[nandpart][test] Fix flaky nandpart-broker-test

There is a race between spawning a new ram-nand backed device and trying
to open it afterwards.

The correct fix would be to use fdio_watch_directory to wait for the
file to appear, but unfortunately due to a bug, openat always seems to
fail. The best we can do for now is just put a small sleep.

Tested: runtest -t nandpart-broker-test
Change-Id: Id281f48e935ece84934ac6628a40a9736df40933
diff --git a/system/dev/nand/broker/rules.mk b/system/dev/nand/broker/rules.mk
index 78eaaf4..5b3de27 100644
--- a/system/dev/nand/broker/rules.mk
+++ b/system/dev/nand/broker/rules.mk
@@ -85,6 +85,8 @@
     $(TEST_DIR)/parent.cpp \
 
 MODULE_STATIC_LIBS := \
+    system/ulib/devmgr-integration-test \
+    system/ulib/devmgr-launcher \
     system/ulib/fbl \
     system/ulib/fzl \
     system/ulib/zx \
diff --git a/system/dev/nand/broker/test/nandpart-main.cpp b/system/dev/nand/broker/test/nandpart-main.cpp
index 76975fa..40320b7 100644
--- a/system/dev/nand/broker/test/nandpart-main.cpp
+++ b/system/dev/nand/broker/test/nandpart-main.cpp
@@ -4,6 +4,7 @@
 
 #include "parent.h"
 
+#include <lib/devmgr-integration-test/fixture.h>
 #include <unittest/unittest.h>
 #include <zircon/hw/gpt.h>
 
@@ -52,6 +53,21 @@
         return -1;
     }
 
+    // TODO(ZX-3193)
+#if OPENAT_FIXED
+    // Wait for nandpart to spawn.
+    fbl::unique_fd dir(dup(parent.get()));
+    fbl::unique_fd nandpart;
+    zx_status_t status = devmgr_integration_test::WaitForFile(
+        dir, "test", zx::deadline_after(zx::sec(1)), &nandpart);
+    if (status != ZX_OK) {
+        printf("Unable to attach to device: %d\n", status);
+        return -1;
+    }
+#else
+    usleep(50000);
+#endif
+
     // Construct path to nandpart partition.
     char path[PATH_MAX];
     strcpy(path, parent.Path());