]> git.itanic.dy.fi Git - linux-stable/commit
selftests/resctrl: Extend signal handler coverage to unmount on receiving signal
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 2 Oct 2023 09:48:08 +0000 (12:48 +0300)
committerShuah Khan <skhan@linuxfoundation.org>
Fri, 13 Oct 2023 20:54:09 +0000 (14:54 -0600)
commit3aff5146445582454c35900f3c0c972987cdd595
tree97c89b390888d07c30c49dbac2df7d1b5ceffe31
parentbeb7f471847663559bd0fe60af1d70e05a1d7c6c
selftests/resctrl: Extend signal handler coverage to unmount on receiving signal

Unmounting resctrl FS has been moved into the per test functions in
resctrl_tests.c by commit caddc0fbe495 ("selftests/resctrl: Move
resctrl FS mount/umount to higher level"). In case a signal (SIGINT,
SIGTERM, or SIGHUP) is received, the running selftest is aborted by
ctrlc_handler() which then unmounts resctrl fs before exiting. The
current section between signal_handler_register() and
signal_handler_unregister(), however, does not cover the entire
duration when resctrl FS is mounted.

Move signal_handler_register() and signal_handler_unregister() calls
from per test files into resctrl_tests.c to properly unmount resctrl
fs. In order to not add signal_handler_register()/unregister() n times,
create helpers test_prepare() and test_cleanup().

Do not call ksft_exit_fail_msg() in test_prepare() but only in the per
test function to keep the control flow cleaner without adding calls to
exit() deep into the call chain.

Adjust child process kill() call in ctrlc_handler() to only be invoked
if the child was already forked.

Fixes: caddc0fbe495 ("selftests/resctrl: Move resctrl FS mount/umount to higher level")
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/resctrl/cat_test.c
tools/testing/selftests/resctrl/resctrl_tests.c
tools/testing/selftests/resctrl/resctrl_val.c