From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Hajnoczi Subject: [PATCH 3/5] VSOCK: add full barrier between test cases Date: Wed, 13 Dec 2017 14:49:09 +0000 Message-ID: <20171213144911.6428-4-stefanha@redhat.com> References: <20171213144911.6428-1-stefanha@redhat.com> Cc: Jorgen Hansen , Dexuan Cui , Stefan Hajnoczi To: netdev@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:25421 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753358AbdLMOtU (ORCPT ); Wed, 13 Dec 2017 09:49:20 -0500 In-Reply-To: <20171213144911.6428-1-stefanha@redhat.com> Sender: netdev-owner@vger.kernel.org List-ID: See code comment for details. Signed-off-by: Stefan Hajnoczi --- tools/testing/vsock/util.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/testing/vsock/util.c b/tools/testing/vsock/util.c index 75a78f295b37..2be923fe9922 100644 --- a/tools/testing/vsock/util.c +++ b/tools/testing/vsock/util.c @@ -165,10 +165,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); -- 2.14.3