summaryrefslogtreecommitdiff
path: root/tools/testing
diff options
context:
space:
mode:
authorShuah Khan <shuahkh@osg.samsung.com>2017-06-29 16:54:57 -0600
committerShuah Khan <shuahkh@osg.samsung.com>2017-06-30 16:16:23 -0600
commite67f85fb96ca80e5a60ea69c536affed0affc77d (patch)
tree47e015c9c6e077e19b163357020ec181cdbf57c9 /tools/testing
parent0732d06ee563bbcdf34ec889918baa62451b580d (diff)
selftests: membarrier: use ksft_* var arg msg api
Use ksft_* var arg msg to include strerror() info. in test output. Remove redundant SKIP/FAIL/PASS logic as it is no longer needed with ksft_ api. Improve test output to be consistent and clear. Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to 'tools/testing')
-rw-r--r--tools/testing/selftests/membarrier/membarrier_test.c91
1 files changed, 41 insertions, 50 deletions
diff --git a/tools/testing/selftests/membarrier/membarrier_test.c b/tools/testing/selftests/membarrier/membarrier_test.c
index 74a712eab2e6..21399fcf1a59 100644
--- a/tools/testing/selftests/membarrier/membarrier_test.c
+++ b/tools/testing/selftests/membarrier/membarrier_test.c
@@ -7,62 +7,63 @@
#include "../kselftest.h"
-enum test_membarrier_status {
- TEST_MEMBARRIER_PASS = 0,
- TEST_MEMBARRIER_FAIL,
- TEST_MEMBARRIER_SKIP,
-};
-
static int sys_membarrier(int cmd, int flags)
{
return syscall(__NR_membarrier, cmd, flags);
}
-static enum test_membarrier_status test_membarrier_cmd_fail(void)
+static int test_membarrier_cmd_fail(void)
{
int cmd = -1, flags = 0;
- const char *test_name = "membarrier command cmd=-1. Wrong command should fail";
if (sys_membarrier(cmd, flags) != -1) {
- ksft_test_result_fail(test_name);
- return TEST_MEMBARRIER_FAIL;
+ ksft_exit_fail_msg(
+ "sys membarrier invalid command test: command = %d, flags = %d. Should fail, but passed\n",
+ cmd, flags);
}
- ksft_test_result_pass(test_name);
- return TEST_MEMBARRIER_PASS;
+ ksft_test_result_pass(
+ "sys membarrier invalid command test: command = %d, flags = %d. Failed as expected\n",
+ cmd, flags);
+ return 0;
}
-static enum test_membarrier_status test_membarrier_flags_fail(void)
+static int test_membarrier_flags_fail(void)
{
int cmd = MEMBARRIER_CMD_QUERY, flags = 1;
- const char *test_name = "MEMBARRIER_CMD_QUERY, flags=1, Wrong flags should fail";
if (sys_membarrier(cmd, flags) != -1) {
- ksft_test_result_fail(test_name);
- return TEST_MEMBARRIER_FAIL;
+ ksft_exit_fail_msg(
+ "sys membarrier MEMBARRIER_CMD_QUERY invalid flags test: flags = %d. Should fail, but passed\n",
+ flags);
}
- ksft_test_result_pass(test_name);
- return TEST_MEMBARRIER_PASS;
+ ksft_test_result_pass(
+ "sys membarrier MEMBARRIER_CMD_QUERY invalid flags test: flags = %d. Failed as expected\n",
+ flags);
+ return 0;
}
-static enum test_membarrier_status test_membarrier_success(void)
+static int test_membarrier_success(void)
{
int cmd = MEMBARRIER_CMD_SHARED, flags = 0;
- const char *test_name = "execute MEMBARRIER_CMD_SHARED";
+ const char *test_name = "sys membarrier MEMBARRIER_CMD_SHARED\n";
if (sys_membarrier(cmd, flags) != 0) {
- ksft_test_result_fail(test_name);
- return TEST_MEMBARRIER_FAIL;
+ ksft_exit_fail_msg(
+ "sys membarrier MEMBARRIER_CMD_SHARED test: flags = %d\n",
+ flags);
}
- ksft_test_result_pass(test_name);
- return TEST_MEMBARRIER_PASS;
+ ksft_test_result_pass(
+ "sys membarrier MEMBARRIER_CMD_SHARED test: flags = %d\n",
+ flags);
+ return 0;
}
-static enum test_membarrier_status test_membarrier(void)
+static int test_membarrier(void)
{
- enum test_membarrier_status status;
+ int status;
status = test_membarrier_cmd_fail();
if (status)
@@ -73,10 +74,10 @@ static enum test_membarrier_status test_membarrier(void)
status = test_membarrier_success();
if (status)
return status;
- return TEST_MEMBARRIER_PASS;
+ return 0;
}
-static enum test_membarrier_status test_membarrier_query(void)
+static int test_membarrier_query(void)
{
int flags = 0, ret;
@@ -87,34 +88,24 @@ static enum test_membarrier_status test_membarrier_query(void)
* It is valid to build a kernel with
* CONFIG_MEMBARRIER=n. However, this skips the tests.
*/
- ksft_exit_skip("CONFIG_MEMBARRIER is not enabled\n");
+ ksft_exit_skip(
+ "sys membarrier (CONFIG_MEMBARRIER) is disabled.\n");
}
- ksft_test_result_fail("sys_membarrier() failed\n");
- return TEST_MEMBARRIER_FAIL;
- }
- if (!(ret & MEMBARRIER_CMD_SHARED)) {
- ksft_test_result_fail("command MEMBARRIER_CMD_SHARED is not supported.\n");
- return TEST_MEMBARRIER_FAIL;
+ ksft_exit_fail_msg("sys_membarrier() failed\n");
}
- ksft_test_result_pass("sys_membarrier available");
- return TEST_MEMBARRIER_PASS;
+ if (!(ret & MEMBARRIER_CMD_SHARED))
+ ksft_exit_fail_msg("sys_membarrier is not supported.\n");
+
+ ksft_test_result_pass("sys_membarrier available\n");
+ return 0;
}
int main(int argc, char **argv)
{
ksft_print_header();
- switch (test_membarrier_query()) {
- case TEST_MEMBARRIER_FAIL:
- return ksft_exit_fail();
- case TEST_MEMBARRIER_SKIP:
- return ksft_exit_skip(NULL);
- }
- switch (test_membarrier()) {
- case TEST_MEMBARRIER_FAIL:
- return ksft_exit_fail();
- case TEST_MEMBARRIER_SKIP:
- return ksft_exit_skip(NULL);
- }
- return ksft_exit_pass();
+ test_membarrier_query();
+ test_membarrier();
+
+ ksft_exit_pass();
}