Skip to content

Commit 35b7fa4

Browse files
leitaohtejun
authored andcommitted
kselftest/cgroup: Fix gathering number of CPUs
test_cpuset_prs.sh is failing with the following error: test_cpuset_prs.sh: line 29: [[: 8 57%: syntax error in expression (error token is "57%") This is happening because `lscpu | grep "^CPU(s)"` returns two lines in some systems (such as Debian unstable): # lscpu | grep "^CPU(s)" CPU(s): 8 CPU(s) scaling MHz: 55% This is a simple fix that discard the second line. Signed-off-by: Breno Leitao <leitao@debian.org> Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 79a7f41 commit 35b7fa4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/testing/selftests/cgroup/test_cpuset_prs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ WAIT_INOTIFY=$(cd $(dirname $0); pwd)/wait_inotify
2525
CGROUP2=$(mount -t cgroup2 | head -1 | awk -e '{print $3}')
2626
[[ -n "$CGROUP2" ]] || skip_test "Cgroup v2 mount point not found!"
2727

28-
CPUS=$(lscpu | grep "^CPU(s)" | sed -e "s/.*:[[:space:]]*//")
28+
CPUS=$(lscpu | grep "^CPU(s):" | sed -e "s/.*:[[:space:]]*//")
2929
[[ $CPUS -lt 8 ]] && skip_test "Test needs at least 8 cpus available!"
3030

3131
# Set verbose flag and delay factor

0 commit comments

Comments
 (0)