aboutsummaryrefslogtreecommitdiff
path: root/tests/xargs.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/xargs.test')
-rw-r--r--tests/xargs.test15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/xargs.test b/tests/xargs.test
index afed8a17..dc3c7b32 100644
--- a/tests/xargs.test
+++ b/tests/xargs.test
@@ -61,6 +61,21 @@ testing "big input forces split" \
'for i in $(seq 1 100);do echo $X;done|{ xargs >/dev/null && echo yes;}' \
"yes\n" "" ""
+# -P max-proc
+testing "max-proc=1" "xargs -n 1 -P 1" "one\ntwo\nthree\n" "" "one\ntwo\nthree\n"
+testing "max-proc=2" "xargs -n 1 -P 2" "y\ny\ny\n" "" "y\ny\ny\n"
+testing "max-proc=3" "xargs -n 1 -P 3" "y\ny\ny\n" "" "y\ny\ny\n"
+# 3 seconds vs 2 seconds vs 1 second parallel sleep
+testing "parallel sleep" "
+ xargs_sleep() {
+ ( yes | head -3 | tr y 1 | time -p xargs -n 1 \${*} sleep ) 2>&1 |
+ sed -n 's/^real *\([0-9]*\)[.]\(.*\)/\1\2/p'
+ } &&
+ A=\`xargs_sleep\` &&
+ B=\`xargs_sleep -P 2\` &&
+ C=\`xargs_sleep -P 0\` &&
+ [ \${A} -gt \${B} -a \${B} -gt \${C} ] && echo OK || echo FAIL" "OK\n" "" ""
+
# TODO: what exactly is -x supposed to do? why does coreutils output "one"?
#testing "-x" "xargs -x -s 9 || echo expected" "one\nexpected\n" "" "one\ntwo\nthree"