diff options
-rw-r--r-- | tests/getopts.sh | 6 | ||||
-rw-r--r-- | tests/util.sh | 12 |
2 files changed, 13 insertions, 5 deletions
diff --git a/tests/getopts.sh b/tests/getopts.sh index 255f2fa..cbb3ce4 100644 --- a/tests/getopts.sh +++ b/tests/getopts.sh @@ -5,11 +5,7 @@ ## Argument parsing -if command -v nproc &>/dev/null; then - JOBS=$(nproc) -else - JOBS=1 -fi +JOBS=$(nproc) MAKE= PATTERNS=() SUDO=() diff --git a/tests/util.sh b/tests/util.sh index b846d45..4bdb86f 100644 --- a/tests/util.sh +++ b/tests/util.sh @@ -190,3 +190,15 @@ pop_defers() { return $ret } + +## Parallelism + +# Get the number of processors +nproc() { + { + (command nproc) \ + || sysctl -n hw.ncpu \ + || getconf _NPROCESSORS_ONLN \ + || echo 1 + } 2>/dev/null +} |