Skip to content

Commit 8fe6e53

Browse files
zhijianli88Shuah Khan
authored andcommitted
selftests/cpu-hotplug: exit with failure when test occured unexpected behaviors
Previously, 'make run_tests -C cpu-hotplug' always PASS since cpu-on-off-test.sh always exits 0 even though the test got some unexpected errors like below: root@debian9:/home/lizhijian/chroot/linux/tools/testing/selftests/cpu-hotplug# make run_tests pid 878's current affinity mask: 1 pid 878's new affinity mask: 1 CPU online/offline summary: Cpus in online state: 0 Cpus in offline state: 0 Limited scope test: one hotplug cpu (leaves cpu in the original state): online to offline to online: cpu 0 ./cpu-on-off-test.sh: line 83: /sys/devices/system/cpu/cpu0/online: Permission denied offline_cpu_expect_success 0: unexpected fail ./cpu-on-off-test.sh: line 78: /sys/devices/system/cpu/cpu0/online: Permission denied online_cpu_expect_success 0: unexpected fail selftests: cpu-on-off-test.sh [PASS] after this patch, the test will exit with failure once it occurs some unexpected behaviors Signed-off-by: Li Zhijian <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent b274e75 commit 8fe6e53

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ online_cpu_expect_success()
8989

9090
if ! online_cpu $cpu; then
9191
echo $FUNCNAME $cpu: unexpected fail >&2
92+
exit 1
9293
elif ! cpu_is_online $cpu; then
9394
echo $FUNCNAME $cpu: unexpected offline >&2
95+
exit 1
9496
fi
9597
}
9698

@@ -100,8 +102,10 @@ online_cpu_expect_fail()
100102

101103
if online_cpu $cpu 2> /dev/null; then
102104
echo $FUNCNAME $cpu: unexpected success >&2
105+
exit 1
103106
elif ! cpu_is_offline $cpu; then
104107
echo $FUNCNAME $cpu: unexpected online >&2
108+
exit 1
105109
fi
106110
}
107111

@@ -111,8 +115,10 @@ offline_cpu_expect_success()
111115

112116
if ! offline_cpu $cpu; then
113117
echo $FUNCNAME $cpu: unexpected fail >&2
118+
exit 1
114119
elif ! cpu_is_offline $cpu; then
115120
echo $FUNCNAME $cpu: unexpected offline >&2
121+
exit 1
116122
fi
117123
}
118124

@@ -122,8 +128,10 @@ offline_cpu_expect_fail()
122128

123129
if offline_cpu $cpu 2> /dev/null; then
124130
echo $FUNCNAME $cpu: unexpected success >&2
131+
exit 1
125132
elif ! cpu_is_online $cpu; then
126133
echo $FUNCNAME $cpu: unexpected offline >&2
134+
exit 1
127135
fi
128136
}
129137

0 commit comments

Comments
 (0)