From 9552ab89c61726e685254639029a621fa1132f62 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 3 Aug 2020 05:54:48 -0500 Subject: 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. --- tests/xargs.test | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/xargs.test') 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" -- cgit v1.2.3