torture: Correctly fetch number of CPUs for non-English languages
authorFrederic Weisbecker <frederic@kernel.org>
Thu, 1 Apr 2021 13:26:02 +0000 (15:26 +0200)
committerPaul E. McKenney <paulmck@kernel.org>
Mon, 10 May 2021 23:05:06 +0000 (16:05 -0700)
Grepping for "CPU" on lscpu output isn't always successful, depending
on the local language setting.  As a result, the build can be aborted
early with:

"make: the '-j' option requires a positive integer argument"

This commit therefore uses the human-language-independent approach
available via the getconf command, both in kvm-build.sh and in
kvm-remote.sh.

Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
tools/testing/selftests/rcutorture/bin/kvm-build.sh
tools/testing/selftests/rcutorture/bin/kvm-remote.sh

index 55f4fc1..5ad973d 100755 (executable)
@@ -42,7 +42,7 @@ then
 fi
 
 # Tell "make" to use double the number of real CPUs on the build system.
-ncpus="`lscpu | grep '^CPU(' | awk '{ print $2 }'`"
+ncpus="`getconf _NPROCESSORS_ONLN`"
 make -j$((2 * ncpus)) $TORTURE_KMAKE_ARG > $resdir/Make.out 2>&1
 retval=$?
 if test $retval -ne 0 || grep "rcu[^/]*": < $resdir/Make.out | egrep -q "Stop|Error|error:|warning:" || egrep -q "Stop|Error|error:" < $resdir/Make.out
index c4859fc..f08d415 100755 (executable)
@@ -136,7 +136,7 @@ chmod +x $T/bin/kvm-remote-*.sh
 # Check first to avoid the need for cleanup for system-name typos
 for i in $systems
 do
-       ncpus="`ssh $i lscpu | grep '^CPU(' | awk '{ print $2 }'`"
+       ncpus="`ssh $i getconf _NPROCESSORS_ONLN 2> /dev/null`"
        echo $i: $ncpus CPUs " " `date` | tee -a "$oldrun/remote-log"
        ret=$?
        if test "$ret" -ne 0