VSOCK: add full barrier between test cases
authorStefan Hajnoczi <stefanha@redhat.com>
Wed, 18 Dec 2019 18:07:02 +0000 (19:07 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 21 Dec 2019 05:09:21 +0000 (21:09 -0800)
See code comment for details.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/vsock/util.c

index f838bcee35898a9c60c8bdbac48a90a053542f67..4280a56ba677d352a048d419f828031143590752 100644 (file)
@@ -161,10 +161,24 @@ void run_tests(const struct test_case *test_cases,
                printf("%s...", test_cases[i].name);
                fflush(stdout);
 
-               if (opts->mode == TEST_MODE_CLIENT)
+               if (opts->mode == TEST_MODE_CLIENT) {
+                       /* Full barrier before executing the next test.  This
+                        * ensures that client and server are executing the
+                        * same test case.  In particular, it means whoever is
+                        * faster will not see the peer still executing the
+                        * last test.  This is important because port numbers
+                        * can be used by multiple test cases.
+                        */
+                       control_expectln("NEXT");
+                       control_writeln("NEXT");
+
                        run = test_cases[i].run_client;
-               else
+               } else {
+                       control_writeln("NEXT");
+                       control_expectln("NEXT");
+
                        run = test_cases[i].run_server;
+               }
 
                if (run)
                        run(opts);