diff options
Diffstat (limited to 'tests/util.sh')
-rw-r--r-- | tests/util.sh | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/util.sh b/tests/util.sh index 76b72b9..1718a1a 100644 --- a/tests/util.sh +++ b/tests/util.sh @@ -16,6 +16,7 @@ ROOT=$(_realpath "$(dirname -- "$TESTS")") TESTS="$ROOT/tests" BIN="$ROOT/bin" MKSOCK="$BIN/tests/mksock" +PTYX="$BIN/tests/ptyx" XTOUCH="$BIN/tests/xtouch" UNAME=$(uname) @@ -70,7 +71,7 @@ stdenv() { fi } -# Drop root priviliges or bail +# Drop root privileges or bail drop_root() { if command -v capsh &>/dev/null; then if capsh --has-p=cap_dac_override &>/dev/null || capsh --has-p=cap_dac_read_search &>/dev/null; then @@ -189,3 +190,28 @@ pop_defers() { return $ret } + +## Parallelism + +# Get the number of processors +_nproc() { + { + nproc \ + || sysctl -n hw.ncpu \ + || getconf _NPROCESSORS_ONLN \ + || echo 1 + } 2>/dev/null +} + +# Run wait, looping if interrupted +_wait() { + local ret=130 + + # "If wait is interrupted by a signal, the return status will be greater than 128" + while ((ret > 128)); do + ret=0 + wait "$@" || ret=$? + done + + return $ret +} |