From: Ira Weiny Date: Mon, 23 Sep 2019 17:53:25 +0000 (-0700) Subject: src/locktest.c: Clean up client command passing X-Git-Tag: v2022.05.01~1025 X-Git-Url: http://git.apps.os.sepia.ceph.com/?p=xfstests-dev.git;a=commitdiff_plain;h=214cc10503cd2e5e6b9410add61362a6b0d74d40 src/locktest.c: Clean up client command passing 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 Signed-off-by: Eryu Guan --- diff --git a/src/locktest.c b/src/locktest.c index 337da665..e2f9c8e3 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);