On 06/09/2017 02:23 AM, Greg Kroah-Hartman wrote: > From: Paul Elder <paul.elder@xxxxxxxx> > > Make the membarrier test output in the TAP13 format by using the > TAP13 output functions defined in kselftest.h > > Cc: Tim Bird <Tim.Bird@xxxxxxxx> > Signed-off-by: Paul Elder <paul.elder@xxxxxxxx> > Signed-off-by: Alice Ferrazzi <alice.ferrazzi@xxxxxxxxx> > Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> > --- > .../testing/selftests/membarrier/membarrier_test.c | 45 ++++++++++++---------- > 1 file changed, 24 insertions(+), 21 deletions(-) > > diff --git a/tools/testing/selftests/membarrier/membarrier_test.c b/tools/testing/selftests/membarrier/membarrier_test.c > index 535f0fef4d0b..dad419bde3a1 100644 > --- a/tools/testing/selftests/membarrier/membarrier_test.c > +++ b/tools/testing/selftests/membarrier/membarrier_test.c > @@ -21,36 +21,42 @@ static int sys_membarrier(int cmd, int flags) > static enum test_membarrier_status test_membarrier_cmd_fail(void) > { > int cmd = -1, flags = 0; > + const char *test_name = "membarrier command fail"; Including the cmd that is being tested in the test_name will improve the message. > > if (sys_membarrier(cmd, flags) != -1) { > - printf("membarrier: Wrong command should fail but passed.\n"); > + ksft_test_result_fail(test_name); > return TEST_MEMBARRIER_FAIL; > } > + > + ksft_test_result_pass(test_name); > return TEST_MEMBARRIER_PASS; > } > > static enum test_membarrier_status test_membarrier_flags_fail(void) > { > int cmd = MEMBARRIER_CMD_QUERY, flags = 1; > + const char *test_name = "Wrong flags should fail"; Same as above. Include cmd details in the test_name > > if (sys_membarrier(cmd, flags) != -1) { > - printf("membarrier: Wrong flags should fail but passed.\n"); > + ksft_test_result_fail(test_name); > return TEST_MEMBARRIER_FAIL; > } > + > + ksft_test_result_pass(test_name); > return TEST_MEMBARRIER_PASS; > } > > static enum test_membarrier_status test_membarrier_success(void) > { > int cmd = MEMBARRIER_CMD_SHARED, flags = 0; > + const char *test_name = "execute MEMBARRIER_CMD_SHARED"; This is good. I am looking to see something similar for all the test cases as I mentioned above. thanks, -- Shuah > > if (sys_membarrier(cmd, flags) != 0) { > - printf("membarrier: Executing MEMBARRIER_CMD_SHARED failed. %s.\n", > - strerror(errno)); > + ksft_test_result_fail(test_name); > return TEST_MEMBARRIER_FAIL; > } > > - printf("membarrier: MEMBARRIER_CMD_SHARED success.\n"); > + ksft_test_result_pass(test_name); > return TEST_MEMBARRIER_PASS; > } > > @@ -74,45 +80,42 @@ static enum test_membarrier_status test_membarrier_query(void) > { > int flags = 0, ret; > > - printf("membarrier MEMBARRIER_CMD_QUERY "); > ret = sys_membarrier(MEMBARRIER_CMD_QUERY, flags); > if (ret < 0) { > - printf("failed. %s.\n", strerror(errno)); > - switch (errno) { > - case ENOSYS: > + if (errno == ENOSYS) { > /* > * It is valid to build a kernel with > * CONFIG_MEMBARRIER=n. However, this skips the tests. > */ > - return TEST_MEMBARRIER_SKIP; > - case EINVAL: > - default: > - return TEST_MEMBARRIER_FAIL; > + ksft_test_result_skip("CONFIG_MEMBARRIER is not enabled\n"); > + return ksft_exit_skip_tap(); > } > + ksft_test_result_fail("sys_membarrier() failed\n"); > + return TEST_MEMBARRIER_FAIL; > } > if (!(ret & MEMBARRIER_CMD_SHARED)) { > - printf("command MEMBARRIER_CMD_SHARED is not supported.\n"); > + ksft_test_result_fail("command MEMBARRIER_CMD_SHARED is not supported.\n"); > return TEST_MEMBARRIER_FAIL; > } > - printf("syscall available.\n"); > + ksft_test_result_pass("sys_membarrier available"); > return TEST_MEMBARRIER_PASS; > } > > int main(int argc, char **argv) > { > + ksft_print_tap_header(); > switch (test_membarrier_query()) { > case TEST_MEMBARRIER_FAIL: > - return ksft_exit_fail(); > + return ksft_exit_fail_tap(); > case TEST_MEMBARRIER_SKIP: > - return ksft_exit_skip(); > + return ksft_exit_skip_tap(); > } > switch (test_membarrier()) { > case TEST_MEMBARRIER_FAIL: > - return ksft_exit_fail(); > + return ksft_exit_fail_tap(); > case TEST_MEMBARRIER_SKIP: > - return ksft_exit_skip(); > + return ksft_exit_skip_tap(); > } > > - printf("membarrier: tests done!\n"); > - return ksft_exit_pass(); > + return ksft_exit_pass_tap(); > } > -- To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html