2010-02-03 23:54:06 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Test xargs compatibility
|
|
|
|
|
2010-06-22 13:24:55 +00:00
|
|
|
echo '### Test -p --interactive'
|
|
|
|
cat >/tmp/parallel-script-for-expect <<_EOF
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
seq 1 3 | parallel -k -p echo opt-p
|
|
|
|
seq 1 3 | parallel -k --interactive echo opt--interactive
|
|
|
|
_EOF
|
|
|
|
chmod 755 /tmp/parallel-script-for-expect
|
|
|
|
|
|
|
|
expect -b - <<_EOF
|
|
|
|
spawn /tmp/parallel-script-for-expect
|
|
|
|
expect "echo opt-p 1"
|
|
|
|
send "y\n"
|
|
|
|
expect "echo opt-p 2"
|
|
|
|
send "n\n"
|
|
|
|
expect "echo opt-p 3"
|
|
|
|
send "y\n"
|
|
|
|
expect "opt-p 1"
|
|
|
|
expect "opt-p 3"
|
|
|
|
expect "echo opt--interactive 1"
|
|
|
|
send "y\n"
|
|
|
|
expect "echo opt--interactive 2"
|
|
|
|
send "n\n"
|
2011-01-11 12:42:14 +00:00
|
|
|
expect "opt--interactive 1"
|
2010-06-22 13:24:55 +00:00
|
|
|
expect "echo opt--interactive 3"
|
|
|
|
send "y\n"
|
|
|
|
expect "opt--interactive 3"
|
|
|
|
_EOF
|
|
|
|
|
2010-06-12 23:24:25 +00:00
|
|
|
echo '### Test -L -l and --max-lines'
|
|
|
|
(echo a_b;echo c) | parallel -km -L2 echo
|
2010-06-25 23:56:14 +00:00
|
|
|
(echo a_b;echo c) | parallel -k -L2 echo
|
2010-06-12 23:24:25 +00:00
|
|
|
(echo a_b;echo c) | xargs -L2 echo
|
|
|
|
(echo a_b;echo c) | parallel -km -L1 echo
|
2010-06-25 23:56:14 +00:00
|
|
|
(echo a_b;echo c) | parallel -k -L1 echo
|
2010-06-12 23:24:25 +00:00
|
|
|
(echo a_b;echo c) | xargs -L1 echo
|
|
|
|
(echo a_b' ';echo c;echo d) | parallel -km -L1 echo
|
2010-06-25 23:56:14 +00:00
|
|
|
(echo a_b' ';echo c;echo d) | parallel -k -L1 echo
|
2010-06-12 23:24:25 +00:00
|
|
|
(echo a_b' ';echo c;echo d) | xargs -L1 echo
|
|
|
|
(echo a_b' ';echo c;echo d;echo e) | parallel -km -L2 echo
|
2010-06-25 23:56:14 +00:00
|
|
|
(echo a_b' ';echo c;echo d;echo e) | parallel -k -L2 echo
|
2010-06-12 23:24:25 +00:00
|
|
|
(echo a_b' ';echo c;echo d;echo e) | xargs -L2 echo
|
|
|
|
(echo a_b' ';echo c;echo d;echo e) | parallel -km -l echo
|
2010-06-25 23:56:14 +00:00
|
|
|
(echo a_b' ';echo c;echo d;echo e) | parallel -k -l echo
|
2010-06-12 23:24:25 +00:00
|
|
|
(echo a_b' ';echo c;echo d;echo e) | xargs -l echo
|
|
|
|
(echo a_b' ';echo c;echo d;echo e) | parallel -km -l2 echo
|
2010-06-25 23:56:14 +00:00
|
|
|
(echo a_b' ';echo c;echo d;echo e) | parallel -k -l2 echo
|
2010-06-12 23:24:25 +00:00
|
|
|
(echo a_b' ';echo c;echo d;echo e) | xargs -l2 echo
|
|
|
|
(echo a_b' ';echo c;echo d;echo e) | parallel -km -l1 echo
|
2010-06-25 23:56:14 +00:00
|
|
|
(echo a_b' ';echo c;echo d;echo e) | parallel -k -l1 echo
|
2010-06-12 23:24:25 +00:00
|
|
|
(echo a_b' ';echo c;echo d;echo e) | xargs -l1 echo
|
|
|
|
(echo a_b' ';echo c;echo d;echo e) | parallel -km --max-lines 2 echo
|
2010-06-25 23:56:14 +00:00
|
|
|
(echo a_b' ';echo c;echo d;echo e) | parallel -k --max-lines 2 echo
|
2010-06-12 23:24:25 +00:00
|
|
|
(echo a_b' ';echo c;echo d;echo e) | xargs --max-lines=2 echo
|
|
|
|
(echo a_b' ';echo c;echo d;echo e) | parallel -km --max-lines echo
|
2010-06-25 23:56:14 +00:00
|
|
|
(echo a_b' ';echo c;echo d;echo e) | parallel -k --max-lines echo
|
2010-06-12 23:24:25 +00:00
|
|
|
(echo a_b' ';echo c;echo d;echo e) | xargs --max-lines echo
|
|
|
|
|
|
|
|
echo '### test too long args'
|
|
|
|
perl -e 'print "z"x1000000' | parallel echo 2>&1
|
|
|
|
perl -e 'print "z"x1000000' | xargs echo 2>&1
|
|
|
|
(seq 1 10; perl -e 'print "z"x1000000'; seq 12 15) | stdout parallel -j1 -km -s 10 echo
|
|
|
|
(seq 1 10; perl -e 'print "z"x1000000'; seq 12 15) | stdout xargs -s 10 echo
|
2010-11-22 09:35:53 +00:00
|
|
|
(seq 1 10; perl -e 'print "z"x1000000'; seq 12 15) | stdout parallel -j1 -kX -s 10 echo
|
2010-06-12 23:24:25 +00:00
|
|
|
echo '### Test -x'
|
|
|
|
(seq 1 10; echo 12345; seq 12 15) | stdout parallel -j1 -km -s 10 -x echo
|
2010-11-22 09:35:53 +00:00
|
|
|
(seq 1 10; echo 12345; seq 12 15) | stdout parallel -j1 -kX -s 10 -x echo
|
2010-06-12 23:24:25 +00:00
|
|
|
(seq 1 10; echo 12345; seq 12 15) | stdout xargs -s 10 -x echo
|
|
|
|
(seq 1 10; echo 1234; seq 12 15) | stdout parallel -j1 -km -s 10 -x echo
|
2010-11-22 09:35:53 +00:00
|
|
|
(seq 1 10; echo 1234; seq 12 15) | stdout parallel -j1 -kX -s 10 -x echo
|
2010-06-12 23:24:25 +00:00
|
|
|
(seq 1 10; echo 1234; seq 12 15) | stdout xargs -s 10 -x echo
|
2010-11-22 09:35:53 +00:00
|
|
|
#echo '### Test bugfix if no command given'
|
|
|
|
#(echo echo; seq 1 5; perl -e 'print "z"x1000000'; seq 12 15) | stdout parallel -j1 -km -s 10
|
2010-06-12 23:24:25 +00:00
|
|
|
|
|
|
|
echo '### Test -a and --arg-file: Read input from file instead of stdin'
|
2010-02-03 23:54:06 +00:00
|
|
|
seq 1 10 >/tmp/$$
|
2010-06-25 23:56:14 +00:00
|
|
|
parallel -k -a /tmp/$$ echo
|
|
|
|
parallel -k --arg-file /tmp/$$ echo
|
2010-02-03 23:54:06 +00:00
|
|
|
|
2010-04-21 19:28:00 +00:00
|
|
|
cd input-files/test15
|
|
|
|
|
2010-06-12 23:24:25 +00:00
|
|
|
echo 'xargs Expect: 3 1 2'
|
|
|
|
echo 3 | xargs -P 1 -n 1 -a files cat -
|
2010-09-05 10:22:08 +00:00
|
|
|
echo 'parallel Expect: 3 1 via psedotty 2'
|
|
|
|
cat >/tmp/parallel-script-for-script <<EOF
|
|
|
|
#!/bin/bash
|
2010-12-21 17:08:16 +00:00
|
|
|
echo 3 | parallel -T -k -P 1 -n 1 -a files cat -
|
2010-09-05 10:22:08 +00:00
|
|
|
EOF
|
|
|
|
chmod 755 /tmp/parallel-script-for-script
|
|
|
|
echo via pseudotty | script -q -f -c /tmp/parallel-script-for-script /dev/null
|
|
|
|
sleep 1
|
|
|
|
|
2010-06-12 23:24:25 +00:00
|
|
|
echo 'xargs Expect: 1 3 2'
|
|
|
|
echo 3 | xargs -I {} -P 1 -n 1 -a files cat {} -
|
2010-09-05 10:22:08 +00:00
|
|
|
echo 'parallel Expect: 1 3 2 via pseudotty'
|
|
|
|
cat >/tmp/parallel-script-for-script2 <<EOF
|
|
|
|
#!/bin/bash
|
2010-12-21 17:08:16 +00:00
|
|
|
echo 3 | parallel -T -k -I {} -P 1 -n 1 -a files cat {} -
|
2010-09-05 10:22:08 +00:00
|
|
|
EOF
|
|
|
|
chmod 755 /tmp/parallel-script-for-script2
|
|
|
|
echo via pseudotty | script -q -f -c /tmp/parallel-script-for-script2 /dev/null
|
|
|
|
sleep 1
|
2010-06-12 23:24:25 +00:00
|
|
|
|
|
|
|
echo '### Test -i and --replace: Replace with argument'
|
2010-06-25 23:56:14 +00:00
|
|
|
(echo a; echo END; echo b) | parallel -k -i -eEND echo repl{}ce
|
|
|
|
(echo a; echo END; echo b) | parallel -k --replace -eEND echo repl{}ce
|
|
|
|
(echo a; echo END; echo b) | parallel -k -i+ -eEND echo repl+ce
|
|
|
|
(echo e; echo END; echo b) | parallel -k -i'*' -eEND echo r'*'plac'*'
|
|
|
|
(echo a; echo END; echo b) | parallel -k --replace + -eEND echo repl+ce
|
|
|
|
(echo a; echo END; echo b) | parallel -k --replace== -eEND echo repl=ce
|
|
|
|
(echo a; echo END; echo b) | parallel -k --replace = -eEND echo repl=ce
|
|
|
|
(echo a; echo END; echo b) | parallel -k --replace=^ -eEND echo repl^ce
|
|
|
|
(echo a; echo END; echo b) | parallel -k -I^ -eEND echo repl^ce
|
2010-02-03 23:54:06 +00:00
|
|
|
|
2010-06-12 23:24:25 +00:00
|
|
|
echo '### Test -E: Artificial end-of-file'
|
2010-06-25 23:56:14 +00:00
|
|
|
(echo include this; echo END; echo not this) | parallel -k -E END echo
|
|
|
|
(echo include this; echo END; echo not this) | parallel -k -EEND echo
|
2010-02-03 23:54:06 +00:00
|
|
|
|
2010-06-12 23:24:25 +00:00
|
|
|
echo '### Test -e and --eof: Artificial end-of-file'
|
2010-06-25 23:56:14 +00:00
|
|
|
(echo include this; echo END; echo not this) | parallel -k -e END echo
|
|
|
|
(echo include this; echo END; echo not this) | parallel -k -eEND echo
|
|
|
|
(echo include this; echo END; echo not this) | parallel -k --eof=END echo
|
|
|
|
(echo include this; echo END; echo not this) | parallel -k --eof END echo
|
2010-02-03 23:54:06 +00:00
|
|
|
|
2010-06-12 23:24:25 +00:00
|
|
|
echo '### Test -n and --max-args: Max number of args per line (only with -X and -m)'
|
2010-06-25 23:56:14 +00:00
|
|
|
(echo line 1;echo line 2;echo line 3) | parallel -k -n1 -m echo
|
|
|
|
(echo line 1;echo line 1;echo line 2) | parallel -k -n2 -m echo
|
|
|
|
(echo line 1;echo line 2;echo line 3) | parallel -k -n1 -X echo
|
|
|
|
(echo line 1;echo line 1;echo line 2) | parallel -k -n2 -X echo
|
|
|
|
(echo line 1;echo line 2;echo line 3) | parallel -k -n1 echo
|
|
|
|
(echo line 1;echo line 1;echo line 2) | parallel -k -n2 echo
|
|
|
|
(echo line 1;echo line 2;echo line 3) | parallel -k --max-args=1 -X echo
|
|
|
|
(echo line 1;echo line 2;echo line 3) | parallel -k --max-args 1 -X echo
|
|
|
|
(echo line 1;echo line 1;echo line 2) | parallel -k --max-args=2 -X echo
|
|
|
|
(echo line 1;echo line 1;echo line 2) | parallel -k --max-args 2 -X echo
|
|
|
|
(echo line 1;echo line 2;echo line 3) | parallel -k --max-args 1 echo
|
|
|
|
(echo line 1;echo line 1;echo line 2) | parallel -k --max-args 2 echo
|
2010-02-03 23:54:06 +00:00
|
|
|
|
2010-06-12 23:24:25 +00:00
|
|
|
echo '### Test --max-procs and -P: Number of processes'
|
2010-06-25 23:56:14 +00:00
|
|
|
seq 1 10 | parallel -k --max-procs +0 echo max proc
|
|
|
|
seq 1 10 | parallel -k -P 200% echo 200% proc
|
2010-02-03 23:54:06 +00:00
|
|
|
|
2010-06-12 23:24:25 +00:00
|
|
|
echo '### Test --delimiter and -d: Delimiter instead of newline'
|
|
|
|
echo '# Yes there is supposed to be an extra newline for -d N'
|
2010-06-25 23:56:14 +00:00
|
|
|
echo line 1Nline 2Nline 3 | parallel -k -d N echo This is
|
|
|
|
echo line 1Nline 2Nline 3 | parallel -k --delimiter N echo This is
|
|
|
|
printf "delimiter NUL line 1\0line 2\0line 3" | parallel -k -d '\0' echo
|
|
|
|
printf "delimiter TAB line 1\tline 2\tline 3" | parallel -k --delimiter '\t' echo
|
2010-02-03 23:54:06 +00:00
|
|
|
|
2010-11-13 13:57:39 +00:00
|
|
|
echo '### Hans found a bug giving unitialized variable'
|
|
|
|
echo >/tmp/parallel_f1
|
|
|
|
echo >/tmp/parallel_f2'
|
|
|
|
'
|
|
|
|
echo /tmp/parallel_f1 /tmp/parallel_f2 | stdout parallel -kv --delimiter ' ' gzip
|
|
|
|
rm /tmp/parallel_f*
|
|
|
|
|
2010-06-12 23:24:25 +00:00
|
|
|
echo '### Test --max-chars and -s: Max number of chars in a line'
|
2010-06-25 23:56:14 +00:00
|
|
|
(echo line 1;echo line 1;echo line 2) | parallel -k --max-chars 25 -X echo
|
|
|
|
(echo line 1;echo line 1;echo line 2) | parallel -k -s 25 -X echo
|
2010-02-03 23:54:06 +00:00
|
|
|
|
2010-06-12 23:24:25 +00:00
|
|
|
echo '### Test --no-run-if-empty and -r: This should give no output'
|
2010-06-25 23:56:14 +00:00
|
|
|
echo " " | parallel -r echo
|
|
|
|
echo " " | parallel --no-run-if-empty echo
|
2010-02-03 23:54:06 +00:00
|
|
|
|
2010-06-12 23:24:25 +00:00
|
|
|
echo '### Test --help and -h: Help output (just check we get the same amount of lines)'
|
2010-04-18 14:18:31 +00:00
|
|
|
echo Output from -h and --help
|
2010-06-25 23:56:14 +00:00
|
|
|
parallel -h | wc -l
|
|
|
|
parallel --help | wc -l
|
2010-02-03 23:54:06 +00:00
|
|
|
|
2010-06-12 23:24:25 +00:00
|
|
|
echo '### Test --version: Version output (just check we get the same amount of lines)'
|
2010-06-25 23:56:14 +00:00
|
|
|
parallel --version | wc -l
|
2010-02-03 23:54:06 +00:00
|
|
|
|
2010-06-12 23:24:25 +00:00
|
|
|
echo '### Test --verbose and -t'
|
2010-06-25 23:56:14 +00:00
|
|
|
(echo b; echo c; echo f) | parallel -k -t echo {}ar 2>&1 >/dev/null
|
|
|
|
(echo b; echo c; echo f) | parallel -k --verbose echo {}ar 2>&1 >/dev/null
|
2010-04-21 19:28:00 +00:00
|
|
|
|
2010-06-12 23:24:25 +00:00
|
|
|
echo '### Test --show-limits'
|
2010-06-25 23:56:14 +00:00
|
|
|
(echo b; echo c; echo f) | parallel -k --show-limits echo {}ar
|
2011-01-11 12:42:14 +00:00
|
|
|
(echo b; echo c; echo f) | parallel -j1 -kX --show-limits -s 100 echo {}ar
|