diff options
author | Rob Landley <rob@landley.net> | 2020-08-03 05:54:48 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2020-08-03 05:54:48 -0500 |
commit | 9552ab89c61726e685254639029a621fa1132f62 (patch) | |
tree | c531fcb0c29d41befeb59861c6b2e31b55b23c8e /tests | |
parent | d2ad946f2af729890e80d0e9228f23a0ca62a450 (diff) | |
download | toybox-9552ab89c61726e685254639029a621fa1132f62.tar.gz |
Mark Salyzyn implemented support for xargs -P (run parallel jobs) because he
has a build script that goes much faster with it, and added tests for it.
I reimplemented it a different way, and did SIGUSR1 and SIGUSR2 support.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/xargs.test | 15 |
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" |