diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2025-05-30 11:27:22 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2025-05-30 12:09:13 -0400 |
commit | fcad266fd1d1524601cc0d0bd952a0f250946bed (patch) | |
tree | ff5f77e0d4010b2be9ff7d489dbc82e761d6265a | |
parent | 397181df7c7372bdf4897296dabe386fa4212ea8 (diff) | |
download | bfs-fcad266fd1d1524601cc0d0bd952a0f250946bed.tar.xz |
tests: Try harder to guess a good parallelism level
-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 +} |