diff options
author | Ruediger Meier | 2014-03-28 15:48:41 +0100 |
---|---|---|
committer | Ruediger Meier | 2014-03-29 01:13:13 +0100 |
commit | 6163259cbd8a53a3af381fbf3822e6505704696e (patch) | |
tree | eefcdbb1ef162b87fd1432b51f0bc55b676a824d /tests/run.sh | |
parent | libblkid: fix partitions probing (diff) | |
download | kernel-qcow2-util-linux-6163259cbd8a53a3af381fbf3822e6505704696e.tar.gz kernel-qcow2-util-linux-6163259cbd8a53a3af381fbf3822e6505704696e.tar.xz kernel-qcow2-util-linux-6163259cbd8a53a3af381fbf3822e6505704696e.zip |
tests: getting paraller_jobs more robust
This patch fixes several issues:
1. lscpu may not exist on all systems.
2. Option -b is not always available but we can skip it because it's
the documented default for -p.
3. Some old lscpu versions print --help output to stdout in case of
error. So in case 2. it would count all the help lines as CPUs,
which could be really bad on slow single core machines.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Diffstat (limited to 'tests/run.sh')
-rwxr-xr-x | tests/run.sh | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/run.sh b/tests/run.sh index 7b1e4b7c7..6bc82de0f 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -24,6 +24,15 @@ top_srcdir= top_builddir= paraller_jobs=1 +function num_cpus() +{ + if lscpu -p &>/dev/null; then + lscpu -p | grep -cv '^#' + else + echo 1 + fi +} + while [ -n "$1" ]; do case "$1" in --force) @@ -55,7 +64,7 @@ while [ -n "$1" ]; do OPTS="$OPTS --parallel" ;; --parallel) - paraller_jobs=$(lscpu -bp | grep -cv '^#') + paraller_jobs=$(num_cpus) OPTS="$OPTS --parallel" ;; --*) |