diff options
| author | Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com> | 2024-02-27 08:21:42 +0100 |
|---|---|---|
| committer | Shuah Khan <skhan@linuxfoundation.org> | 2024-05-06 13:57:19 -0600 |
| commit | e6487230e952cfd4070c61141f011608841f36eb (patch) | |
| tree | 48810da77f1abda29a2a34e560476266797fb3e3 /tools/testing/selftests/resctrl/resctrl_tests.c | |
| parent | 8780bc88d4c86cdb7e9591bde9dd1110156a203b (diff) | |
| download | lwn-e6487230e952cfd4070c61141f011608841f36eb.tar.gz lwn-e6487230e952cfd4070c61141f011608841f36eb.zip | |
selftests/resctrl: Simplify cleanup in ctrl-c handler
Ctrl-c handler isn't aware of what test is currently running. Because of
that it executes all cleanups even if they aren't necessary. Since the
ctrl-c handler uses the sa_sigaction system no parameters can be passed
to it as function arguments.
Add a global variable to make ctrl-c handler aware of the currently run
test and only execute the correct cleanup callback.
Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/testing/selftests/resctrl/resctrl_tests.c')
| -rw-r--r-- | tools/testing/selftests/resctrl/resctrl_tests.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index f3dc1b9696e7..0590daec2f44 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -81,19 +81,11 @@ static void cmd_help(void) printf("\t-h: help\n"); } -void tests_cleanup(void) -{ - mbm_test_cleanup(); - mba_test_cleanup(); - cmt_test_cleanup(); - cat_test_cleanup(); -} - -static int test_prepare(void) +static int test_prepare(const struct resctrl_test *test) { int res; - res = signal_handler_register(); + res = signal_handler_register(test); if (res) { ksft_print_msg("Failed to register signal handler\n"); return res; @@ -136,7 +128,7 @@ static void run_single_test(const struct resctrl_test *test, const struct user_p ksft_print_msg("Starting %s test ...\n", test->name); - if (test_prepare()) { + if (test_prepare(test)) { ksft_exit_fail_msg("Abnormal failure when preparing for the test\n"); return; } |
