• Ilpo Järvinen's avatar
    selftests/resctrl: Extend signal handler coverage to unmount on receiving signal · 3aff5146
    Ilpo Järvinen authored
    Unmounting resctrl FS has been moved into the per test functions in
    resctrl_tests.c by commit caddc0fb ("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: caddc0fb ("selftests/resctrl: Move resctrl FS mount/umount to higher level")
    Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Tested-by: default avatarShaopeng Tan <tan.shaopeng@jp.fujitsu.com>
    Reviewed-by: default avatarShaopeng Tan <tan.shaopeng@jp.fujitsu.com>
    Reviewed-by: default avatarReinette Chatre <reinette.chatre@intel.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
    3aff5146
cat_test.c 4.71 KB