selftests/resctrl: Cleanup properly when an error occurs in CAT test
authorShaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Thu, 13 Apr 2023 07:22:57 +0000 (16:22 +0900)
committerShuah Khan <skhan@linuxfoundation.org>
Thu, 13 Apr 2023 17:34:17 +0000 (11:34 -0600)
commit39e34ddc382b33c9b784805ca9d83927093eb4af
tree57a42a6c794b28842081312678f9d5d09d35cd7a
parenta080b6e74b241dbc7e13dd378d6f6fc884579196
selftests/resctrl: Cleanup properly when an error occurs in CAT test

After creating a child process with fork() in CAT test, if an error
occurs when parent process runs cat_val() or check_results(), the child
process will not be killed and also resctrlfs is not unmounted. Also if
an error occurs when child process runs cat_val() or check_results(),
the parent process will wait for the pipe message from the child process
which will never be sent by the child process and the parent process
cannot proceed to unmount resctrlfs.

Synchronize the exits between the parent and child. An error could
occur whether in parent process or child process. The parent process
always kills the child process and runs umount_resctrlfs(). The
child process always waits to be killed by the parent process.

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