selftests/resctrl: Commonize the signal handler register/unregister for all tests
authorShaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Thu, 13 Apr 2023 07:22:58 +0000 (16:22 +0900)
committerShuah Khan <skhan@linuxfoundation.org>
Thu, 13 Apr 2023 17:34:23 +0000 (11:34 -0600)
commit73c55fa5ab5539d38561b0d816be1315c8bf6752
tree7c21effb9720150f3512a7c9701e9b4be3e5481d
parent39e34ddc382b33c9b784805ca9d83927093eb4af
selftests/resctrl: Commonize the signal handler register/unregister for all tests

After creating a child process with fork() in CAT test, if a signal such
as SIGINT is received, the parent process will be terminated immediately,
and therefore the child process will not be killed and also resctrlfs is
not unmounted.

There is a signal handler registered in CMT/MBM/MBA tests, which kills
child process, unmount resctrlfs, cleanups result files, etc., if a
signal such as SIGINT is received.

Commonize the signal handler registered for CMT/MBM/MBA tests and
reuse it in CAT.

To reuse the signal handler to kill child process use global bm_pid
instead of local bm_pid.

Also, since the MBA/MBA/CMT/CAT are run in order, unregister the signal
handler at the end of each test so that the signal handler cannot be
inherited by other tests.

Reviewed-by: Ilpo Jarvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/resctrl/cat_test.c
tools/testing/selftests/resctrl/fill_buf.c
tools/testing/selftests/resctrl/resctrl.h
tools/testing/selftests/resctrl/resctrl_val.c