summaryrefslogtreecommitdiffstats
path: root/tests/util.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/util.sh')
-rw-r--r--tests/util.sh12
1 files changed, 12 insertions, 0 deletions
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
+}