From patchwork Mon Sep 23 17:53:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11157441 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 85B2114ED for ; Mon, 23 Sep 2019 17:53:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 62E2320B7C for ; Mon, 23 Sep 2019 17:53:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502187AbfIWRxk (ORCPT ); Mon, 23 Sep 2019 13:53:40 -0400 Received: from mga14.intel.com ([192.55.52.115]:39308 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394221AbfIWRxj (ORCPT ); Mon, 23 Sep 2019 13:53:39 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:39 -0700 X-IronPort-AV: E=Sophos;i="5.64,541,1559545200"; d="scan'208";a="182620896" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:39 -0700 From: ira.weiny@intel.com To: fstests@vger.kernel.org, Eryu Guan Cc: john.hubbard@gmail.com, Dave Chinner , Jan Kara , Jason Gunthorpe , dan.j.williams@intel.com, Jeff Layton , Ira Weiny Subject: [PATCH V2 01/16] src/locktest: Remove unnecessary sleep Date: Mon, 23 Sep 2019 10:53:21 -0700 Message-Id: <20190923175336.2287-2-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923175336.2287-1-ira.weiny@intel.com> References: <20190923175336.2287-1-ira.weiny@intel.com> MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Ira Weiny There is no need to sleep because we asked for debugging. Remove extra sleep code. Reviewed-by: Jeff Layton Signed-off-by: Ira Weiny --- src/locktest.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/locktest.c b/src/locktest.c index 8e27e922668e..29e914febdf9 100644 --- a/src/locktest.c +++ b/src/locktest.c @@ -69,7 +69,6 @@ extern int h_errno; #define RAND() (rand()) #define SRAND(s) (srand(s)) -#define SLEEP(s) (sleep(s)) #define MIN(A,B) (((A)<(B))?(A):(B)) #define MAX(A,B) (((A)>(B))?(A):(B)) @@ -1037,10 +1036,6 @@ main(int argc, char *argv[]) } } } - if (debug > 1) { - fprintf(stderr, "server sleeping ...\n"); - SLEEP(1); - } if(tests[index][TEST_NUM] != 0) { if(last_test != tests[index][TEST_NUM]) { test_count++; From patchwork Mon Sep 23 17:53:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11157443 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C07917D4 for ; Mon, 23 Sep 2019 17:53:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EF16820882 for ; Mon, 23 Sep 2019 17:53:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502227AbfIWRxk (ORCPT ); Mon, 23 Sep 2019 13:53:40 -0400 Received: from mga06.intel.com ([134.134.136.31]:32885 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394221AbfIWRxk (ORCPT ); Mon, 23 Sep 2019 13:53:40 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:40 -0700 X-IronPort-AV: E=Sophos;i="5.64,541,1559545200"; d="scan'208";a="179208342" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:39 -0700 From: ira.weiny@intel.com To: fstests@vger.kernel.org, Eryu Guan Cc: john.hubbard@gmail.com, Dave Chinner , Jan Kara , Jason Gunthorpe , dan.j.williams@intel.com, Jeff Layton , Ira Weiny Subject: [PATCH V2 02/16] src/locktest: Remove OPEN macro Date: Mon, 23 Sep 2019 10:53:22 -0700 Message-Id: <20190923175336.2287-3-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923175336.2287-1-ira.weiny@intel.com> References: <20190923175336.2287-1-ira.weiny@intel.com> MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Ira Weiny The code is much cleaner without this macro. While here add extra debug output as well. Reviewed-by: Jeff Layton Signed-off-by: Ira Weiny --- src/locktest.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/locktest.c b/src/locktest.c index 29e914febdf9..b5e1cf7669d8 100644 --- a/src/locktest.c +++ b/src/locktest.c @@ -61,7 +61,6 @@ extern int h_errno; #define HANDLE int #define INVALID_HANDLE -1 -#define OPEN(N,F) (open(N, F|O_CREAT|O_BINARY, 0644)) #define SEEK(H, O) (lseek(H, O, SEEK_SET)) #define READ(H, B, L) (read(H, B, L)) #define WRITE(H, B, L) (write(H, B, L)) @@ -598,12 +597,16 @@ initialize(HANDLE fd) int do_open(int flag) { - if ((f_fd = OPEN(filename, flag)) == INVALID_HANDLE) { + int flags = flag|O_CREAT|O_BINARY; + + if(debug > 1) + fprintf(stderr, "do_open %s 0x%x\n", filename, flags); + + if ((f_fd = open(filename, flags, 0666)) == INVALID_HANDLE) { perror("shared file create"); return FAIL; /*NOTREACHED*/ } - return PASS; } From patchwork Mon Sep 23 17:53:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11157447 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CD6417D4 for ; Mon, 23 Sep 2019 17:53:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 54D6A20882 for ; Mon, 23 Sep 2019 17:53:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502228AbfIWRxn (ORCPT ); Mon, 23 Sep 2019 13:53:43 -0400 Received: from mga02.intel.com ([134.134.136.20]:33973 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394221AbfIWRxn (ORCPT ); Mon, 23 Sep 2019 13:53:43 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:41 -0700 X-IronPort-AV: E=Sophos;i="5.64,541,1559545200"; d="scan'208";a="193168181" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:40 -0700 From: ira.weiny@intel.com To: fstests@vger.kernel.org, Eryu Guan Cc: john.hubbard@gmail.com, Dave Chinner , Jan Kara , Jason Gunthorpe , dan.j.williams@intel.com, Jeff Layton , Ira Weiny Subject: [PATCH V2 03/16] src/locktest: Change command macro names Date: Mon, 23 Sep 2019 10:53:23 -0700 Message-Id: <20190923175336.2287-4-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923175336.2287-1-ira.weiny@intel.com> References: <20190923175336.2287-1-ira.weiny@intel.com> MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Ira Weiny The macro names for commands are not consistent. Change them such that they are not confused with other flags and macros within the test. Reviewed-by: Jeff Layton Signed-off-by: Ira Weiny --- src/locktest.c | 546 ++++++++++++++++++++++++------------------------- 1 file changed, 273 insertions(+), 273 deletions(-) diff --git a/src/locktest.c b/src/locktest.c index b5e1cf7669d8..ce04ecba6205 100644 --- a/src/locktest.c +++ b/src/locktest.c @@ -87,13 +87,13 @@ static SOCKET s_fd = -1; /* listen socket */ static SOCKET c_fd = -1; /* IPC socket */ static HANDLE f_fd = INVALID_HANDLE; /* shared file */ -#define WRLOCK 0 -#define RDLOCK 1 -#define UNLOCK 2 -#define F_CLOSE 3 -#define F_OPEN 4 -#define WRTEST 5 -#define RDTEST 6 +#define CMD_WRLOCK 0 +#define CMD_RDLOCK 1 +#define CMD_UNLOCK 2 +#define CMD_CLOSE 3 +#define CMD_OPEN 4 +#define CMD_WRTEST 5 +#define CMD_RDTEST 6 #define PASS 1 #define FAIL 0 @@ -175,361 +175,361 @@ static int64_t tests[][6] = { /* Various simple tests exercising the list */ -/* SECTION 1: WRITE and UNLOCK with the same process (SERVER) */ +/* SECTION 1: WRITE and CMD_UNLOCK with the same process (SERVER) */ /* Add a lock to an empty list */ - {1, WRLOCK, 1, 10, PASS, SERVER }, - {1, UNLOCK, 1, 10, PASS, SERVER }, + {1, CMD_WRLOCK, 1, 10, PASS, SERVER }, + {1, CMD_UNLOCK, 1, 10, PASS, SERVER }, /* Add a lock to the start and end of a list - 1, 13 - no overlap */ - {2, WRLOCK, 10, 10, PASS, SERVER }, - {2, WRLOCK, 30, 10, PASS, SERVER }, - {2, WRLOCK, 50, 10, PASS, SERVER }, - {2, WRLOCK, 1, 5, PASS, SERVER }, - {2, WRLOCK, 70, 5, PASS, SERVER }, + {2, CMD_WRLOCK, 10, 10, PASS, SERVER }, + {2, CMD_WRLOCK, 30, 10, PASS, SERVER }, + {2, CMD_WRLOCK, 50, 10, PASS, SERVER }, + {2, CMD_WRLOCK, 1, 5, PASS, SERVER }, + {2, CMD_WRLOCK, 70, 5, PASS, SERVER }, - {2, UNLOCK, 10, 10, PASS, SERVER }, - {2, UNLOCK, 30, 10, PASS, SERVER }, - {2, UNLOCK, 50, 10, PASS, SERVER }, - {2, UNLOCK, 1, 5, PASS, SERVER }, - {2, UNLOCK, 70, 5, PASS, SERVER }, + {2, CMD_UNLOCK, 10, 10, PASS, SERVER }, + {2, CMD_UNLOCK, 30, 10, PASS, SERVER }, + {2, CMD_UNLOCK, 50, 10, PASS, SERVER }, + {2, CMD_UNLOCK, 1, 5, PASS, SERVER }, + {2, CMD_UNLOCK, 70, 5, PASS, SERVER }, /* Add a lock to the middle of a list - no overlap */ - {3, WRLOCK, 10, 10, PASS, SERVER }, - {3, WRLOCK, 30, 10, PASS, SERVER }, - {3, WRLOCK, 50, 10, PASS, SERVER }, - {3, WRLOCK, 42, 5, PASS, SERVER }, + {3, CMD_WRLOCK, 10, 10, PASS, SERVER }, + {3, CMD_WRLOCK, 30, 10, PASS, SERVER }, + {3, CMD_WRLOCK, 50, 10, PASS, SERVER }, + {3, CMD_WRLOCK, 42, 5, PASS, SERVER }, - {3, UNLOCK, 10, 10, PASS, SERVER }, - {3, UNLOCK, 30, 10, PASS, SERVER }, - {3, UNLOCK, 50, 10, PASS, SERVER }, - {3, UNLOCK, 42, 5, PASS, SERVER }, + {3, CMD_UNLOCK, 10, 10, PASS, SERVER }, + {3, CMD_UNLOCK, 30, 10, PASS, SERVER }, + {3, CMD_UNLOCK, 50, 10, PASS, SERVER }, + {3, CMD_UNLOCK, 42, 5, PASS, SERVER }, /* Add different lock types to middle of the list - overlap exact match - 3 */ - {4, WRLOCK, 10, 10, PASS, SERVER }, - {4, WRLOCK, 30, 10, PASS, SERVER }, - {4, WRLOCK, 50, 10, PASS, SERVER }, + {4, CMD_WRLOCK, 10, 10, PASS, SERVER }, + {4, CMD_WRLOCK, 30, 10, PASS, SERVER }, + {4, CMD_WRLOCK, 50, 10, PASS, SERVER }, /* Exact match - same lock type */ - {4, WRLOCK, 30, 10, PASS, SERVER }, + {4, CMD_WRLOCK, 30, 10, PASS, SERVER }, /* Exact match - different lock type */ - {4, RDLOCK, 30, 10, PASS, SERVER }, + {4, CMD_RDLOCK, 30, 10, PASS, SERVER }, /* Exact match - unlock */ - {4, UNLOCK, 30, 10, PASS, SERVER }, + {4, CMD_UNLOCK, 30, 10, PASS, SERVER }, /* New lock - as above, inserting in the list again */ - {4, WRLOCK, 30, 10, PASS, SERVER }, + {4, CMD_WRLOCK, 30, 10, PASS, SERVER }, - {4, UNLOCK, 10, 10, PASS, SERVER }, - {4, UNLOCK, 30, 10, PASS, SERVER }, - {4, UNLOCK, 50, 10, PASS, SERVER }, + {4, CMD_UNLOCK, 10, 10, PASS, SERVER }, + {4, CMD_UNLOCK, 30, 10, PASS, SERVER }, + {4, CMD_UNLOCK, 50, 10, PASS, SERVER }, /* Add new lock which completely overlaps any old lock in the list - 4,5,6 */ - {5, WRLOCK, 10, 10, PASS, SERVER }, - {5, WRLOCK, 30, 10, PASS, SERVER }, - {5, WRLOCK, 50, 10, PASS, SERVER }, + {5, CMD_WRLOCK, 10, 10, PASS, SERVER }, + {5, CMD_WRLOCK, 30, 10, PASS, SERVER }, + {5, CMD_WRLOCK, 50, 10, PASS, SERVER }, /* The start is the same, end overlaps */ - {5, WRLOCK, 30, 15, PASS, SERVER }, + {5, CMD_WRLOCK, 30, 15, PASS, SERVER }, /* The start is before, end is the same */ - {5, WRLOCK, 25, 20, PASS, SERVER }, + {5, CMD_WRLOCK, 25, 20, PASS, SERVER }, /* Both start and end overlap */ - {5, WRLOCK, 22, 26, PASS, SERVER }, + {5, CMD_WRLOCK, 22, 26, PASS, SERVER }, - {5, UNLOCK, 10, 10, PASS, SERVER }, - {5, UNLOCK, 22, 26, PASS, SERVER }, - {5, UNLOCK, 50, 10, PASS, SERVER }, + {5, CMD_UNLOCK, 10, 10, PASS, SERVER }, + {5, CMD_UNLOCK, 22, 26, PASS, SERVER }, + {5, CMD_UNLOCK, 50, 10, PASS, SERVER }, /* Add new lock which itself is completely overlaped by any old lock in the list - 7,8,10 */ - {6, WRLOCK, 10, 10, PASS, SERVER }, - {6, WRLOCK, 30, 10, PASS, SERVER }, - {6, WRLOCK, 50, 10, PASS, SERVER }, + {6, CMD_WRLOCK, 10, 10, PASS, SERVER }, + {6, CMD_WRLOCK, 30, 10, PASS, SERVER }, + {6, CMD_WRLOCK, 50, 10, PASS, SERVER }, /* The start is the same, end is in the middle of old lock - NOP */ - {6, WRLOCK, 30, 5, PASS, SERVER }, + {6, CMD_WRLOCK, 30, 5, PASS, SERVER }, /* The start and end are in the middle of old lock - NOP */ - {6, WRLOCK, 32, 6, PASS, SERVER }, + {6, CMD_WRLOCK, 32, 6, PASS, SERVER }, /* Start in the middle and end is the same - NOP */ - {6, WRLOCK, 32, 8, PASS, SERVER }, + {6, CMD_WRLOCK, 32, 8, PASS, SERVER }, - {6, UNLOCK, 10, 10, PASS, SERVER }, - {6, UNLOCK, 30, 10, PASS, SERVER }, - {6, UNLOCK, 32, 8, PASS, SERVER }, - {6, UNLOCK, 50, 10, PASS, SERVER }, + {6, CMD_UNLOCK, 10, 10, PASS, SERVER }, + {6, CMD_UNLOCK, 30, 10, PASS, SERVER }, + {6, CMD_UNLOCK, 32, 8, PASS, SERVER }, + {6, CMD_UNLOCK, 50, 10, PASS, SERVER }, /* Add new lock which starts before any old lock in the list - 2,9 */ - {7, WRLOCK, 10, 10, PASS, SERVER }, - {7, WRLOCK, 30, 10, PASS, SERVER }, - {7, WRLOCK, 50, 10, PASS, SERVER }, + {7, CMD_WRLOCK, 10, 10, PASS, SERVER }, + {7, CMD_WRLOCK, 30, 10, PASS, SERVER }, + {7, CMD_WRLOCK, 50, 10, PASS, SERVER }, /* Here is the new lock */ - {7, WRLOCK, 27, 10, PASS, SERVER }, + {7, CMD_WRLOCK, 27, 10, PASS, SERVER }, /* Go again with the end of the new lock matching the start of old lock */ - {7, WRLOCK, 25, 2, PASS, SERVER }, + {7, CMD_WRLOCK, 25, 2, PASS, SERVER }, - {7, UNLOCK, 10, 10, PASS, SERVER }, - {7, UNLOCK, 25, 15, PASS, SERVER }, - {7, UNLOCK, 50, 10, PASS, SERVER }, + {7, CMD_UNLOCK, 10, 10, PASS, SERVER }, + {7, CMD_UNLOCK, 25, 15, PASS, SERVER }, + {7, CMD_UNLOCK, 50, 10, PASS, SERVER }, /* Add new lock which starts in the middle of any old lock in the list and ends after - 11,12 */ - {8, WRLOCK, 10, 10, PASS, SERVER }, - {8, WRLOCK, 30, 10, PASS, SERVER }, - {8, WRLOCK, 50, 10, PASS, SERVER }, + {8, CMD_WRLOCK, 10, 10, PASS, SERVER }, + {8, CMD_WRLOCK, 30, 10, PASS, SERVER }, + {8, CMD_WRLOCK, 50, 10, PASS, SERVER }, /* Here is the new lock */ - {8, WRLOCK, 35, 10, PASS, SERVER }, + {8, CMD_WRLOCK, 35, 10, PASS, SERVER }, /* Go again with the end of the new lock matching the start of old lock */ - {8, WRLOCK, 45, 2, PASS, SERVER }, + {8, CMD_WRLOCK, 45, 2, PASS, SERVER }, - {8, UNLOCK, 10, 10, PASS, SERVER }, - {8, UNLOCK, 30, 17, PASS, SERVER }, - {8, UNLOCK, 50, 10, PASS, SERVER }, -/* SECTION 2: Overlapping READ and WRITE and UNLOCK with the same process (SERVER) */ + {8, CMD_UNLOCK, 10, 10, PASS, SERVER }, + {8, CMD_UNLOCK, 30, 17, PASS, SERVER }, + {8, CMD_UNLOCK, 50, 10, PASS, SERVER }, +/* SECTION 2: Overlapping READ and WRITE and CMD_UNLOCK with the same process (SERVER) */ /* Add different new lock types which completely overlaps any old lock in the list - 4,5,6 */ - {9, WRLOCK, 10, 10, PASS, SERVER }, - {9, WRLOCK, 30, 10, PASS, SERVER }, - {9, WRLOCK, 50, 10, PASS, SERVER }, + {9, CMD_WRLOCK, 10, 10, PASS, SERVER }, + {9, CMD_WRLOCK, 30, 10, PASS, SERVER }, + {9, CMD_WRLOCK, 50, 10, PASS, SERVER }, /* The start is the same, end overlaps */ - {9, RDLOCK, 30, 15, PASS, SERVER }, + {9, CMD_RDLOCK, 30, 15, PASS, SERVER }, /* The start is before, end is the same */ - {9, WRLOCK, 25, 20, PASS, SERVER }, + {9, CMD_WRLOCK, 25, 20, PASS, SERVER }, /* Both start and end overlap */ - {9, RDLOCK, 22, 26, PASS, SERVER }, + {9, CMD_RDLOCK, 22, 26, PASS, SERVER }, - {9, UNLOCK, 10, 10, PASS, SERVER }, - {9, UNLOCK, 22, 26, PASS, SERVER }, - {9, UNLOCK, 50, 10, PASS, SERVER }, + {9, CMD_UNLOCK, 10, 10, PASS, SERVER }, + {9, CMD_UNLOCK, 22, 26, PASS, SERVER }, + {9, CMD_UNLOCK, 50, 10, PASS, SERVER }, /* Add different new locks which are completely overlaped by an old lock in the list - 7,8,10 */ - {10, WRLOCK, 10, 10, PASS, SERVER }, - {10, WRLOCK, 30, 10, PASS, SERVER }, - {10, WRLOCK, 50, 10, PASS, SERVER }, + {10, CMD_WRLOCK, 10, 10, PASS, SERVER }, + {10, CMD_WRLOCK, 30, 10, PASS, SERVER }, + {10, CMD_WRLOCK, 50, 10, PASS, SERVER }, /* The start is the same, end is in the middle of old lock */ - {10, RDLOCK, 30, 5, PASS, SERVER }, + {10, CMD_RDLOCK, 30, 5, PASS, SERVER }, /* The start and end are in the middle of a lock */ - {10, WRLOCK, 32, 2, PASS, SERVER }, + {10, CMD_WRLOCK, 32, 2, PASS, SERVER }, /* Start in the middle and end is the same */ - {10, RDLOCK, 36, 5, PASS, SERVER }, + {10, CMD_RDLOCK, 36, 5, PASS, SERVER }, - {10, UNLOCK, 10, 10, PASS, SERVER }, - {10, UNLOCK, 30, 11, PASS, SERVER }, - {10, UNLOCK, 50, 10, PASS, SERVER }, + {10, CMD_UNLOCK, 10, 10, PASS, SERVER }, + {10, CMD_UNLOCK, 30, 11, PASS, SERVER }, + {10, CMD_UNLOCK, 50, 10, PASS, SERVER }, /* Add different new lock types which start before the old lock in the list - 2,9 */ - {11, WRLOCK, 10, 10, PASS, SERVER }, - {11, WRLOCK, 30, 10, PASS, SERVER }, - {11, WRLOCK, 50, 10, PASS, SERVER }, + {11, CMD_WRLOCK, 10, 10, PASS, SERVER }, + {11, CMD_WRLOCK, 30, 10, PASS, SERVER }, + {11, CMD_WRLOCK, 50, 10, PASS, SERVER }, /* Here is the new lock */ - {11, RDLOCK, 27, 10, PASS, SERVER }, + {11, CMD_RDLOCK, 27, 10, PASS, SERVER }, /* Go again with the end of the new lock matching the start of lock */ - {11, WRLOCK, 25, 3, PASS, SERVER }, + {11, CMD_WRLOCK, 25, 3, PASS, SERVER }, - {11, UNLOCK, 10, 10, PASS, SERVER }, - {11, UNLOCK, 25, 15, PASS, SERVER }, - {11, UNLOCK, 50, 10, PASS, SERVER }, + {11, CMD_UNLOCK, 10, 10, PASS, SERVER }, + {11, CMD_UNLOCK, 25, 15, PASS, SERVER }, + {11, CMD_UNLOCK, 50, 10, PASS, SERVER }, /* Add different new lock types which start in the middle of an old lock in the list and end after - 11,12 */ - {12, WRLOCK, 10, 10, PASS, SERVER }, - {12, WRLOCK, 30, 10, PASS, SERVER }, - {12, WRLOCK, 50, 10, PASS, SERVER }, + {12, CMD_WRLOCK, 10, 10, PASS, SERVER }, + {12, CMD_WRLOCK, 30, 10, PASS, SERVER }, + {12, CMD_WRLOCK, 50, 10, PASS, SERVER }, /* Here is the new lock */ - {12, RDLOCK, 35, 10, PASS, SERVER }, + {12, CMD_RDLOCK, 35, 10, PASS, SERVER }, /* Go again with the end of the new lock matching the start of old lock */ - {12, WRLOCK, 44, 3, PASS, SERVER }, + {12, CMD_WRLOCK, 44, 3, PASS, SERVER }, - {12, UNLOCK, 10, 10, PASS, SERVER }, - {12, UNLOCK, 30, 18, PASS, SERVER }, - {12, UNLOCK, 50, 10, PASS, SERVER }, + {12, CMD_UNLOCK, 10, 10, PASS, SERVER }, + {12, CMD_UNLOCK, 30, 18, PASS, SERVER }, + {12, CMD_UNLOCK, 50, 10, PASS, SERVER }, -/* SECTION 3: Overlapping READ and WRITE and UNLOCK with the different processes (CLIENT/SERVER) */ +/* SECTION 3: Overlapping READ and WRITE and CMD_UNLOCK with the different processes (CLIENT/SERVER) */ /* Add new lock, differing types and processes, to middle of the list - exact overlap match - 3 */ - {13, WRLOCK, 10, 10, PASS, SERVER }, - {13, WRLOCK, 30, 10, PASS, SERVER }, - {13, RDLOCK, 50, 10, PASS, SERVER }, + {13, CMD_WRLOCK, 10, 10, PASS, SERVER }, + {13, CMD_WRLOCK, 30, 10, PASS, SERVER }, + {13, CMD_RDLOCK, 50, 10, PASS, SERVER }, /* Same lock type, different process */ - {13, WRLOCK, 30, 10, FAIL, CLIENT }, - {13, RDLOCK, 50, 10, PASS, CLIENT }, + {13, CMD_WRLOCK, 30, 10, FAIL, CLIENT }, + {13, CMD_RDLOCK, 50, 10, PASS, CLIENT }, /* Exact match - different lock type, different process */ - {13, RDLOCK, 30, 10, FAIL, CLIENT }, + {13, CMD_RDLOCK, 30, 10, FAIL, CLIENT }, /* Exact match - unlock */ - {13, UNLOCK, 30, 10, PASS, CLIENT }, + {13, CMD_UNLOCK, 30, 10, PASS, CLIENT }, /* New lock - as above, inserting in the list again */ - {13, UNLOCK, 30, 10, PASS, SERVER }, + {13, CMD_UNLOCK, 30, 10, PASS, SERVER }, /* Exact match - same lock type, different process */ - {13, WRLOCK, 30, 10, PASS, CLIENT }, + {13, CMD_WRLOCK, 30, 10, PASS, CLIENT }, - {13, UNLOCK, 10, 10, PASS, SERVER }, - {13, UNLOCK, 30, 10, PASS, CLIENT }, - {13, UNLOCK, 50, 10, PASS, SERVER }, + {13, CMD_UNLOCK, 10, 10, PASS, SERVER }, + {13, CMD_UNLOCK, 30, 10, PASS, CLIENT }, + {13, CMD_UNLOCK, 50, 10, PASS, SERVER }, /* Add new lock, differing types and processes, which completely overlap any of the locks in the list - 4,5,6 */ - {14, WRLOCK, 10, 10, PASS, SERVER }, - {14, WRLOCK, 30, 10, PASS, SERVER }, - {14, RDLOCK, 50, 10, PASS, SERVER }, + {14, CMD_WRLOCK, 10, 10, PASS, SERVER }, + {14, CMD_WRLOCK, 30, 10, PASS, SERVER }, + {14, CMD_RDLOCK, 50, 10, PASS, SERVER }, /* The start is the same, end overlaps */ - {14, RDLOCK, 30, 15, FAIL, CLIENT }, - {14, WRLOCK, 30, 15, FAIL, CLIENT }, + {14, CMD_RDLOCK, 30, 15, FAIL, CLIENT }, + {14, CMD_WRLOCK, 30, 15, FAIL, CLIENT }, /* The start is before, end is the same */ - {14, RDLOCK, 25, 20, FAIL, CLIENT }, - {14, WRLOCK, 25, 20, FAIL, CLIENT }, + {14, CMD_RDLOCK, 25, 20, FAIL, CLIENT }, + {14, CMD_WRLOCK, 25, 20, FAIL, CLIENT }, /* Both start and end overlap */ - {14, RDLOCK, 22, 26, FAIL, CLIENT }, - {14, WRLOCK, 22, 26, FAIL, CLIENT }, + {14, CMD_RDLOCK, 22, 26, FAIL, CLIENT }, + {14, CMD_WRLOCK, 22, 26, FAIL, CLIENT }, /* The start is the same, end overlaps */ - {14, RDLOCK, 50, 15, PASS, CLIENT }, - {14, WRLOCK, 50, 17, FAIL, CLIENT }, + {14, CMD_RDLOCK, 50, 15, PASS, CLIENT }, + {14, CMD_WRLOCK, 50, 17, FAIL, CLIENT }, /* The start is before, end is the same */ - {14, RDLOCK, 45, 20, PASS, CLIENT }, - {14, WRLOCK, 43, 22, FAIL, CLIENT }, + {14, CMD_RDLOCK, 45, 20, PASS, CLIENT }, + {14, CMD_WRLOCK, 43, 22, FAIL, CLIENT }, /* Both start and end overlap */ - {14, RDLOCK, 42, 26, PASS, CLIENT }, - {14, WRLOCK, 41, 28, FAIL, CLIENT }, + {14, CMD_RDLOCK, 42, 26, PASS, CLIENT }, + {14, CMD_WRLOCK, 41, 28, FAIL, CLIENT }, - {14, UNLOCK, 10, 10, PASS, SERVER }, - {14, UNLOCK, 22, 26, PASS, SERVER }, - {14, UNLOCK, 42, 26, PASS, CLIENT }, + {14, CMD_UNLOCK, 10, 10, PASS, SERVER }, + {14, CMD_UNLOCK, 22, 26, PASS, SERVER }, + {14, CMD_UNLOCK, 42, 26, PASS, CLIENT }, /* Add new lock, differing types and processes, which are completely overlaped by an old lock in the list - 7,8,10 */ - {15, WRLOCK, 10, 10, PASS, SERVER }, - {15, RDLOCK, 30, 10, PASS, SERVER }, - {15, WRLOCK, 50, 10, PASS, SERVER }, + {15, CMD_WRLOCK, 10, 10, PASS, SERVER }, + {15, CMD_RDLOCK, 30, 10, PASS, SERVER }, + {15, CMD_WRLOCK, 50, 10, PASS, SERVER }, /* The start is the same, end is in the middle of old lock */ - {15, RDLOCK, 50, 5, FAIL, CLIENT }, - {15, WRLOCK, 50, 5, FAIL, CLIENT }, + {15, CMD_RDLOCK, 50, 5, FAIL, CLIENT }, + {15, CMD_WRLOCK, 50, 5, FAIL, CLIENT }, /* The start and end are in the middle of old lock */ - {15, RDLOCK, 52, 6, FAIL, CLIENT }, - {15, WRLOCK, 52, 6, FAIL, CLIENT }, + {15, CMD_RDLOCK, 52, 6, FAIL, CLIENT }, + {15, CMD_WRLOCK, 52, 6, FAIL, CLIENT }, /* Start in the middle and end is the same */ - {15, RDLOCK, 52, 8, FAIL, CLIENT }, - {15, WRLOCK, 52, 8, FAIL, CLIENT }, + {15, CMD_RDLOCK, 52, 8, FAIL, CLIENT }, + {15, CMD_WRLOCK, 52, 8, FAIL, CLIENT }, /* The start is the same, end is in the middle of old lock */ - {15, RDLOCK, 30, 5, PASS, CLIENT }, - {15, WRLOCK, 30, 5, FAIL, CLIENT }, + {15, CMD_RDLOCK, 30, 5, PASS, CLIENT }, + {15, CMD_WRLOCK, 30, 5, FAIL, CLIENT }, /* The start and end are in the middle of old lock */ - {15, RDLOCK, 32, 6, PASS, CLIENT }, - {15, WRLOCK, 32, 6, FAIL, CLIENT }, + {15, CMD_RDLOCK, 32, 6, PASS, CLIENT }, + {15, CMD_WRLOCK, 32, 6, FAIL, CLIENT }, /* Start in the middle and end is the same */ - {15, RDLOCK, 32, 8, PASS, CLIENT }, - {15, WRLOCK, 32, 8, FAIL, CLIENT }, + {15, CMD_RDLOCK, 32, 8, PASS, CLIENT }, + {15, CMD_WRLOCK, 32, 8, FAIL, CLIENT }, - {15, UNLOCK, 10, 10, PASS, SERVER }, - {15, UNLOCK, 30, 10, PASS, SERVER }, - {15, UNLOCK, 50, 10, PASS, SERVER }, + {15, CMD_UNLOCK, 10, 10, PASS, SERVER }, + {15, CMD_UNLOCK, 30, 10, PASS, SERVER }, + {15, CMD_UNLOCK, 50, 10, PASS, SERVER }, /* Add new lock, differing types and processes, which start before a lock in the list - 2,9 */ - {16, RDLOCK, 10, 10, PASS, SERVER }, - {16, WRLOCK, 50, 10, PASS, SERVER }, + {16, CMD_RDLOCK, 10, 10, PASS, SERVER }, + {16, CMD_WRLOCK, 50, 10, PASS, SERVER }, /* Start is before, end is the start of the old lock in list */ - {16, RDLOCK, 5, 6, PASS, CLIENT }, - {16, WRLOCK, 5, 6, FAIL, CLIENT }, + {16, CMD_RDLOCK, 5, 6, PASS, CLIENT }, + {16, CMD_WRLOCK, 5, 6, FAIL, CLIENT }, /* Start is before, end is in the middle of the old lock */ - {16, RDLOCK, 5, 10, PASS, CLIENT }, - {16, WRLOCK, 5, 10, FAIL, CLIENT }, + {16, CMD_RDLOCK, 5, 10, PASS, CLIENT }, + {16, CMD_WRLOCK, 5, 10, FAIL, CLIENT }, /* Start is before, end is the start of the old lock in list */ - {16, RDLOCK, 45, 6, FAIL, CLIENT }, - {16, WRLOCK, 45, 6, FAIL, CLIENT }, + {16, CMD_RDLOCK, 45, 6, FAIL, CLIENT }, + {16, CMD_WRLOCK, 45, 6, FAIL, CLIENT }, /* Start is before, end is in the middle of the old lock */ - {16, RDLOCK, 45, 10, FAIL, CLIENT }, - {16, WRLOCK, 45, 10, FAIL, CLIENT }, + {16, CMD_RDLOCK, 45, 10, FAIL, CLIENT }, + {16, CMD_WRLOCK, 45, 10, FAIL, CLIENT }, - {16, UNLOCK, 5, 15, PASS, CLIENT }, - {16, UNLOCK, 30, 10, PASS, SERVER }, - {16, UNLOCK, 50, 10, PASS, SERVER }, + {16, CMD_UNLOCK, 5, 15, PASS, CLIENT }, + {16, CMD_UNLOCK, 30, 10, PASS, SERVER }, + {16, CMD_UNLOCK, 50, 10, PASS, SERVER }, /* Add new lock, differing types and processes, which starts in the middle of a lock, and ends after - 11,12 */ - {17, WRLOCK, 10, 10, PASS, SERVER }, - {17, RDLOCK, 30, 10, PASS, SERVER }, - {17, WRLOCK, 50, 10, PASS, SERVER }, + {17, CMD_WRLOCK, 10, 10, PASS, SERVER }, + {17, CMD_RDLOCK, 30, 10, PASS, SERVER }, + {17, CMD_WRLOCK, 50, 10, PASS, SERVER }, /* Start in the middle, end after lock in list */ - {17, WRLOCK, 35, 10, FAIL, CLIENT }, + {17, CMD_WRLOCK, 35, 10, FAIL, CLIENT }, /* Start matches end of lock in list */ - {17, RDLOCK, 35, 10, PASS, CLIENT }, - {17, RDLOCK, 44, 2, PASS, CLIENT }, + {17, CMD_RDLOCK, 35, 10, PASS, CLIENT }, + {17, CMD_RDLOCK, 44, 2, PASS, CLIENT }, /* Start in the middle, end after lock in list */ - {17, RDLOCK, 55, 10, FAIL, CLIENT }, - {17, WRLOCK, 55, 10, FAIL, CLIENT }, + {17, CMD_RDLOCK, 55, 10, FAIL, CLIENT }, + {17, CMD_WRLOCK, 55, 10, FAIL, CLIENT }, /* Start matches end of lock in list */ - {17, RDLOCK, 59, 5, FAIL, CLIENT }, - {17, WRLOCK, 59, 5, FAIL, CLIENT }, + {17, CMD_RDLOCK, 59, 5, FAIL, CLIENT }, + {17, CMD_WRLOCK, 59, 5, FAIL, CLIENT }, - {17, UNLOCK, 10, 10, PASS, SERVER }, - {17, UNLOCK, 30, 16, PASS, CLIENT }, - {17, UNLOCK, 50, 10, PASS, SERVER }, + {17, CMD_UNLOCK, 10, 10, PASS, SERVER }, + {17, CMD_UNLOCK, 30, 16, PASS, CLIENT }, + {17, CMD_UNLOCK, 50, 10, PASS, SERVER }, /* SECTION 4: overlapping and EOF tests */ /* Acquire overlapping ranges */ - {18, WRLOCK, 11, 7, PASS, SERVER }, - {18, WRLOCK, 13, 8, FAIL, CLIENT }, - {18, UNLOCK, 11, 7, PASS, SERVER }, + {18, CMD_WRLOCK, 11, 7, PASS, SERVER }, + {18, CMD_WRLOCK, 13, 8, FAIL, CLIENT }, + {18, CMD_UNLOCK, 11, 7, PASS, SERVER }, /* Acquire different ranges beyond EOF */ - {19, WRLOCK, 10, FILE_SIZE, PASS, SERVER }, - {19, WRLOCK, FILE_SIZE + 10, 10, PASS, CLIENT }, - {19, UNLOCK, 10, FILE_SIZE, PASS, SERVER }, - {19, UNLOCK, FILE_SIZE + 10, 10, PASS, CLIENT }, + {19, CMD_WRLOCK, 10, FILE_SIZE, PASS, SERVER }, + {19, CMD_WRLOCK, FILE_SIZE + 10, 10, PASS, CLIENT }, + {19, CMD_UNLOCK, 10, FILE_SIZE, PASS, SERVER }, + {19, CMD_UNLOCK, FILE_SIZE + 10, 10, PASS, CLIENT }, /* Acquire same range beyong EOF */ - {20, WRLOCK, 10, FILE_SIZE, PASS, SERVER, }, - {20, WRLOCK, 10, FILE_SIZE, FAIL, CLIENT, }, - {20, UNLOCK, 10, FILE_SIZE, PASS, SERVER, }, + {20, CMD_WRLOCK, 10, FILE_SIZE, PASS, SERVER, }, + {20, CMD_WRLOCK, 10, FILE_SIZE, FAIL, CLIENT, }, + {20, CMD_UNLOCK, 10, FILE_SIZE, PASS, SERVER, }, /* Acquire whole file lock */ - {21, WRLOCK, 0, 0, PASS, SERVER, }, - {21, WRLOCK, 0, 0, FAIL, CLIENT, }, - {21, UNLOCK, 0, 0, PASS, SERVER, }, + {21, CMD_WRLOCK, 0, 0, PASS, SERVER, }, + {21, CMD_WRLOCK, 0, 0, FAIL, CLIENT, }, + {21, CMD_UNLOCK, 0, 0, PASS, SERVER, }, /* Acquire whole file lock, then range */ - {22, WRLOCK, 0, 0, PASS, SERVER, }, - {22, WRLOCK, 1, 5, FAIL, CLIENT, }, - {22, UNLOCK, 0, 0, PASS, SERVER, }, + {22, CMD_WRLOCK, 0, 0, PASS, SERVER, }, + {22, CMD_WRLOCK, 1, 5, FAIL, CLIENT, }, + {22, CMD_UNLOCK, 0, 0, PASS, SERVER, }, /* Acquire non-overlapping read locks */ - {23, RDLOCK, 1, 5, PASS, SERVER, }, - {23, RDLOCK, 7, 6, PASS, CLIENT, }, - {23, UNLOCK, 1, 5, PASS, SERVER, }, - {23, UNLOCK, 7, 6, PASS, CLIENT, }, + {23, CMD_RDLOCK, 1, 5, PASS, SERVER, }, + {23, CMD_RDLOCK, 7, 6, PASS, CLIENT, }, + {23, CMD_UNLOCK, 1, 5, PASS, SERVER, }, + {23, CMD_UNLOCK, 7, 6, PASS, CLIENT, }, /* Acquire overlapping read locks */ - {24, RDLOCK, 1, 5, PASS, SERVER, }, - {24, RDLOCK, 2, 6, PASS, CLIENT, }, - {24, UNLOCK, 1, 5, PASS, SERVER, }, - {24, UNLOCK, 1, 7, PASS, CLIENT, }, + {24, CMD_RDLOCK, 1, 5, PASS, SERVER, }, + {24, CMD_RDLOCK, 2, 6, PASS, CLIENT, }, + {24, CMD_UNLOCK, 1, 5, PASS, SERVER, }, + {24, CMD_UNLOCK, 1, 7, PASS, CLIENT, }, /* Acquire non-overlapping read and write locks */ - {25, RDLOCK, 1, 5, PASS, SERVER, }, - {25, WRLOCK, 7, 6, PASS, CLIENT, }, - {25, UNLOCK, 1, 5, PASS, SERVER, }, - {25, UNLOCK, 7, 6, PASS, CLIENT, }, + {25, CMD_RDLOCK, 1, 5, PASS, SERVER, }, + {25, CMD_WRLOCK, 7, 6, PASS, CLIENT, }, + {25, CMD_UNLOCK, 1, 5, PASS, SERVER, }, + {25, CMD_UNLOCK, 7, 6, PASS, CLIENT, }, /* Acquire overlapping read and write locks */ - {26, RDLOCK, 1, 5, PASS, SERVER, }, - {26, WRLOCK, 2, 6, FAIL, CLIENT, }, - {26, UNLOCK, 1, 5, PASS, SERVER, }, + {26, CMD_RDLOCK, 1, 5, PASS, SERVER, }, + {26, CMD_WRLOCK, 2, 6, FAIL, CLIENT, }, + {26, CMD_UNLOCK, 1, 5, PASS, SERVER, }, /* Acquire whole file lock, then close (without unlocking) */ - {27, WRLOCK, 0, 0, PASS, SERVER, }, - {27, WRLOCK, 1, 5, FAIL, CLIENT, }, - {27, F_CLOSE,0, 0, PASS, SERVER, }, - {27, WRLOCK, 1, 5, PASS, CLIENT, }, - {27, F_OPEN, O_RDWR, 0, PASS, SERVER, }, - {27, UNLOCK, 1, 5, PASS, CLIENT, }, + {27, CMD_WRLOCK, 0, 0, PASS, SERVER, }, + {27, CMD_WRLOCK, 1, 5, FAIL, CLIENT, }, + {27, CMD_CLOSE,0, 0, PASS, SERVER, }, + {27, CMD_WRLOCK, 1, 5, PASS, CLIENT, }, + {27, CMD_OPEN, O_RDWR, 0, PASS, SERVER, }, + {27, CMD_UNLOCK, 1, 5, PASS, CLIENT, }, /* Acquire two read locks, close one file and then reopen to check that first lock still exists */ - {28, RDLOCK, 1, 5, PASS, SERVER, }, - {28, RDLOCK, 1, 5, PASS, CLIENT, }, - {28, F_CLOSE,0, 0, PASS, SERVER, }, - {28, F_OPEN, O_RDWR, 0, PASS, SERVER, }, - {28, WRLOCK, 0, 0, FAIL, SERVER, }, - {28, UNLOCK, 1, 5, PASS, SERVER, }, + {28, CMD_RDLOCK, 1, 5, PASS, SERVER, }, + {28, CMD_RDLOCK, 1, 5, PASS, CLIENT, }, + {28, CMD_CLOSE,0, 0, PASS, SERVER, }, + {28, CMD_OPEN, O_RDWR, 0, PASS, SERVER, }, + {28, CMD_WRLOCK, 0, 0, FAIL, SERVER, }, + {28, CMD_UNLOCK, 1, 5, PASS, SERVER, }, /* Verify that F_GETLK for F_WRLCK doesn't require that file be opened for write */ - {29, F_CLOSE, 0, 0, PASS, SERVER, }, - {29, F_OPEN, O_RDONLY, 0, PASS, SERVER, }, - {29, WRTEST, 0, 0, PASS, SERVER, }, - {29, F_CLOSE,0, 0, PASS, SERVER, }, - {29, F_OPEN, O_RDWR, 0, PASS, SERVER, }, + {29, CMD_CLOSE, 0, 0, PASS, SERVER, }, + {29, CMD_OPEN, O_RDONLY, 0, PASS, SERVER, }, + {29, CMD_WRTEST, 0, 0, PASS, SERVER, }, + {29, CMD_CLOSE,0, 0, PASS, SERVER, }, + {29, CMD_OPEN, O_RDWR, 0, PASS, SERVER, }, #ifdef macosx /* Close the opened file and open the file with SHLOCK, other client will try to open with SHLOCK too */ - {30, F_CLOSE,0, 0, PASS, SERVER, }, - {30, F_OPEN, O_RDWR|O_SHLOCK|O_NONBLOCK, 0, PASS, SERVER, }, - {30, F_CLOSE,0, 0, PASS, CLIENT, }, - {30, F_OPEN, O_RDWR|O_SHLOCK|O_NONBLOCK, 0, PASS, CLIENT, }, + {30, CMD_CLOSE,0, 0, PASS, SERVER, }, + {30, CMD_OPEN, O_RDWR|O_SHLOCK|O_NONBLOCK, 0, PASS, SERVER, }, + {30, CMD_CLOSE,0, 0, PASS, CLIENT, }, + {30, CMD_OPEN, O_RDWR|O_SHLOCK|O_NONBLOCK, 0, PASS, CLIENT, }, /* Close the opened file and open the file with SHLOCK, other client will try to open with EXLOCK */ - {31, F_CLOSE,0, 0, PASS, SERVER, }, - {31, F_CLOSE,0, 0, PASS, CLIENT, }, - {31, F_OPEN, O_RDWR|O_SHLOCK|O_NONBLOCK, 0, PASS, SERVER, }, - {31, F_OPEN, O_RDWR|O_EXLOCK|O_NONBLOCK, 0, FAIL, CLIENT, }, + {31, CMD_CLOSE,0, 0, PASS, SERVER, }, + {31, CMD_CLOSE,0, 0, PASS, CLIENT, }, + {31, CMD_OPEN, O_RDWR|O_SHLOCK|O_NONBLOCK, 0, PASS, SERVER, }, + {31, CMD_OPEN, O_RDWR|O_EXLOCK|O_NONBLOCK, 0, FAIL, CLIENT, }, /* Close the opened file and open the file with EXLOCK, other client will try to open with EXLOCK too */ - {32, F_CLOSE,0, 0, PASS, SERVER, }, - {32, F_CLOSE,0, 0, FAIL, CLIENT, }, - {32, F_OPEN, O_RDWR|O_EXLOCK|O_NONBLOCK, 0, PASS, SERVER, }, - {32, F_OPEN, O_RDWR|O_EXLOCK|O_NONBLOCK, 0, FAIL, CLIENT, }, - {32, F_CLOSE,0, 0, PASS, SERVER, }, - {32, F_CLOSE,0, 0, FAIL, CLIENT, }, - {32, F_OPEN, O_RDWR, 0, PASS, SERVER, }, - {32, F_OPEN, O_RDWR, 0, PASS, CLIENT, }, + {32, CMD_CLOSE,0, 0, PASS, SERVER, }, + {32, CMD_CLOSE,0, 0, FAIL, CLIENT, }, + {32, CMD_OPEN, O_RDWR|O_EXLOCK|O_NONBLOCK, 0, PASS, SERVER, }, + {32, CMD_OPEN, O_RDWR|O_EXLOCK|O_NONBLOCK, 0, FAIL, CLIENT, }, + {32, CMD_CLOSE,0, 0, PASS, SERVER, }, + {32, CMD_CLOSE,0, 0, FAIL, CLIENT, }, + {32, CMD_OPEN, O_RDWR, 0, PASS, SERVER, }, + {32, CMD_OPEN, O_RDWR, 0, PASS, CLIENT, }, #endif /* macosx */ /* indicate end of array */ {0,0,0,0,0,SERVER}, @@ -962,25 +962,25 @@ main(int argc, char *argv[]) if(tests[index][TEST_NUM] != 0) { switch(tests[index][COMMAND]) { - case WRLOCK: + case CMD_WRLOCK: result = do_lock(F_SETLK, F_WRLCK, tests[index][OFFSET], tests[index][LENGTH]); break; - case RDLOCK: + case CMD_RDLOCK: result = do_lock(F_SETLK, F_RDLCK, tests[index][OFFSET], tests[index][LENGTH]); break; - case UNLOCK: + case CMD_UNLOCK: result = do_lock(F_SETLK, F_UNLCK, tests[index][OFFSET], tests[index][LENGTH]); break; - case F_CLOSE: + case CMD_CLOSE: result = do_close(); break; - case F_OPEN: + case CMD_OPEN: result = do_open(tests[index][FLAGS]); break; - case WRTEST: + case CMD_WRTEST: result = do_lock(F_GETLK, F_WRLCK, tests[index][OFFSET], tests[index][LENGTH]); break; - case RDTEST: + case CMD_RDTEST: result = do_lock(F_GETLK, F_RDLCK, tests[index][OFFSET], tests[index][LENGTH]); break; } @@ -989,10 +989,10 @@ main(int argc, char *argv[]) /* We have a failure */ if(debug) fprintf(stderr, "Server failure in test %d, while %sing using offset %lld, length %lld - err = %d:%s\n", - ctl.test, tests[index][COMMAND]==WRLOCK?"write lock": - tests[index][COMMAND]==RDLOCK?"read lock": - tests[index][COMMAND]==UNLOCK?"unlock": - tests[index][COMMAND]==F_OPEN?"open":"clos", + ctl.test, tests[index][COMMAND]==CMD_WRLOCK?"write lock": + tests[index][COMMAND]==CMD_RDLOCK?"read lock": + tests[index][COMMAND]==CMD_UNLOCK?"unlock": + tests[index][COMMAND]==CMD_OPEN?"open":"clos", (long long)tests[index][OFFSET], (long long)tests[index][LENGTH], saved_errno, strerror(saved_errno)); @@ -1009,10 +1009,10 @@ main(int argc, char *argv[]) } if(debug > 1) fprintf(stderr, "Sending command to client (%d) - %s - %lld:%lld\n", - index, tests[index][COMMAND]==WRLOCK?"write lock": - tests[index][COMMAND]==RDLOCK?"read lock": - tests[index][COMMAND]==UNLOCK?"unlock": - tests[index][COMMAND]==F_OPEN?"open":"clos", + index, tests[index][COMMAND]==CMD_WRLOCK?"write lock": + tests[index][COMMAND]==CMD_RDLOCK?"read lock": + tests[index][COMMAND]==CMD_UNLOCK?"unlock": + tests[index][COMMAND]==CMD_OPEN?"open":"clos", (long long)tests[index][OFFSET], (long long)tests[index][LENGTH]); /* get the client to do something */ @@ -1027,10 +1027,10 @@ main(int argc, char *argv[]) fail_flag++; if(debug) fprintf(stderr, "Client failure in test %d, while %sing using offset %lld, length %lld - err = %d:%s\n", - ctl.test, ctl.command==WRLOCK?"write lock": - ctl.command==RDLOCK?"read lock": - ctl.command==UNLOCK?"unlock": - ctl.command==F_OPEN?"open":"clos", + ctl.test, ctl.command==CMD_WRLOCK?"write lock": + ctl.command==CMD_RDLOCK?"read lock": + ctl.command==CMD_UNLOCK?"unlock": + ctl.command==CMD_OPEN?"open":"clos", (long long)ctl.offset, (long long)ctl.length, ctl.error, strerror(ctl.error)); fprintf(stderr, "Client failure in %lld:%s\n", @@ -1074,25 +1074,25 @@ main(int argc, char *argv[]) ctl.offset = tests[index][OFFSET]; ctl.length = tests[index][LENGTH]; switch(tests[index][COMMAND]) { - case WRLOCK: + case CMD_WRLOCK: result = do_lock(F_SETLK, F_WRLCK, tests[index][OFFSET], tests[index][LENGTH]); break; - case RDLOCK: + case CMD_RDLOCK: result = do_lock(F_SETLK, F_RDLCK, tests[index][OFFSET], tests[index][LENGTH]); break; - case UNLOCK: + case CMD_UNLOCK: result = do_lock(F_SETLK, F_UNLCK, tests[index][OFFSET], tests[index][LENGTH]); break; - case F_CLOSE: + case CMD_CLOSE: result = do_close(); break; - case F_OPEN: + case CMD_OPEN: result = do_open(tests[index][FLAGS]); break; - case WRTEST: + case CMD_WRTEST: result = do_lock(F_GETLK, F_WRLCK, tests[index][OFFSET], tests[index][LENGTH]); break; - case RDTEST: + case CMD_RDTEST: result = do_lock(F_GETLK, F_RDLCK, tests[index][OFFSET], tests[index][LENGTH]); break; } From patchwork Mon Sep 23 17:53:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11157445 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D41A912 for ; Mon, 23 Sep 2019 17:53:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E865D20B7C for ; Mon, 23 Sep 2019 17:53:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502229AbfIWRxm (ORCPT ); Mon, 23 Sep 2019 13:53:42 -0400 Received: from mga04.intel.com ([192.55.52.120]:33175 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502228AbfIWRxm (ORCPT ); Mon, 23 Sep 2019 13:53:42 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:42 -0700 X-IronPort-AV: E=Sophos;i="5.64,541,1559545200"; d="scan'208";a="363704369" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:41 -0700 From: ira.weiny@intel.com To: fstests@vger.kernel.org, Eryu Guan Cc: john.hubbard@gmail.com, Dave Chinner , Jan Kara , Jason Gunthorpe , dan.j.williams@intel.com, Jeff Layton , Ira Weiny Subject: [PATCH V2 04/16] src/locktest: Add get_cmd_str Date: Mon, 23 Sep 2019 10:53:24 -0700 Message-Id: <20190923175336.2287-5-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923175336.2287-1-ira.weiny@intel.com> References: <20190923175336.2287-1-ira.weiny@intel.com> MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Ira Weiny Rather than open code printing the strings, use a helper function. Reviewed-by: Jeff Layton Signed-off-by: Ira Weiny --- src/locktest.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/locktest.c b/src/locktest.c index ce04ecba6205..825d9df3ddf8 100644 --- a/src/locktest.c +++ b/src/locktest.c @@ -109,6 +109,19 @@ static HANDLE f_fd = INVALID_HANDLE; /* shared file */ #define WHO 5 #define FLAGS 2 /* index 2 is also used for do_open() flag, see below */ +static char *get_cmd_str(int cmd) +{ + switch (cmd) { + case CMD_WRLOCK: return "write lock"; break; + case CMD_RDLOCK: return "read lock"; break; + case CMD_UNLOCK: return "unlock"; break; + case CMD_CLOSE: return "close"; break; + case CMD_OPEN: return "open"; break; + case CMD_WRTEST: return "Wait for SIGIO"; break; + case CMD_RDTEST: return "Truncate"; break; + } + return "unknown"; +} /* * flags for Mac OS X do_open() * O_RDONLY 0x0000 @@ -989,10 +1002,8 @@ main(int argc, char *argv[]) /* We have a failure */ if(debug) fprintf(stderr, "Server failure in test %d, while %sing using offset %lld, length %lld - err = %d:%s\n", - ctl.test, tests[index][COMMAND]==CMD_WRLOCK?"write lock": - tests[index][COMMAND]==CMD_RDLOCK?"read lock": - tests[index][COMMAND]==CMD_UNLOCK?"unlock": - tests[index][COMMAND]==CMD_OPEN?"open":"clos", + ctl.test, + get_cmd_str(tests[index][COMMAND]), (long long)tests[index][OFFSET], (long long)tests[index][LENGTH], saved_errno, strerror(saved_errno)); @@ -1009,10 +1020,8 @@ main(int argc, char *argv[]) } if(debug > 1) fprintf(stderr, "Sending command to client (%d) - %s - %lld:%lld\n", - index, tests[index][COMMAND]==CMD_WRLOCK?"write lock": - tests[index][COMMAND]==CMD_RDLOCK?"read lock": - tests[index][COMMAND]==CMD_UNLOCK?"unlock": - tests[index][COMMAND]==CMD_OPEN?"open":"clos", + index, + get_cmd_str(ctl.command), (long long)tests[index][OFFSET], (long long)tests[index][LENGTH]); /* get the client to do something */ @@ -1027,10 +1036,7 @@ main(int argc, char *argv[]) fail_flag++; if(debug) fprintf(stderr, "Client failure in test %d, while %sing using offset %lld, length %lld - err = %d:%s\n", - ctl.test, ctl.command==CMD_WRLOCK?"write lock": - ctl.command==CMD_RDLOCK?"read lock": - ctl.command==CMD_UNLOCK?"unlock": - ctl.command==CMD_OPEN?"open":"clos", + ctl.test, get_cmd_str(ctl.command), (long long)ctl.offset, (long long)ctl.length, ctl.error, strerror(ctl.error)); fprintf(stderr, "Client failure in %lld:%s\n", From patchwork Mon Sep 23 17:53:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11157449 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF1BB14ED for ; Mon, 23 Sep 2019 17:53:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A69E020882 for ; Mon, 23 Sep 2019 17:53:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502230AbfIWRxn (ORCPT ); Mon, 23 Sep 2019 13:53:43 -0400 Received: from mga18.intel.com ([134.134.136.126]:15071 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394221AbfIWRxn (ORCPT ); Mon, 23 Sep 2019 13:53:43 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:42 -0700 X-IronPort-AV: E=Sophos;i="5.64,541,1559545200"; d="scan'208";a="339803962" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:42 -0700 From: ira.weiny@intel.com To: fstests@vger.kernel.org, Eryu Guan Cc: john.hubbard@gmail.com, Dave Chinner , Jan Kara , Jason Gunthorpe , dan.j.williams@intel.com, Jeff Layton , Ira Weiny Subject: [PATCH V2 05/16] src/locktest.c: Clean up client command passing Date: Mon, 23 Sep 2019 10:53:25 -0700 Message-Id: <20190923175336.2287-6-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923175336.2287-1-ira.weiny@intel.com> References: <20190923175336.2287-1-ira.weiny@intel.com> MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Ira Weiny The client was using the test index rather than the values being passed to it for a command. While this technically worked it is cleaner to fully initialize the command message and use the values in that message. Reviewed-by: Jeff Layton Signed-off-by: Ira Weiny --- src/locktest.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/locktest.c b/src/locktest.c index 825d9df3ddf8..3abb91120144 100644 --- a/src/locktest.c +++ b/src/locktest.c @@ -670,6 +670,17 @@ int do_close(void) return PASS; } +static void init_ctl(int32_t index) +{ + ctl.test= (int32_t)tests[index][TEST_NUM]; + ctl.command = (int32_t)tests[index][COMMAND]; + ctl.offset = tests[index][OFFSET]; + ctl.length = tests[index][LENGTH]; + ctl.index = index; + ctl.result = (int32_t)tests[index][RESULT]; + ctl.error = 0; +} + void send_ctl(void) { @@ -1018,6 +1029,8 @@ main(int argc, char *argv[]) ctl.test = 0; end=1; } + /* get the client to do something */ + init_ctl(index); if(debug > 1) fprintf(stderr, "Sending command to client (%d) - %s - %lld:%lld\n", index, @@ -1074,20 +1087,16 @@ main(int argc, char *argv[]) end = 1; break; } - - ctl.command = tests[index][COMMAND]; - ctl.offset = tests[index][OFFSET]; - ctl.length = tests[index][LENGTH]; - switch(tests[index][COMMAND]) { + switch(ctl.command) { case CMD_WRLOCK: - result = do_lock(F_SETLK, F_WRLCK, tests[index][OFFSET], tests[index][LENGTH]); + result = do_lock(F_SETLK, F_WRLCK, ctl.offset, ctl.length); break; case CMD_RDLOCK: - result = do_lock(F_SETLK, F_RDLCK, tests[index][OFFSET], tests[index][LENGTH]); + result = do_lock(F_SETLK, F_RDLCK, ctl.offset, ctl.length); break; case CMD_UNLOCK: - result = do_lock(F_SETLK, F_UNLCK, tests[index][OFFSET], tests[index][LENGTH]); + result = do_lock(F_SETLK, F_UNLCK, ctl.offset, ctl.length); break; case CMD_CLOSE: result = do_close(); @@ -1096,21 +1105,22 @@ main(int argc, char *argv[]) result = do_open(tests[index][FLAGS]); break; case CMD_WRTEST: - result = do_lock(F_GETLK, F_WRLCK, tests[index][OFFSET], tests[index][LENGTH]); + result = do_lock(F_GETLK, F_WRLCK, ctl.offset, ctl.length); break; case CMD_RDTEST: - result = do_lock(F_GETLK, F_RDLCK, tests[index][OFFSET], tests[index][LENGTH]); + result = do_lock(F_GETLK, F_RDLCK, ctl.offset, ctl.length); break; } - if( result != tests[index][RESULT] ) { + if( result != ctl.result ) { if(debug) - fprintf(stderr,"Got %d, wanted %lld\n", result, - (long long)tests[index][RESULT]); + fprintf(stderr,"Got %d, wanted %d\n", + result, ctl.result); ctl.result = FAIL; ctl.error = saved_errno; fail_count++; } else { ctl.result = PASS; + ctl.error = 0; } if(debug > 2) fprintf(stderr,"client: sending result to server (%d)\n", ctl.index); From patchwork Mon Sep 23 17:53:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11157451 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1C11912 for ; Mon, 23 Sep 2019 17:53:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BE29620882 for ; Mon, 23 Sep 2019 17:53:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502231AbfIWRxo (ORCPT ); Mon, 23 Sep 2019 13:53:44 -0400 Received: from mga05.intel.com ([192.55.52.43]:53958 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394221AbfIWRxo (ORCPT ); Mon, 23 Sep 2019 13:53:44 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:44 -0700 X-IronPort-AV: E=Sophos;i="5.64,541,1559545200"; d="scan'208";a="190749557" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:43 -0700 From: ira.weiny@intel.com To: fstests@vger.kernel.org, Eryu Guan Cc: john.hubbard@gmail.com, Dave Chinner , Jan Kara , Jason Gunthorpe , dan.j.williams@intel.com, Jeff Layton , Ira Weiny Subject: [PATCH V2 06/16] src/locktest.c: Fix return code if last test fails Date: Mon, 23 Sep 2019 10:53:26 -0700 Message-Id: <20190923175336.2287-7-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923175336.2287-1-ira.weiny@intel.com> References: <20190923175336.2287-1-ira.weiny@intel.com> MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Ira Weiny If anything but the first step of the last test fails, the exit code (fail_count) was not properly set. Fix this such that follow on patches will be able to save error output and correctly inform the script that a failure has occurred rather than just expecting random output to fail the diff check. The issue is last_test is not properly tracking which test the loop is currently on. Therefore fail_count would not be incremented correctly. Remove the special case of checking for the end of the steps array and track last_test properly. Then adjust test_count to be correct for the new code. Reviewed-by: Jeff Layton Signed-off-by: Ira Weiny --- src/locktest.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/locktest.c b/src/locktest.c index 3abb91120144..241e7c451724 100644 --- a/src/locktest.c +++ b/src/locktest.c @@ -963,7 +963,7 @@ main(int argc, char *argv[]) int end = 0; int result = 0; int last_test = 0; - int test_count = 0; + int test_count = -1; int fail_flag = 0; while(!end) { if (server) { @@ -1058,15 +1058,13 @@ main(int argc, char *argv[]) } } } - if(tests[index][TEST_NUM] != 0) { - if(last_test != tests[index][TEST_NUM]) { - test_count++; - if(fail_flag) - fail_count++; - fail_flag = 0; - } - last_test = tests[index][TEST_NUM]; + if(last_test != tests[index][TEST_NUM]) { + test_count++; + if(fail_flag) + fail_count++; + fail_flag = 0; + last_test = tests[index][TEST_NUM]; } index++; @@ -1126,9 +1124,8 @@ main(int argc, char *argv[]) fprintf(stderr,"client: sending result to server (%d)\n", ctl.index); /* Send result to the server */ send_ctl(); - if(tests[index][TEST_NUM] != 0) { - if(last_test != tests[index][TEST_NUM]) - test_count++; + if(last_test != tests[index][TEST_NUM]) { + test_count++; last_test = tests[index][TEST_NUM]; } } From patchwork Mon Sep 23 17:53:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11157453 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AECC8912 for ; Mon, 23 Sep 2019 17:53:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8C98120882 for ; Mon, 23 Sep 2019 17:53:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502232AbfIWRxp (ORCPT ); Mon, 23 Sep 2019 13:53:45 -0400 Received: from mga05.intel.com ([192.55.52.43]:53958 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394221AbfIWRxp (ORCPT ); Mon, 23 Sep 2019 13:53:45 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:44 -0700 X-IronPort-AV: E=Sophos;i="5.64,541,1559545200"; d="scan'208";a="200618254" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:44 -0700 From: ira.weiny@intel.com To: fstests@vger.kernel.org, Eryu Guan Cc: john.hubbard@gmail.com, Dave Chinner , Jan Kara , Jason Gunthorpe , dan.j.williams@intel.com, Jeff Layton , Ira Weiny Subject: [PATCH V2 07/16] generic/131: Clean up pid variables Date: Mon, 23 Sep 2019 10:53:27 -0700 Message-Id: <20190923175336.2287-8-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923175336.2287-1-ira.weiny@intel.com> References: <20190923175336.2287-1-ira.weiny@intel.com> MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Ira Weiny Change the name of the variables to reflect the client vs server. This will help in future patches. Reviewed-by: Jeff Layton Signed-off-by: Ira Weiny --- tests/generic/131 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/generic/131 b/tests/generic/131 index e8cdd48e8667..c333e676e8f9 100755 --- a/tests/generic/131 +++ b/tests/generic/131 @@ -17,8 +17,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _cleanup() { - kill $locktest_pid2 > /dev/null 2>&1 - kill $locktest_pid1 > /dev/null 2>&1 + kill $client_pid > /dev/null 2>&1 + kill $server_pid > /dev/null 2>&1 } # get standard environment, filters and checks @@ -38,7 +38,7 @@ touch $TEST_DIR/server.out # Start the server src/locktest $TESTFILE 2>&1 > $TEST_DIR/server.out & -locktest_pid1=$! +server_pid=$! timeout=30 while [ $timeout -gt 0 ]; do @@ -50,7 +50,7 @@ while [ $timeout -gt 0 ]; do fi # check the existence of server process - if ! kill -s 0 $locktest_pid1 >/dev/null 2>&1; then + if ! kill -s 0 $server_pid >/dev/null 2>&1; then echo "Server died abnormally" exit 1 fi @@ -65,7 +65,7 @@ fi # Start the client src/locktest -p $PORT -h localhost $TESTFILE 2>&1 > $TEST_DIR/client.out -locktest_pid2=$! +client_pid=$! result=$? if [ $result -eq 0 ]; then echo success! From patchwork Mon Sep 23 17:53:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11157455 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9F644912 for ; Mon, 23 Sep 2019 17:53:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 876EF21783 for ; Mon, 23 Sep 2019 17:53:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502233AbfIWRxq (ORCPT ); Mon, 23 Sep 2019 13:53:46 -0400 Received: from mga04.intel.com ([192.55.52.120]:33175 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394221AbfIWRxq (ORCPT ); Mon, 23 Sep 2019 13:53:46 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:45 -0700 X-IronPort-AV: E=Sophos;i="5.64,541,1559545200"; d="scan'208";a="272361592" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:45 -0700 From: ira.weiny@intel.com To: fstests@vger.kernel.org, Eryu Guan Cc: john.hubbard@gmail.com, Dave Chinner , Jan Kara , Jason Gunthorpe , dan.j.williams@intel.com, Jeff Layton , Ira Weiny Subject: [PATCH V2 08/16] generic/131: Save stderr for debugging Date: Mon, 23 Sep 2019 10:53:28 -0700 Message-Id: <20190923175336.2287-9-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923175336.2287-1-ira.weiny@intel.com> References: <20190923175336.2287-1-ira.weiny@intel.com> MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Ira Weiny Details of which internal step failed within a test are lost without additional debugging output. Save that output by separating stdout and stderr. This allows the server port to be written solely to stdout for consumption by the script. Then all error output can be sent to the seqres.full file in the event of a failure. Then, depend on the return code of the server _and_ the client to detect failure and save the error output for inspection. Reviewed-by: Jeff Layton Signed-off-by: Ira Weiny --- tests/generic/131 | 63 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/tests/generic/131 b/tests/generic/131 index c333e676e8f9..4d90411d4a19 100755 --- a/tests/generic/131 +++ b/tests/generic/131 @@ -14,11 +14,15 @@ here=`pwd` tmp=/tmp/$$ status=1 # failure is the default! trap "_cleanup; exit \$status" 0 1 2 3 15 +debug="-d" + +TESTFILE=$TEST_DIR/lock_file _cleanup() { kill $client_pid > /dev/null 2>&1 kill $server_pid > /dev/null 2>&1 + rm -f $TESTFILE } # get standard environment, filters and checks @@ -31,48 +35,71 @@ _supported_os Linux _require_test _require_test_fcntl_advisory_locks -TESTFILE=$TEST_DIR/lock_file +# set up log files +SERVER_LOG=$TEST_DIR/server.out +rm -f $SERVER_LOG +touch $SERVER_LOG +SERVER_PORT=$TEST_DIR/server.port +rm -f $SERVER_PORT +touch $SERVER_PORT +CLIENT_LOG=$TEST_DIR/client.out +rm -f $CLIENT_LOG +touch $CLIENT_LOG + +touch $TESTFILE + +function dump_logs_fail() +{ + fail_str=$1 -rm -f $TEST_DIR/server.out -touch $TEST_DIR/server.out + echo " ***** Client log *****" >> $seqres.full + cat $CLIENT_LOG >> $seqres.full + echo " ***** Server log *****" >> $seqres.full + cat $SERVER_LOG >> $seqres.full + echo " ***** End file details *****" >> $seqres.full + ls -la $TESTFILE >> $seqres.full + _fail $fail_str + exit 1 +} # Start the server -src/locktest $TESTFILE 2>&1 > $TEST_DIR/server.out & +src/locktest $debug $TESTFILE 2> $SERVER_LOG 1> $SERVER_PORT & server_pid=$! timeout=30 while [ $timeout -gt 0 ]; do sleep 1 - PORT=$(cat $TEST_DIR/server.out | grep "^server port: " | awk '{print $3}') + PORT=$(cat $SERVER_PORT | grep "^server port: " | awk '{print $3}') if [ -n "$PORT" ]; then break fi # check the existence of server process if ! kill -s 0 $server_pid >/dev/null 2>&1; then - echo "Server died abnormally" - exit 1 + dump_logs_fail "Server died abnormally" fi let timeout=timeout-1 done if [ -z "$PORT" ]; then - echo "Could not get server port" - exit 1 + dump_logs_fail "Could not get server port" fi # Start the client -src/locktest -p $PORT -h localhost $TESTFILE 2>&1 > $TEST_DIR/client.out + +src/locktest $debug -p $PORT -h localhost $TESTFILE 2> $CLIENT_LOG +client_result=$? client_pid=$! -result=$? -if [ $result -eq 0 ]; then - echo success! - status=0 -else - echo "Client reported failure ($result)" - cat $TEST_DIR/*.out +if [ $client_result -ne 0 ]; then + dump_logs_fail "Client reported failure ($client_result)" fi - +wait $server_pid +server_result=$? +if [ $server_result -ne 0 ]; then + dump_logs_fail "Server reported failure ($server_result)" +fi +echo success! +status=0 exit From patchwork Mon Sep 23 17:53:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11157459 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D7661800 for ; Mon, 23 Sep 2019 17:53:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0571920B7C for ; Mon, 23 Sep 2019 17:53:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502236AbfIWRxq (ORCPT ); Mon, 23 Sep 2019 13:53:46 -0400 Received: from mga09.intel.com ([134.134.136.24]:12801 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502234AbfIWRxq (ORCPT ); Mon, 23 Sep 2019 13:53:46 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:46 -0700 X-IronPort-AV: E=Sophos;i="5.64,541,1559545200"; d="scan'208";a="188210657" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:45 -0700 From: ira.weiny@intel.com To: fstests@vger.kernel.org, Eryu Guan Cc: john.hubbard@gmail.com, Dave Chinner , Jan Kara , Jason Gunthorpe , dan.j.williams@intel.com, Jeff Layton , Ira Weiny Subject: [PATCH V2 09/16] src/locktest: Clean up error output Date: Mon, 23 Sep 2019 10:53:29 -0700 Message-Id: <20190923175336.2287-10-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923175336.2287-1-ira.weiny@intel.com> References: <20190923175336.2287-1-ira.weiny@intel.com> MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Ira Weiny Add some debugging Make sure all errors go to stderr Clean up formatting and make failures stand out Report test results for the client not just the server Reviewed-by: Jeff Layton Signed-off-by: Ira Weiny --- Changes from v1: Moved earlier in the series src/locktest.c | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/locktest.c b/src/locktest.c index 241e7c451724..159d13291f79 100644 --- a/src/locktest.c +++ b/src/locktest.c @@ -827,6 +827,8 @@ main(int argc, char *argv[]) } filename=argv[optind]; + if (debug) + fprintf(stderr, "Working on file : %s\n", filename); if (do_open(O_RDWR) == FAIL) exit(1); @@ -905,10 +907,10 @@ main(int argc, char *argv[]) struct hostent *servInfo; if ((servInfo = gethostbyname(host)) == NULL) { - printf("Couldn't get hostbyname for %s", host); + fprintf(stderr, "Couldn't get hostbyname for %s", host); if (h_errno == HOST_NOT_FOUND) - printf(": host not found"); - printf("\n"); + fprintf(stderr, ": host not found"); + fprintf(stderr, "\n"); exit(1); /*NOTREACHED*/ } @@ -1011,16 +1013,14 @@ main(int argc, char *argv[]) if( result != tests[index][RESULT]) { fail_flag++; /* We have a failure */ - if(debug) - fprintf(stderr, "Server failure in test %d, while %sing using offset %lld, length %lld - err = %d:%s\n", - ctl.test, - get_cmd_str(tests[index][COMMAND]), - (long long)tests[index][OFFSET], - (long long)tests[index][LENGTH], - saved_errno, strerror(saved_errno)); - fprintf(stderr, "Server failure in %lld:%s\n", - (long long)tests[index][TEST_NUM], - descriptions[tests[index][TEST_NUM] - 1]); + fprintf(stderr, " ***** Server failure *****\n"); + fprintf(stderr, " in test %d, while %sing using offset %lld, length %lld - err = %d:%s\n", + ctl.test, get_cmd_str(tests[index][COMMAND]), + (long long)tests[index][OFFSET], + (long long)tests[index][LENGTH], + saved_errno, strerror(saved_errno)); + fprintf(stderr, " %d:%s\n", + ctl.test, descriptions[ctl.test - 1]); } } /* else send it off to the client */ @@ -1047,14 +1047,13 @@ main(int argc, char *argv[]) * not what the command returned */ if( ctl.result == FAIL ) { fail_flag++; - if(debug) - fprintf(stderr, "Client failure in test %d, while %sing using offset %lld, length %lld - err = %d:%s\n", + fprintf(stderr, " ***** Client failure *****\n"); + fprintf(stderr, " in test %d, while %sing using offset %lld, length %lld - err = %d:%s\n", ctl.test, get_cmd_str(ctl.command), (long long)ctl.offset, (long long)ctl.length, ctl.error, strerror(ctl.error)); - fprintf(stderr, "Client failure in %lld:%s\n", - (long long)tests[index][TEST_NUM], - descriptions[tests[index][TEST_NUM] - 1]); + fprintf(stderr, " %d:%s\n", + ctl.test, descriptions[ctl.test - 1]); } } } @@ -1110,9 +1109,10 @@ main(int argc, char *argv[]) break; } if( result != ctl.result ) { - if(debug) - fprintf(stderr,"Got %d, wanted %d\n", - result, ctl.result); + fprintf(stderr,"Failure in %d:%s\n", + ctl.test, descriptions[ctl.test - 1]); + fprintf(stderr," Got %d, wanted %d\n", + result, ctl.result); ctl.result = FAIL; ctl.error = saved_errno; fail_count++; @@ -1130,8 +1130,7 @@ main(int argc, char *argv[]) } } } - if(server) - printf("%d tests run, %d failed\n", test_count, fail_count); + fprintf(stderr, "%d tests run, %d failed\n", test_count, fail_count); } exit(fail_count); From patchwork Mon Sep 23 17:53:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11157457 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED5C617D4 for ; Mon, 23 Sep 2019 17:53:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D593D21850 for ; Mon, 23 Sep 2019 17:53:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502235AbfIWRxq (ORCPT ); Mon, 23 Sep 2019 13:53:46 -0400 Received: from mga05.intel.com ([192.55.52.43]:53958 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394221AbfIWRxq (ORCPT ); Mon, 23 Sep 2019 13:53:46 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:46 -0700 X-IronPort-AV: E=Sophos;i="5.64,541,1559545200"; d="scan'208";a="189128465" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:46 -0700 From: ira.weiny@intel.com To: fstests@vger.kernel.org, Eryu Guan Cc: john.hubbard@gmail.com, Dave Chinner , Jan Kara , Jason Gunthorpe , dan.j.williams@intel.com, Jeff Layton , Ira Weiny Subject: [PATCH V2 10/16] src/locktest: Audit all debug output Date: Mon, 23 Sep 2019 10:53:30 -0700 Message-Id: <20190923175336.2287-11-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923175336.2287-1-ira.weiny@intel.com> References: <20190923175336.2287-1-ira.weiny@intel.com> MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Ira Weiny Audit all the debug output to be clear on what failed so that we can remove the debug flag from the script. Specifically, remove the need for a debug flag on system call error output. This helps to indicate what happened when an individual test step fails. Reviewed-by: Jeff Layton Signed-off-by: Ira Weiny --- Changes from V1: Moved earlier in the series src/locktest.c | 19 +++++++++++-------- tests/generic/131 | 5 ++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/locktest.c b/src/locktest.c index 159d13291f79..3dc74947f100 100644 --- a/src/locktest.c +++ b/src/locktest.c @@ -647,7 +647,7 @@ static int do_lock(int cmd, int type, int start, int length) ret = fcntl(filedes, cmd, &fl); saved_errno = errno; - if(debug > 1 && ret) + if(ret) fprintf(stderr, "do_lock: ret = %d, errno = %d (%s)\n", ret, errno, strerror(errno)); return(ret==0?PASS:FAIL); @@ -665,8 +665,11 @@ int do_close(void) saved_errno = errno; - if (errno) + if (errno) { + fprintf(stderr, "%s errno = %d (%s)\n", + __FILE__, errno, strerror(errno)); return FAIL; + } return PASS; } @@ -686,7 +689,7 @@ send_ctl(void) { int nwrite; - if (debug > 1) { + if (debug) { fprintf(stderr, "send_ctl: test=%d, command=%d offset=%"LL"d, length=%"LL"d, result=%d, error=%d\n", ctl.test, ctl.command, (long long)ctl.offset, (long long)ctl.length,ctl.result, ctl.error); } @@ -741,7 +744,7 @@ void recv_ctl(void) ctl.index= bswap_uint32(ctl.index); ctl.error= bswap_uint32(ctl.error); - if (debug > 1) { + if (debug) { fprintf(stderr, "recv_ctl: test=%d, command=%d offset=%"LL"d, length=%"LL"d, result=%d, error=%d\n", ctl.test, ctl.command, (long long)ctl.offset, (long long)ctl.length, ctl.result, ctl.error); } @@ -977,7 +980,7 @@ main(int argc, char *argv[]) } /* If we have a server command, deal with it */ if(tests[index][WHO] == SERVER) { - if(debug>1) + if(debug) fprintf(stderr, "Got a server command (%d)\n", index); if(tests[index][TEST_NUM] == 0) { index++; @@ -1031,7 +1034,7 @@ main(int argc, char *argv[]) } /* get the client to do something */ init_ctl(index); - if(debug > 1) + if(debug) fprintf(stderr, "Sending command to client (%d) - %s - %lld:%lld\n", index, get_cmd_str(ctl.command), @@ -1068,7 +1071,7 @@ main(int argc, char *argv[]) index++; } else { /* CLIENT */ - if(debug > 2) + if(debug) fprintf(stderr,"client: waiting...\n"); /* wait for the server to do something */ recv_ctl(); @@ -1120,7 +1123,7 @@ main(int argc, char *argv[]) ctl.result = PASS; ctl.error = 0; } - if(debug > 2) + if(debug) fprintf(stderr,"client: sending result to server (%d)\n", ctl.index); /* Send result to the server */ send_ctl(); diff --git a/tests/generic/131 b/tests/generic/131 index 4d90411d4a19..9990f38b26a3 100755 --- a/tests/generic/131 +++ b/tests/generic/131 @@ -14,7 +14,6 @@ here=`pwd` tmp=/tmp/$$ status=1 # failure is the default! trap "_cleanup; exit \$status" 0 1 2 3 15 -debug="-d" TESTFILE=$TEST_DIR/lock_file @@ -63,7 +62,7 @@ function dump_logs_fail() } # Start the server -src/locktest $debug $TESTFILE 2> $SERVER_LOG 1> $SERVER_PORT & +src/locktest $TESTFILE 2> $SERVER_LOG 1> $SERVER_PORT & server_pid=$! timeout=30 @@ -89,7 +88,7 @@ fi # Start the client -src/locktest $debug -p $PORT -h localhost $TESTFILE 2> $CLIENT_LOG +src/locktest -p $PORT -h localhost $TESTFILE 2> $CLIENT_LOG client_result=$? client_pid=$! if [ $client_result -ne 0 ]; then From patchwork Mon Sep 23 17:53:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11157463 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9B1351850 for ; Mon, 23 Sep 2019 17:53:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 823BE20882 for ; Mon, 23 Sep 2019 17:53:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502234AbfIWRxr (ORCPT ); Mon, 23 Sep 2019 13:53:47 -0400 Received: from mga02.intel.com ([134.134.136.20]:33973 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394221AbfIWRxr (ORCPT ); Mon, 23 Sep 2019 13:53:47 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:46 -0700 X-IronPort-AV: E=Sophos;i="5.64,541,1559545200"; d="scan'208";a="389561600" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:46 -0700 From: ira.weiny@intel.com To: fstests@vger.kernel.org, Eryu Guan Cc: john.hubbard@gmail.com, Dave Chinner , Jan Kara , Jason Gunthorpe , dan.j.williams@intel.com, Jeff Layton , Ira Weiny Subject: [PATCH V2 11/16] src/locktest: Add run() function Date: Mon, 23 Sep 2019 10:53:31 -0700 Message-Id: <20190923175336.2287-12-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923175336.2287-1-ira.weiny@intel.com> References: <20190923175336.2287-1-ira.weiny@intel.com> MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Ira Weiny Separate the functionality of main() into socket set up and run(). Pass the test information to run() rather than have it be gloabal. This is in preparation for adding a separate lease test array. Signed-off-by: Ira Weiny --- Changes from V1: New patch for this series src/locktest.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/locktest.c b/src/locktest.c index 3dc74947f100..076781badaa1 100644 --- a/src/locktest.c +++ b/src/locktest.c @@ -146,7 +146,7 @@ static char *get_cmd_str(int cmd) * (or vice versa) */ -char *descriptions[] = { +char *lock_descriptions[] = { /* 1 */"Add a lock to an empty lock list", /* 2 */"Add a lock to the start and end of a list - no overlaps", /* 3 */"Add a lock to the middle of a list - no overlap", @@ -183,7 +183,7 @@ char *descriptions[] = { #endif }; -static int64_t tests[][6] = +static int64_t lock_tests[][6] = /* test # Action [offset|flags] length expected server/client */ { /* Various simple tests exercising the list */ @@ -673,7 +673,7 @@ int do_close(void) return PASS; } -static void init_ctl(int32_t index) +static void init_ctl(int64_t tests[][6], int32_t index) { ctl.test= (int32_t)tests[index][TEST_NUM]; ctl.command = (int32_t)tests[index][COMMAND]; @@ -765,6 +765,9 @@ cleanup(void) PLATFORM_CLEANUP(); } +int +run(int64_t tests[][6], char *descriptions[]); + int main(int argc, char *argv[]) { @@ -778,7 +781,7 @@ main(int argc, char *argv[]) char *p; extern char *optarg; extern int optind; - int fail_count = 0;; + int fail_count = 0; atexit(cleanup); @@ -962,7 +965,13 @@ main(int argc, char *argv[]) * * real work is in here ... */ - i = 0; + fail_count = run(lock_tests, lock_descriptions); + + exit(fail_count); + /*NOTREACHED*/ +} + +int run(int64_t tests[][6], char *descriptions[]) { int index = 0; int end = 0; @@ -970,6 +979,7 @@ main(int argc, char *argv[]) int last_test = 0; int test_count = -1; int fail_flag = 0; + int fail_count = 0; while(!end) { if (server) { if(testnumber > 0) { @@ -1033,7 +1043,7 @@ main(int argc, char *argv[]) end=1; } /* get the client to do something */ - init_ctl(index); + init_ctl(tests, index); if(debug) fprintf(stderr, "Sending command to client (%d) - %s - %lld:%lld\n", index, @@ -1134,10 +1144,6 @@ main(int argc, char *argv[]) } } fprintf(stderr, "%d tests run, %d failed\n", test_count, fail_count); -} - - exit(fail_count); - /*NOTREACHED*/ -} - + return fail_count; +} From patchwork Mon Sep 23 17:53:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11157461 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 77F0014ED for ; Mon, 23 Sep 2019 17:53:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F11321783 for ; Mon, 23 Sep 2019 17:53:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502238AbfIWRxr (ORCPT ); Mon, 23 Sep 2019 13:53:47 -0400 Received: from mga17.intel.com ([192.55.52.151]:1416 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502234AbfIWRxr (ORCPT ); Mon, 23 Sep 2019 13:53:47 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:46 -0700 X-IronPort-AV: E=Sophos;i="5.64,541,1559545200"; d="scan'208";a="388567776" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:46 -0700 From: ira.weiny@intel.com To: fstests@vger.kernel.org, Eryu Guan Cc: john.hubbard@gmail.com, Dave Chinner , Jan Kara , Jason Gunthorpe , dan.j.williams@intel.com, Jeff Layton , Ira Weiny Subject: [PATCH V2 12/16] src/locktest: Add simple lease testing Date: Mon, 23 Sep 2019 10:53:32 -0700 Message-Id: <20190923175336.2287-13-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923175336.2287-1-ira.weiny@intel.com> References: <20190923175336.2287-1-ira.weiny@intel.com> MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Ira Weiny /* 1 */"Take Read Lease", /* 2 */"Take Write Lease", /* 3 */"Fail Write Lease if file is open somewhere else", /* 4 */"Fail Read Lease if opened with write permissions", Signed-off-by: Ira Weiny --- Changes from V1: Tests are now a separate array and are run with '-L' option. src/locktest.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 3 deletions(-) diff --git a/src/locktest.c b/src/locktest.c index 076781badaa1..2147acc67ef7 100644 --- a/src/locktest.c +++ b/src/locktest.c @@ -1,11 +1,12 @@ // SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2000-2003 Silicon Graphics, Inc. + * Copyright (c) 2019 Intel Corp. * All Rights Reserved. */ /* - * Synchronized byte range lock exerciser + * Synchronized byte range lock and lease exerciser */ #include @@ -94,6 +95,8 @@ static HANDLE f_fd = INVALID_HANDLE; /* shared file */ #define CMD_OPEN 4 #define CMD_WRTEST 5 #define CMD_RDTEST 6 +#define CMD_SETLEASE 7 +#define CMD_GETLEASE 8 #define PASS 1 #define FAIL 0 @@ -108,6 +111,7 @@ static HANDLE f_fd = INVALID_HANDLE; /* shared file */ #define RESULT 4 #define WHO 5 #define FLAGS 2 /* index 2 is also used for do_open() flag, see below */ +#define ARG FLAGS /* Arguments for Lease operations */ static char *get_cmd_str(int cmd) { @@ -119,6 +123,8 @@ static char *get_cmd_str(int cmd) case CMD_OPEN: return "open"; break; case CMD_WRTEST: return "Wait for SIGIO"; break; case CMD_RDTEST: return "Truncate"; break; + case CMD_SETLEASE: return "Set Lease"; break; + case CMD_GETLEASE: return "Get Lease"; break; } return "unknown"; } @@ -544,6 +550,56 @@ static int64_t lock_tests[][6] = {32, CMD_OPEN, O_RDWR, 0, PASS, SERVER, }, {32, CMD_OPEN, O_RDWR, 0, PASS, CLIENT, }, #endif /* macosx */ + + /* indicate end of array */ + {0,0,0,0,0,SERVER}, + {0,0,0,0,0,CLIENT} + }; + + +char *lease_descriptions[] = { + /* 1 */"Take Read Lease", + /* 2 */"Take Write Lease", + /* 3 */"Fail Write Lease if file is open somewhere else", + /* 4 */"Fail Read Lease if opened with write permissions", +}; + +static int64_t lease_tests[][6] = + /* test # Action [offset|flags|arg] length expected server/client */ + { + /* Various tests to exercise leases */ + +/* SECTION 1: Simple verification of being able to take leases */ + /* Take Read Lease */ + {1, CMD_CLOSE, 0, 0, PASS, CLIENT }, + {1, CMD_OPEN, O_RDONLY, 0, PASS, CLIENT }, + {1, CMD_CLOSE, 0, 0, PASS, SERVER }, + {1, CMD_OPEN, O_RDONLY, 0, PASS, SERVER }, + {1, CMD_SETLEASE, F_RDLCK, 0, PASS, SERVER }, + {1, CMD_GETLEASE, F_RDLCK, 0, PASS, SERVER }, + {1, CMD_SETLEASE, F_UNLCK, 0, PASS, SERVER }, + {1, CMD_CLOSE, 0, 0, PASS, SERVER }, + {1, CMD_CLOSE, 0, 0, PASS, CLIENT }, + + /* Take Write Lease */ + {2, CMD_OPEN, O_RDWR, 0, PASS, SERVER }, + {2, CMD_SETLEASE, F_WRLCK, 0, PASS, SERVER }, + {2, CMD_GETLEASE, F_WRLCK, 0, PASS, SERVER }, + {2, CMD_SETLEASE, F_UNLCK, 0, PASS, SERVER }, + {2, CMD_CLOSE, 0, 0, PASS, SERVER }, + /* Fail Write Lease with other users */ + {3, CMD_OPEN, O_RDONLY, 0, PASS, CLIENT }, + {3, CMD_OPEN, O_RDWR, 0, PASS, SERVER }, + {3, CMD_SETLEASE, F_WRLCK, 0, FAIL, SERVER }, + {3, CMD_GETLEASE, F_WRLCK, 0, FAIL, SERVER }, + {3, CMD_CLOSE, 0, 0, PASS, SERVER }, + {3, CMD_CLOSE, 0, 0, PASS, CLIENT }, + /* Fail Read Lease if opened for write */ + {4, CMD_OPEN, O_RDWR, 0, PASS, SERVER }, + {4, CMD_SETLEASE, F_RDLCK, 0, FAIL, SERVER }, + {4, CMD_GETLEASE, F_RDLCK, 0, FAIL, SERVER }, + {4, CMD_CLOSE, 0, 0, PASS, SERVER }, + /* indicate end of array */ {0,0,0,0,0,SERVER}, {0,0,0,0,0,CLIENT} @@ -653,6 +709,32 @@ static int do_lock(int cmd, int type, int start, int length) return(ret==0?PASS:FAIL); } +static int do_lease(int cmd, int arg, int expected) +{ + int ret; + + if(debug > 1) + fprintf(stderr, "do_lease: cmd=%d arg=%d exp=%X\n", + cmd, arg, expected); + + if (f_fd < 0) + return f_fd; + + errno = 0; + + ret = fcntl(f_fd, cmd, arg); + saved_errno = errno; + + if (expected && (expected == ret)) + ret = 0; + + if(ret) + fprintf(stderr, "%s do_lease: ret = %d, errno = %d (%s)\n", + __FILE__, ret, errno, strerror(errno)); + + return(ret==0?PASS:FAIL); +} + int do_close(void) { if(debug > 1) { @@ -782,6 +864,7 @@ main(int argc, char *argv[]) extern char *optarg; extern int optind; int fail_count = 0; + int run_leases = 0; atexit(cleanup); @@ -794,13 +877,17 @@ main(int argc, char *argv[]) prog = p+1; } - while ((c = getopt(argc, argv, "dn:h:p:?")) != EOF) { + while ((c = getopt(argc, argv, "dLn:h:p:?")) != EOF) { switch (c) { case 'd': /* debug flag */ debug++; break; + case 'L': /* Lease testing */ + run_leases = 1; + break; + case 'h': /* (server) hostname */ server = 0; host = optarg; @@ -965,7 +1052,10 @@ main(int argc, char *argv[]) * * real work is in here ... */ - fail_count = run(lock_tests, lock_descriptions); + if (run_leases) + fail_count = run(lease_tests, lease_descriptions); + else + fail_count = run(lock_tests, lock_descriptions); exit(fail_count); /*NOTREACHED*/ @@ -1022,6 +1112,12 @@ int run(int64_t tests[][6], char *descriptions[]) case CMD_RDTEST: result = do_lock(F_GETLK, F_RDLCK, tests[index][OFFSET], tests[index][LENGTH]); break; + case CMD_SETLEASE: + result = do_lease(F_SETLEASE, tests[index][ARG], 0); + break; + case CMD_GETLEASE: + result = do_lease(F_GETLEASE, tests[index][ARG], tests[index][ARG]); + break; } if( result != tests[index][RESULT]) { fail_flag++; @@ -1120,6 +1216,13 @@ int run(int64_t tests[][6], char *descriptions[]) case CMD_RDTEST: result = do_lock(F_GETLK, F_RDLCK, ctl.offset, ctl.length); break; + /* NOTE offset carries the argument values */ + case CMD_SETLEASE: + result = do_lease(F_SETLEASE, ctl.offset, 0); + break; + case CMD_GETLEASE: + result = do_lease(F_GETLEASE, ctl.offset, ctl.offset); + break; } if( result != ctl.result ) { fprintf(stderr,"Failure in %d:%s\n", From patchwork Mon Sep 23 17:53:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11157465 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE71F912 for ; Mon, 23 Sep 2019 17:53:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C5D3021783 for ; Mon, 23 Sep 2019 17:53:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502239AbfIWRxr (ORCPT ); Mon, 23 Sep 2019 13:53:47 -0400 Received: from mga05.intel.com ([192.55.52.43]:53958 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502237AbfIWRxr (ORCPT ); Mon, 23 Sep 2019 13:53:47 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:46 -0700 X-IronPort-AV: E=Sophos;i="5.64,541,1559545200"; d="scan'208";a="213403975" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:46 -0700 From: ira.weiny@intel.com To: fstests@vger.kernel.org, Eryu Guan Cc: john.hubbard@gmail.com, Dave Chinner , Jan Kara , Jason Gunthorpe , dan.j.williams@intel.com, Jeff Layton , Ira Weiny Subject: [PATCH V2 13/16] src/locktest: Add lease testing for basic signal reception Date: Mon, 23 Sep 2019 10:53:33 -0700 Message-Id: <20190923175336.2287-14-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923175336.2287-1-ira.weiny@intel.com> References: <20190923175336.2287-1-ira.weiny@intel.com> MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Ira Weiny /* 5 */"Read lease gets SIGIO on write open", /* 6 */"Write lease gets SIGIO on read open", /* 7 */"Read lease does _not_ get SIGIO on read open", /* 8 */"Read lease gets SIGIO on write open", Signed-off-by: Ira Weiny --- Changes from V1: Tests are now a separate array and are run with '-L' option. src/locktest.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 135 insertions(+), 2 deletions(-) diff --git a/src/locktest.c b/src/locktest.c index 2147acc67ef7..9f8a892a21a0 100644 --- a/src/locktest.c +++ b/src/locktest.c @@ -27,6 +27,8 @@ #include #include #include +#include + #define HEX_2_ASC(x) ((x) > 9) ? (x)-10+'a' : (x)+'0' #define FILE_SIZE 1024 #define PLATFORM_INIT() /*no-op*/ @@ -83,6 +85,7 @@ static int server = 1; static int port = 0; static int testnumber = -1; static int saved_errno = 0; +static int got_sigio = 0; static SOCKET s_fd = -1; /* listen socket */ static SOCKET c_fd = -1; /* IPC socket */ @@ -97,6 +100,8 @@ static HANDLE f_fd = INVALID_HANDLE; /* shared file */ #define CMD_RDTEST 6 #define CMD_SETLEASE 7 #define CMD_GETLEASE 8 +#define CMD_SIGIO 9 +#define CMD_WAIT_SIGIO 10 #define PASS 1 #define FAIL 0 @@ -112,6 +117,7 @@ static HANDLE f_fd = INVALID_HANDLE; /* shared file */ #define WHO 5 #define FLAGS 2 /* index 2 is also used for do_open() flag, see below */ #define ARG FLAGS /* Arguments for Lease operations */ +#define TIME FLAGS /* Time for waiting on sigio */ static char *get_cmd_str(int cmd) { @@ -125,6 +131,8 @@ static char *get_cmd_str(int cmd) case CMD_RDTEST: return "Truncate"; break; case CMD_SETLEASE: return "Set Lease"; break; case CMD_GETLEASE: return "Get Lease"; break; + case CMD_SIGIO: return "Setup SIGIO"; break; + case CMD_WAIT_SIGIO: return "Wait for SIGIO"; break; } return "unknown"; } @@ -562,10 +570,15 @@ char *lease_descriptions[] = { /* 2 */"Take Write Lease", /* 3 */"Fail Write Lease if file is open somewhere else", /* 4 */"Fail Read Lease if opened with write permissions", + /* 5 */"Read lease gets SIGIO on write open", + /* 6 */"Write lease gets SIGIO on read open", + /* 7 */"Read lease does _not_ get SIGIO on read open", + /* 8 */"Read lease gets SIGIO on write open", }; static int64_t lease_tests[][6] = /* test # Action [offset|flags|arg] length expected server/client */ + /* [sigio_wait_time] */ { /* Various tests to exercise leases */ @@ -600,6 +613,47 @@ static int64_t lease_tests[][6] = {4, CMD_GETLEASE, F_RDLCK, 0, FAIL, SERVER }, {4, CMD_CLOSE, 0, 0, PASS, SERVER }, +/* SECTION 2: Proper SIGIO notifications */ + /* Get SIGIO when read lease is broken by write */ + {5, CMD_OPEN, O_RDONLY, 0, PASS, CLIENT }, + {5, CMD_SETLEASE, F_RDLCK, 0, PASS, CLIENT }, + {5, CMD_GETLEASE, F_RDLCK, 0, PASS, CLIENT }, + {5, CMD_SIGIO, 0, 0, PASS, CLIENT }, + {5, CMD_OPEN, O_RDWR, 0, PASS, SERVER }, + {5, CMD_WAIT_SIGIO, 5, 0, PASS, CLIENT }, + {5, CMD_CLOSE, 0, 0, PASS, SERVER }, + {5, CMD_CLOSE, 0, 0, PASS, CLIENT }, + + /* Get SIGIO when write lease is broken by read */ + {6, CMD_OPEN, O_RDWR, 0, PASS, CLIENT }, + {6, CMD_SETLEASE, F_WRLCK, 0, PASS, CLIENT }, + {6, CMD_GETLEASE, F_WRLCK, 0, PASS, CLIENT }, + {6, CMD_SIGIO, 0, 0, PASS, CLIENT }, + {6, CMD_OPEN, O_RDONLY, 0, PASS, SERVER }, + {6, CMD_WAIT_SIGIO, 5, 0, PASS, CLIENT }, + {6, CMD_CLOSE, 0, 0, PASS, SERVER }, + {6, CMD_CLOSE, 0, 0, PASS, CLIENT }, + + /* Don't get SIGIO when read lease is taken by read */ + {7, CMD_OPEN, O_RDONLY, 0, PASS, CLIENT }, + {7, CMD_SETLEASE, F_RDLCK, 0, PASS, CLIENT }, + {7, CMD_GETLEASE, F_RDLCK, 0, PASS, CLIENT }, + {7, CMD_SIGIO, 0, 0, PASS, CLIENT }, + {7, CMD_OPEN, O_RDONLY, 0, PASS, SERVER }, + {7, CMD_WAIT_SIGIO, 5, 0, FAIL, CLIENT }, + {7, CMD_CLOSE, 0, 0, PASS, SERVER }, + {7, CMD_CLOSE, 0, 0, PASS, CLIENT }, + + /* Get SIGIO when Read lease is broken by Write */ + {8, CMD_OPEN, O_RDONLY, 0, PASS, CLIENT }, + {8, CMD_SETLEASE, F_RDLCK, 0, PASS, CLIENT }, + {8, CMD_GETLEASE, F_RDLCK, 0, PASS, CLIENT }, + {8, CMD_SIGIO, 0, 0, PASS, CLIENT }, + {8, CMD_OPEN, O_RDWR, 0, PASS, SERVER }, + {8, CMD_WAIT_SIGIO, 5, 0, PASS, CLIENT }, + {8, CMD_CLOSE, 0, 0, PASS, SERVER }, + {8, CMD_CLOSE, 0, 0, PASS, CLIENT }, + /* indicate end of array */ {0,0,0,0,0,SERVER}, {0,0,0,0,0,CLIENT} @@ -663,6 +717,70 @@ initialize(HANDLE fd) } } +void release_lease(int fd) +{ + int rc; + + rc = fcntl(fd, F_SETLEASE, F_UNLCK); + if (rc != 0) + fprintf(stderr, "%s Failed to remove lease %d : %d %s\n", + __FILE__, rc, errno, strerror(errno)); +} + +void lease_break(int sig, siginfo_t *info, void *p) +{ + if (debug) + fprintf(stderr, "lease break %d %p fd %d\n", + sig, info, info->si_fd); + got_sigio = 1; + release_lease(f_fd); +} + +struct sigaction lease_break_action = { + .sa_sigaction = lease_break, + .sa_flags = SA_SIGINFO, +}; + +int do_setup_sigio(int fd) +{ + int rc; + + got_sigio = 0; + + rc = sigaction(SIGIO, &lease_break_action, NULL); + if (rc != 0) { + fprintf(stderr, "%s Set '%s' sigaction failed %d\n", + __FILE__, strsignal(SIGIO), rc); + return FAIL; + } + + if (debug) + fprintf(stderr, "Set '%s' sigaction on %d\n", + strsignal(SIGIO), fd); + + rc = fcntl(fd, F_SETSIG, SIGIO); + if (rc) + fprintf(stderr, "%s Set '%s' sigaction failed %d\n", + __FILE__, strsignal(SIGIO), rc); + + return (rc == 0 ? PASS : FAIL); +} + +int do_wait_sigio(int32_t time) +{ + if (time <= 0) + return FAIL; + + while (!got_sigio && time--) { + sleep(1); + } + + if (debug > 1 && !got_sigio) + fprintf(stderr, "%s failed to get sigio\n", + __FILE__); + + return (got_sigio ? PASS: FAIL); +} int do_open(int flag) { @@ -807,10 +925,13 @@ void recv_ctl(void) { int nread; +again: if ((nread = SOCKET_READ(c_fd, (char*)&ctl, sizeof(ctl))) != sizeof(ctl)) { - if (nread < 0) + if (nread < 0) { + if (errno == EINTR) + goto again; perror("recv_ctl: read"); - else { + } else { fprintf(stderr, "recv_ctl[%d]: read() returns %d, not %zu as expected\n", ctl.test, nread, sizeof(ctl)); fprintf(stderr, "socket might has been closed by other locktest\n"); @@ -1118,6 +1239,12 @@ int run(int64_t tests[][6], char *descriptions[]) case CMD_GETLEASE: result = do_lease(F_GETLEASE, tests[index][ARG], tests[index][ARG]); break; + case CMD_SIGIO: + result = do_setup_sigio(f_fd); + break; + case CMD_WAIT_SIGIO: + result = do_wait_sigio(tests[index][TIME]); + break; } if( result != tests[index][RESULT]) { fail_flag++; @@ -1223,6 +1350,12 @@ int run(int64_t tests[][6], char *descriptions[]) case CMD_GETLEASE: result = do_lease(F_GETLEASE, ctl.offset, ctl.offset); break; + case CMD_SIGIO: + result = do_setup_sigio(f_fd); + break; + case CMD_WAIT_SIGIO: + result = do_wait_sigio(ctl.offset); + break; } if( result != ctl.result ) { fprintf(stderr,"Failure in %d:%s\n", From patchwork Mon Sep 23 17:53:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11157467 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0A7B21800 for ; Mon, 23 Sep 2019 17:53:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E660F21783 for ; Mon, 23 Sep 2019 17:53:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502237AbfIWRxr (ORCPT ); Mon, 23 Sep 2019 13:53:47 -0400 Received: from mga01.intel.com ([192.55.52.88]:2370 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394221AbfIWRxr (ORCPT ); Mon, 23 Sep 2019 13:53:47 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:47 -0700 X-IronPort-AV: E=Sophos;i="5.64,541,1559545200"; d="scan'208";a="195438425" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 10:53:46 -0700 From: ira.weiny@intel.com To: fstests@vger.kernel.org, Eryu Guan Cc: john.hubbard@gmail.com, Dave Chinner , Jan Kara , Jason Gunthorpe , dan.j.williams@intel.com, Jeff Layton , Ira Weiny Subject: [PATCH V2 14/16] src/locktest: Add truncate lease tests Date: Mon, 23 Sep 2019 10:53:34 -0700 Message-Id: <20190923175336.2287-15-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923175336.2287-1-ira.weiny@intel.com> References: <20190923175336.2287-1-ira.weiny@intel.com> MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Ira Weiny Add verification of signal reception on truncate: /* 9 */"Write lease gets SIGIO on truncate", /* 10 */"Read lease gets SIGIO on truncate", Signed-off-by: Ira Weiny --- Changes from V1: Tests are now a separate array and are run with '-L' option. src/locktest.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/locktest.c b/src/locktest.c index 9f8a892a21a0..2e7f2a19b1af 100644 --- a/src/locktest.c +++ b/src/locktest.c @@ -102,6 +102,7 @@ static HANDLE f_fd = INVALID_HANDLE; /* shared file */ #define CMD_GETLEASE 8 #define CMD_SIGIO 9 #define CMD_WAIT_SIGIO 10 +#define CMD_TRUNCATE 11 #define PASS 1 #define FAIL 0 @@ -133,6 +134,7 @@ static char *get_cmd_str(int cmd) case CMD_GETLEASE: return "Get Lease"; break; case CMD_SIGIO: return "Setup SIGIO"; break; case CMD_WAIT_SIGIO: return "Wait for SIGIO"; break; + case CMD_TRUNCATE: return "Truncate"; break; } return "unknown"; } @@ -574,6 +576,8 @@ char *lease_descriptions[] = { /* 6 */"Write lease gets SIGIO on read open", /* 7 */"Read lease does _not_ get SIGIO on read open", /* 8 */"Read lease gets SIGIO on write open", + /* 9 */"Write lease gets SIGIO on truncate", + /* 10 */"Read lease gets SIGIO on truncate", }; static int64_t lease_tests[][6] = @@ -654,6 +658,25 @@ static int64_t lease_tests[][6] = {8, CMD_CLOSE, 0, 0, PASS, SERVER }, {8, CMD_CLOSE, 0, 0, PASS, CLIENT }, + /* Get SIGIO when Write lease is broken by Truncate */ + {9, CMD_OPEN, O_RDWR, 0, PASS, CLIENT }, + {9, CMD_SETLEASE, F_WRLCK, 0, PASS, CLIENT }, + {9, CMD_GETLEASE, F_WRLCK, 0, PASS, CLIENT }, + {9, CMD_SIGIO, 0, 0, PASS, CLIENT }, + {9, CMD_TRUNCATE, FILE_SIZE/2, 0, PASS, CLIENT }, + {9, CMD_WAIT_SIGIO, 5, 0, PASS, CLIENT }, + {9, CMD_CLOSE, 0, 0, PASS, CLIENT }, + + /* Get SIGIO when Read lease is broken by Truncate */ + {10, CMD_OPEN, O_RDONLY, 0, PASS, CLIENT }, + {10, CMD_SETLEASE, F_RDLCK, 0, PASS, CLIENT }, + {10, CMD_GETLEASE, F_RDLCK, 0, PASS, CLIENT }, + {10, CMD_SIGIO, 0, 0, PASS, CLIENT }, + {10, CMD_TRUNCATE, FILE_SIZE/2, 0, PASS, SERVER }, + {10, CMD_WAIT_SIGIO, 5, 0, PASS, CLIENT }, + {10, CMD_CLOSE, 0, 0, PASS, CLIENT }, + + /* indicate end of array */ {0,0,0,0,0,SERVER}, {0,0,0,0,0,CLIENT} @@ -717,6 +740,27 @@ initialize(HANDLE fd) } } +static int do_truncate(size_t length) +{ + int rc; + + if (debug) + fprintf(stderr, "truncating to %ld\n", length); + +again: + rc = truncate(filename, length); + if (rc && errno == EINTR) + goto again; + + saved_errno = errno; + + if (rc) + fprintf(stderr, "%s %d : %s\n", + __FILE__, errno, strerror(errno)); + + return (rc == 0 ? PASS:FAIL); +} + void release_lease(int fd) { int rc; @@ -1245,6 +1289,9 @@ int run(int64_t tests[][6], char *descriptions[]) case CMD_WAIT_SIGIO: result = do_wait_sigio(tests[index][TIME]); break; + case CMD_TRUNCATE: + result = do_truncate(tests[index][OFFSET]); + break; } if( result != tests[index][RESULT]) { fail_flag++; @@ -1356,6 +1403,9 @@ int run(int64_t tests[][6], char *descriptions[]) case CMD_WAIT_SIGIO: result = do_wait_sigio(ctl.offset); break; + case CMD_TRUNCATE: + result = do_truncate(ctl.offset); + break; } if( result != ctl.result ) { fprintf(stderr,"Failure in %d:%s\n", From patchwork Mon Sep 23 17:59:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11157469 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 18F99112B for ; Mon, 23 Sep 2019 18:00:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EABAD20882 for ; Mon, 23 Sep 2019 18:00:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440253AbfIWSAH (ORCPT ); Mon, 23 Sep 2019 14:00:07 -0400 Received: from mga14.intel.com ([192.55.52.115]:39785 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393421AbfIWSAH (ORCPT ); Mon, 23 Sep 2019 14:00:07 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 11:00:06 -0700 X-IronPort-AV: E=Sophos;i="5.64,541,1559545200"; d="scan'208";a="203175680" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 11:00:06 -0700 From: ira.weiny@intel.com To: fstests@vger.kernel.org, Eryu Guan Cc: john.hubbard@gmail.com, Dave Chinner , Jan Kara , Jason Gunthorpe , dan.j.williams@intel.com, Jeff Layton , Ira Weiny Subject: [PATCH V2 15/16] common/locktest: Add common locktest functions Date: Mon, 23 Sep 2019 10:59:58 -0700 Message-Id: <20190923175959.2802-1-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923175336.2287-1-ira.weiny@intel.com> References: <20190923175336.2287-1-ira.weiny@intel.com> MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Ira Weiny Move common test functions to common directory and call them from the lock test. This is in preparation for adding a separate lease test. Signed-off-by: Ira Weiny --- Changes from V1: New patch for this series common/locktest | 91 +++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/131 | 80 +++-------------------------------------- 2 files changed, 95 insertions(+), 76 deletions(-) create mode 100644 common/locktest diff --git a/common/locktest b/common/locktest new file mode 100644 index 000000000000..c41f5054c523 --- /dev/null +++ b/common/locktest @@ -0,0 +1,91 @@ +##/bin/bash +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2019 Intel Corp, All Rights Reserved + +SERVER_LOG=$TEST_DIR/server.out +SERVER_PORT=$TEST_DIR/server.port +CLIENT_LOG=$TEST_DIR/client.out +TESTFILE=$TEST_DIR/lock_file +client_pid="" +server_pid="" + +_cleanup() +{ + kill $client_pid > /dev/null 2>&1 + kill $server_pid > /dev/null 2>&1 + rm -f $TESTFILE +} + +_dump_logs_fail() +{ + fail_str=$1 + + echo " ***** Client log *****" >> $seqres.full + cat $CLIENT_LOG >> $seqres.full + echo " ***** Server log *****" >> $seqres.full + cat $SERVER_LOG >> $seqres.full + echo " ***** End file details *****" >> $seqres.full + ls -la $TESTFILE >> $seqres.full + _fail $fail_str + exit 1 +} + + +_run_generic() { + mode=$1 + + # set up log files + rm -f $SERVER_LOG + touch $SERVER_LOG + rm -f $SERVER_PORT + touch $SERVER_PORT + rm -f $CLIENT_LOG + touch $CLIENT_LOG + + touch $TESTFILE + + # Start the server + src/locktest $mode $TESTFILE 2> $SERVER_LOG 1> $SERVER_PORT & + server_pid=$! + + timeout=30 + while [ $timeout -gt 0 ]; do + sleep 1 + + PORT=$(cat $SERVER_PORT | grep "^server port: " | awk '{print $3}') + if [ -n "$PORT" ]; then + break + fi + + # check the existence of server process + if ! kill -s 0 $server_pid >/dev/null 2>&1; then + _dump_logs_fail "Server died abnormally" + fi + + let timeout=timeout-1 + done + + if [ -z "$PORT" ]; then + _dump_logs_fail "Could not get server port" + fi + + # Start the client + + src/locktest $mode -p $PORT -h localhost $TESTFILE 2> $CLIENT_LOG + client_result=$? + client_pid=$! + if [ $client_result -ne 0 ]; then + _dump_logs_fail "Client reported failure ($client_result)" + fi + wait $server_pid + server_result=$? + if [ $server_result -ne 0 ]; then + _dump_logs_fail "Server reported failure ($server_result)" + fi + echo success! + status=0 +} + +_run_locktest() { + _run_generic "" +} diff --git a/tests/generic/131 b/tests/generic/131 index 9990f38b26a3..f086bc9840c1 100755 --- a/tests/generic/131 +++ b/tests/generic/131 @@ -13,20 +13,13 @@ echo "QA output created by $seq" here=`pwd` tmp=/tmp/$$ status=1 # failure is the default! -trap "_cleanup; exit \$status" 0 1 2 3 15 - -TESTFILE=$TEST_DIR/lock_file - -_cleanup() -{ - kill $client_pid > /dev/null 2>&1 - kill $server_pid > /dev/null 2>&1 - rm -f $TESTFILE -} # get standard environment, filters and checks . ./common/rc . ./common/filter +. ./common/locktest + +trap "_cleanup; exit \$status" 0 1 2 3 15 # real QA test starts here _supported_fs generic @@ -34,71 +27,6 @@ _supported_os Linux _require_test _require_test_fcntl_advisory_locks -# set up log files -SERVER_LOG=$TEST_DIR/server.out -rm -f $SERVER_LOG -touch $SERVER_LOG -SERVER_PORT=$TEST_DIR/server.port -rm -f $SERVER_PORT -touch $SERVER_PORT -CLIENT_LOG=$TEST_DIR/client.out -rm -f $CLIENT_LOG -touch $CLIENT_LOG - -touch $TESTFILE - -function dump_logs_fail() -{ - fail_str=$1 - - echo " ***** Client log *****" >> $seqres.full - cat $CLIENT_LOG >> $seqres.full - echo " ***** Server log *****" >> $seqres.full - cat $SERVER_LOG >> $seqres.full - echo " ***** End file details *****" >> $seqres.full - ls -la $TESTFILE >> $seqres.full - _fail $fail_str - exit 1 -} - -# Start the server -src/locktest $TESTFILE 2> $SERVER_LOG 1> $SERVER_PORT & -server_pid=$! - -timeout=30 -while [ $timeout -gt 0 ]; do - sleep 1 - - PORT=$(cat $SERVER_PORT | grep "^server port: " | awk '{print $3}') - if [ -n "$PORT" ]; then - break - fi - - # check the existence of server process - if ! kill -s 0 $server_pid >/dev/null 2>&1; then - dump_logs_fail "Server died abnormally" - fi - - let timeout=timeout-1 -done - -if [ -z "$PORT" ]; then - dump_logs_fail "Could not get server port" -fi - -# Start the client +_run_locktest -src/locktest -p $PORT -h localhost $TESTFILE 2> $CLIENT_LOG -client_result=$? -client_pid=$! -if [ $client_result -ne 0 ]; then - dump_logs_fail "Client reported failure ($client_result)" -fi -wait $server_pid -server_result=$? -if [ $server_result -ne 0 ]; then - dump_logs_fail "Server reported failure ($server_result)" -fi -echo success! -status=0 exit From patchwork Mon Sep 23 17:59:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 11157471 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C84A2912 for ; Mon, 23 Sep 2019 18:00:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A5FC820882 for ; Mon, 23 Sep 2019 18:00:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440257AbfIWSAJ (ORCPT ); Mon, 23 Sep 2019 14:00:09 -0400 Received: from mga02.intel.com ([134.134.136.20]:34525 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393421AbfIWSAJ (ORCPT ); Mon, 23 Sep 2019 14:00:09 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 11:00:08 -0700 X-IronPort-AV: E=Sophos;i="5.64,541,1559545200"; d="scan'208";a="182622926" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.157]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 11:00:08 -0700 From: ira.weiny@intel.com To: fstests@vger.kernel.org, Eryu Guan Cc: john.hubbard@gmail.com, Dave Chinner , Jan Kara , Jason Gunthorpe , dan.j.williams@intel.com, Jeff Layton , Ira Weiny Subject: [PATCH V2 16/16] generic/568: Add lease testing Date: Mon, 23 Sep 2019 10:59:59 -0700 Message-Id: <20190923175959.2802-2-ira.weiny@intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923175959.2802-1-ira.weiny@intel.com> References: <20190923175336.2287-1-ira.weiny@intel.com> <20190923175959.2802-1-ira.weiny@intel.com> MIME-Version: 1.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Ira Weiny Create a new lease test script. Signed-off-by: Ira Weiny --- Changes from V1: New patch for this series. common/locktest | 4 ++++ tests/generic/568 | 32 ++++++++++++++++++++++++++++++++ tests/generic/568.out | 2 ++ tests/generic/group | 1 + 4 files changed, 39 insertions(+) create mode 100755 tests/generic/568 create mode 100644 tests/generic/568.out diff --git a/common/locktest b/common/locktest index c41f5054c523..1da5fbb1eb62 100644 --- a/common/locktest +++ b/common/locktest @@ -89,3 +89,7 @@ _run_generic() { _run_locktest() { _run_generic "" } + +_run_leasetest() { + _run_generic "-L" +} diff --git a/tests/generic/568 b/tests/generic/568 new file mode 100755 index 000000000000..0d52c384cbd1 --- /dev/null +++ b/tests/generic/568 @@ -0,0 +1,32 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2019 Intel, Corp. All Rights Reserved. +# +# FSQA Test No. 568 +# +# lease test +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/locktest + +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# real QA test starts here +_supported_fs generic +_supported_os Linux +_require_test +_require_test_fcntl_advisory_locks + +_run_leasetest + +exit diff --git a/tests/generic/568.out b/tests/generic/568.out new file mode 100644 index 000000000000..5efccbbc6194 --- /dev/null +++ b/tests/generic/568.out @@ -0,0 +1,2 @@ +QA output created by 568 +success! diff --git a/tests/generic/group b/tests/generic/group index 7cf4f6c48b2f..c773d6b52a99 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -570,3 +570,4 @@ 565 auto quick copy_range 566 auto quick quota metadata 567 auto quick rw punch +568 auto quick