Commit d74f87f3 authored by Michal Clapinski's avatar Michal Clapinski Committed by Ingo Molnar

selftests/membarrier: Test MEMBARRIER_CMD_GET_REGISTRATIONS

Keep track of previously issued registrations and compare the result
with MEMBARRIER_CMD_GET_REGISTRATIONS return value.
Signed-off-by: default avatarMichal Clapinski <mclapinski@google.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Acked-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: default avatarPaul E. McKenney <paulmck@kernel.org>
Link: https://lore.kernel.org/r/20221207164338.1535591-3-mclapinski@google.com
parent 544a4f2e
......@@ -9,11 +9,38 @@
#include "../kselftest.h"
static int registrations;
static int sys_membarrier(int cmd, int flags)
{
return syscall(__NR_membarrier, cmd, flags);
}
static int test_membarrier_get_registrations(int cmd)
{
int ret, flags = 0;
const char *test_name =
"sys membarrier MEMBARRIER_CMD_GET_REGISTRATIONS";
registrations |= cmd;
ret = sys_membarrier(MEMBARRIER_CMD_GET_REGISTRATIONS, 0);
if (ret < 0) {
ksft_exit_fail_msg(
"%s test: flags = %d, errno = %d\n",
test_name, flags, errno);
} else if (ret != registrations) {
ksft_exit_fail_msg(
"%s test: flags = %d, ret = %d, registrations = %d\n",
test_name, flags, ret, registrations);
}
ksft_test_result_pass(
"%s test: flags = %d, ret = %d, registrations = %d\n",
test_name, flags, ret, registrations);
return 0;
}
static int test_membarrier_cmd_fail(void)
{
int cmd = -1, flags = 0;
......@@ -113,6 +140,8 @@ static int test_membarrier_register_private_expedited_success(void)
ksft_test_result_pass(
"%s test: flags = %d\n",
test_name, flags);
test_membarrier_get_registrations(cmd);
return 0;
}
......@@ -170,6 +199,8 @@ static int test_membarrier_register_private_expedited_sync_core_success(void)
ksft_test_result_pass(
"%s test: flags = %d\n",
test_name, flags);
test_membarrier_get_registrations(cmd);
return 0;
}
......@@ -204,6 +235,8 @@ static int test_membarrier_register_global_expedited_success(void)
ksft_test_result_pass(
"%s test: flags = %d\n",
test_name, flags);
test_membarrier_get_registrations(cmd);
return 0;
}
......
......@@ -62,7 +62,7 @@ static int test_mt_membarrier(void)
int main(int argc, char **argv)
{
ksft_print_header();
ksft_set_plan(13);
ksft_set_plan(16);
test_membarrier_query();
......
......@@ -12,7 +12,9 @@
int main(int argc, char **argv)
{
ksft_print_header();
ksft_set_plan(13);
ksft_set_plan(18);
test_membarrier_get_registrations(/*cmd=*/0);
test_membarrier_query();
......@@ -20,5 +22,7 @@ int main(int argc, char **argv)
test_membarrier_success();
test_membarrier_get_registrations(/*cmd=*/0);
return ksft_exit_pass();
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment