Skip to content

Commit 1e85591

Browse files
kamalesh-babulalhtejun
authored andcommitted
kselftest/cgroup: Add cleanup() to test_cpuset_prs.sh
Install a cleanup function using the trap command for signals EXIT, SIGINT, SIGQUIT and SIGABRT. The cleanup function will perform: 1. Online the CPUs that were made offline during the test. 2. Removing the cgroups created. 3. Restoring the original /sys/kernel/debug/sched/verbose value, currently it's left turned on, irrespective of the original configuration value. the test performs steps 1 and 2, on the successful runs, but not during all of the failed runs. With the cleanup(), the system will perform all three steps during failed/passed test runs. Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Acked-by: Waiman Long <longman@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 7fd4da9 commit 1e85591

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tools/testing/selftests/cgroup/test_cpuset_prs.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ skip_test() {
1616
[[ $(id -u) -eq 0 ]] || skip_test "Test must be run as root!"
1717

1818
# Set sched verbose flag, if available
19-
[[ -d /sys/kernel/debug/sched ]] && echo Y > /sys/kernel/debug/sched/verbose
19+
if [[ -d /sys/kernel/debug/sched ]]
20+
then
21+
# Used to restore the original setting during cleanup
22+
SCHED_DEBUG=$(cat /sys/kernel/debug/sched/verbose)
23+
echo Y > /sys/kernel/debug/sched/verbose
24+
fi
2025

2126
# Get wait_inotify location
2227
WAIT_INOTIFY=$(cd $(dirname $0); pwd)/wait_inotify
@@ -54,6 +59,15 @@ echo +cpuset > cgroup.subtree_control
5459
[[ -d test ]] || mkdir test
5560
cd test
5661

62+
cleanup()
63+
{
64+
online_cpus
65+
rmdir A1/A2/A3 A1/A2 A1 B1 > /dev/null 2>&1
66+
cd ..
67+
rmdir test > /dev/null 2>&1
68+
echo "$SCHED_DEBUG" > /sys/kernel/debug/sched/verbose
69+
}
70+
5771
# Pause in ms
5872
pause()
5973
{
@@ -666,6 +680,7 @@ test_inotify()
666680
fi
667681
}
668682

683+
trap cleanup 0 2 3 6
669684
run_state_test TEST_MATRIX
670685
test_isolated
671686
test_inotify

0 commit comments

Comments
 (0)