summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKerin Millar <kfm@plushkava.net>2024-06-07 14:00:01 +0100
committerKerin Millar <kfm@plushkava.net>2024-06-12 08:06:42 +0100
commitfa942450e3b289057881a60fd98a9d4b35d99604 (patch)
tree8d762a68b7b66227d92da3477d69f178b8103cb4 /test-functions
parentAdd the whenceforth() function as a type -P alternative (diff)
downloadgentoo-functions-fa942450e3b289057881a60fd98a9d4b35d99604.tar.gz
gentoo-functions-fa942450e3b289057881a60fd98a9d4b35d99604.tar.bz2
gentoo-functions-fa942450e3b289057881a60fd98a9d4b35d99604.zip
Add the get_nprocs() function
It stands a good chance of printing a useful value, even in the case that nproc(1) from coreutils is unavailable. Signed-off-by: Kerin Millar <kfm@plushkava.net>
Diffstat (limited to 'test-functions')
-rwxr-xr-xtest-functions12
1 files changed, 12 insertions, 0 deletions
diff --git a/test-functions b/test-functions
index 813d524..c734141 100755
--- a/test-functions
+++ b/test-functions
@@ -544,6 +544,17 @@ test_whenceforth() {
iterate_tests 4 "$@"
}
+test_get_nprocs() {
+ set -- eq 0
+
+ callback() {
+ shift
+ test_description="get_nprocs"
+ nproc=$(get_nprocs) && is_int "${nproc}" && test "${nproc}" -gt 0
+ }
+
+ iterate_tests 2 "$@"
+}
iterate_tests() {
slice_width=$1
@@ -610,6 +621,7 @@ test_newest || rc=1
test_trim || rc=1
test_hr || rc=1
test_whenceforth || rc=1
+test_get_nprocs || rc=1
cleanup_tmpdir