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 <jlayton@kernel.org>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
+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;
+}
+
+ /* get the client to do something */
+ init_ctl(index);
if(debug > 1)
fprintf(stderr, "Sending command to client (%d) - %s - %lld:%lld\n",
index,
if(debug > 1)
fprintf(stderr, "Sending command to client (%d) - %s - %lld:%lld\n",
index,
- ctl.command = tests[index][COMMAND];
- ctl.offset = tests[index][OFFSET];
- ctl.length = tests[index][LENGTH];
- switch(tests[index][COMMAND]) {
- result = do_lock(F_SETLK, F_WRLCK, tests[index][OFFSET], tests[index][LENGTH]);
+ result = do_lock(F_SETLK, F_WRLCK, ctl.offset, ctl.length);
- result = do_lock(F_SETLK, F_RDLCK, tests[index][OFFSET], tests[index][LENGTH]);
+ result = do_lock(F_SETLK, F_RDLCK, ctl.offset, ctl.length);
- 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();
break;
case CMD_CLOSE:
result = do_close();
result = do_open(tests[index][FLAGS]);
break;
case CMD_WRTEST:
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);
- result = do_lock(F_GETLK, F_RDLCK, tests[index][OFFSET], tests[index][LENGTH]);
+ result = do_lock(F_GETLK, F_RDLCK, ctl.offset, ctl.length);
- if( result != tests[index][RESULT] ) {
+ if( result != ctl.result ) {
- 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.result = FAIL;
ctl.error = saved_errno;
fail_count++;
} else {
ctl.result = PASS;
}
if(debug > 2)
fprintf(stderr,"client: sending result to server (%d)\n", ctl.index);
}
if(debug > 2)
fprintf(stderr,"client: sending result to server (%d)\n", ctl.index);