[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Make testing more reliable: wait for event after async so we know



# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID 6f4d500001799c44be2f0267017ee409da9ae2ec
# Parent  4e833037159dd09a62ce10011592f9f67005a7e4
Make testing more reliable: wait for event after async so we know
child has done command
Signed-off-by: Rusty Russel <rusty@xxxxxxxxxxxxxxx>
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r 4e833037159d -r 6f4d50000179 tools/xenstore/testsuite/13watch-ack.sh
--- a/tools/xenstore/testsuite/13watch-ack.sh   Tue Jul 26 15:20:09 2005
+++ b/tools/xenstore/testsuite/13watch-ack.sh   Tue Jul 26 15:21:00 2005
@@ -16,8 +16,8 @@
 1 watch /test/2 token2 0
 1 watch /test/3 token3 0
 2 async write /test/2 create contents2
-1 waitwatch
 3 async write /test/1 create contents1
 4 async write /test/3 create contents3
+1 waitwatch
 1 ackwatch token2
 1 close' | ./xs_test 2>&1`" = "1:/test/2:token2" ]
diff -r 4e833037159d -r 6f4d50000179 tools/xenstore/xs_test.c
--- a/tools/xenstore/xs_test.c  Tue Jul 26 15:20:09 2005
+++ b/tools/xenstore/xs_test.c  Tue Jul 26 15:21:00 2005
@@ -406,6 +406,35 @@
                failed(handle);
 }
 
+static bool wait_for_input(unsigned int handle)
+{
+       unsigned int i;
+       for (i = 0; i < ARRAY_SIZE(handles); i++) {
+               int fd;
+
+               if (!handles[i] || i == handle)
+                       continue;
+
+               fd = xs_fileno(handles[i]);
+               if (fd == -2) {
+                       unsigned int avail;
+                       get_input_chunk(in, in->buf, &avail);
+                       if (avail != 0)
+                               return true;
+               } else {
+                       struct timeval tv = {.tv_sec = 0, .tv_usec = 0 };
+                       fd_set set;
+
+                       FD_ZERO(&set);
+                       FD_SET(fd, &set);
+                       if (select(fd+1, &set, NULL, NULL,&tv))
+                               return true;
+               }
+       }
+       return false;
+}
+
+
 /* Async wait for watch on handle */
 static void do_command(unsigned int default_handle, char *line);
 static void do_async(unsigned int handle, char *line)
@@ -413,8 +442,14 @@
        int child;
        unsigned int i;
        children++;
-       if ((child = fork()) != 0)
+       if ((child = fork()) != 0) {
+               /* Wait until *something* happens, which indicates
+                * child has created an event.  V. sloppy, but we can't
+                * select on fake domain connections.
+                */
+               while (!wait_for_input(handle));
                return;
+       }
 
        /* Don't keep other handles open in parent. */
        for (i = 0; i < ARRAY_SIZE(handles); i++) {
@@ -632,7 +667,7 @@
        command = arg(line, 0);
 
        if (timeout)
-               alarm(5);
+               alarm(1);
 
        if (streq(command, "dir"))
                do_dir(handle, arg(line, 1));

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.