Skip to content

Commit 43ee401

Browse files
Waiman-Longhtejun
authored andcommitted
selftest/cgroup: Fix test_cpuset_prs.sh problems reported by test robot
The test robot reported two different problems when running the test_cpuset_prs.sh test. # ./test_cpuset_prs.sh: line 106: echo: write error: Input/output error # : # Effective cpus changed to 0-1,4-7 after test 4! The write error is caused by writing to /dev/console. It looks like some systems may not have /dev/console configured or in a writeable state. Fix this by checking the existence of /dev/console before attempting to write it. After the completion of each test run, the script will check if the cpuset state is reset back to the original state. That usually takes a while to happen. The test script inserts some artificial delay to make sure that the reset has completed. The current setting is about 80ms. That may not be enough in some cases especially if the test system is slow. Double it to 160ms to minimize the chance of this type of failure. Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-lkp/[email protected] Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent ccac8e8 commit 43ee401

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

tools/testing/selftests/cgroup/test_cpuset_prs.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ CPULIST=$(cat $CGROUP2/cpuset.cpus.effective)
2828
NR_CPUS=$(lscpu | grep "^CPU(s):" | sed -e "s/.*:[[:space:]]*//")
2929
[[ $NR_CPUS -lt 8 ]] && skip_test "Test needs at least 8 cpus available!"
3030

31+
# Check to see if /dev/console exists and is writable
32+
if [[ -c /dev/console && -w /dev/console ]]
33+
then
34+
CONSOLE=/dev/console
35+
else
36+
CONSOLE=/dev/null
37+
fi
38+
3139
# Set verbose flag and delay factor
3240
PROG=$1
3341
VERBOSE=0
@@ -103,8 +111,8 @@ console_msg()
103111
{
104112
MSG=$1
105113
echo "$MSG"
106-
echo "" > /dev/console
107-
echo "$MSG" > /dev/console
114+
echo "" > $CONSOLE
115+
echo "$MSG" > $CONSOLE
108116
pause 0.01
109117
}
110118

@@ -694,9 +702,9 @@ null_isolcpus_check()
694702
[[ $VERBOSE -gt 0 ]] || return 0
695703
# Retry a few times before printing error
696704
RETRY=0
697-
while [[ $RETRY -lt 5 ]]
705+
while [[ $RETRY -lt 8 ]]
698706
do
699-
pause 0.01
707+
pause 0.02
700708
check_isolcpus "."
701709
[[ $? -eq 0 ]] && return 0
702710
((RETRY++))
@@ -726,7 +734,7 @@ run_state_test()
726734

727735
while [[ $I -lt $CNT ]]
728736
do
729-
echo "Running test $I ..." > /dev/console
737+
echo "Running test $I ..." > $CONSOLE
730738
[[ $VERBOSE -gt 1 ]] && {
731739
echo ""
732740
eval echo \${$TEST[$I]}
@@ -783,7 +791,7 @@ run_state_test()
783791
while [[ $NEWLIST != $CPULIST && $RETRY -lt 8 ]]
784792
do
785793
# Wait a bit longer & recheck a few times
786-
pause 0.01
794+
pause 0.02
787795
((RETRY++))
788796
NEWLIST=$(cat cpuset.cpus.effective)
789797
done

0 commit comments

Comments
 (0)