2007-09-10 20:28:03 +00:00
#!/bin/bash
2021-03-22 20:16:35 +00:00
# SPDX-FileCopyrightText: 2021 Ole Tange, http://ole.tange.dk and Free Software and Foundation, Inc.
#
# SPDX-License-Identifier: GPL-3.0-or-later
2007-09-10 20:28:03 +00:00
rm -rf tmp 2>/dev/null
cp -a input-files/testdir2 tmp
2014-08-22 21:30:39 +00:00
NICEPAR = "nice nice parallel"
export NICEPAR
2018-09-20 22:15:14 +00:00
cat <<'EOF' | sed -e 's/;$/; /;s/$SE RVER1/'$SERVER1' /; s/$SERVER2 /'$SERVER2' /' | stdout parallel -vj0 -k --joblog /tmp/jl-` basename $0 ` -L1 -r
2014-05-12 07:27:28 +00:00
echo '### bug #42329: --line-buffer gives wrong output' ;
2014-08-22 21:30:39 +00:00
$NICEPAR --line-buffer --tag seq ::: 10000000 | wc -c;
$NICEPAR --line-buffer seq ::: 10000000 | wc -c
2014-05-12 07:27:28 +00:00
2014-05-03 22:42:52 +00:00
echo '### Test \0 as recend' ;
2014-08-22 21:30:39 +00:00
printf "a\0b\0c\0" | $NICEPAR --recend '\0' -k -N1 --pipe cat -v \; echo;
printf "\0a\0b\0c" | $NICEPAR --recstart '\0' -k -N1 --pipe cat -v \; echo
2014-05-03 22:42:52 +00:00
2013-07-30 21:15:40 +00:00
echo '### bug #39554: Feature request: line buffered output' ;
parallel -j0 --linebuffer 'echo -n start {};sleep 0.{#};echo middle -n {};sleep 1.{#}5;echo next to last {};sleep 1.{#};echo -n last {}' ::: A B C
echo
echo '### bug #39554: Feature request: line buffered output --tag' ;
parallel --tag -j0 --linebuffer 'echo -n start {};sleep 0.{#};echo middle -n {};sleep 1.{#}5;echo next to last {};sleep 1.{#};echo -n last {}' ::: A B C
echo
2013-08-14 18:11:00 +00:00
echo '### test round-robin' ;
2015-07-22 06:28:05 +00:00
nice seq 1000 | $NICEPAR -j4 --block 1k --pipe --round-robin wc | sort
2013-08-14 18:11:00 +00:00
2014-11-13 16:03:36 +00:00
echo '### bug #43600: --pipe --linebuffer --round does not work'
2016-08-03 21:45:13 +00:00
seq 10000000000 | parallel --pipe --linebuffer --round cat | head | wc -l
2014-11-13 16:03:36 +00:00
2014-11-14 00:00:56 +00:00
echo '### Check that 4 processes are really used'
2016-08-03 21:45:13 +00:00
seq 1000000 | parallel -j4 --pipe --round --line-buf wc | wc -l
2014-11-14 00:00:56 +00:00
2013-08-14 18:11:00 +00:00
echo '### --version must have higher priority than retired options'
2019-06-21 14:52:48 +00:00
$NICEPAR --version -g -Y -U -W -T | tail -n9
2013-08-14 18:11:00 +00:00
2013-08-15 17:38:39 +00:00
echo '### bug #39787: --xargs broken'
2014-08-22 21:30:39 +00:00
nice perl -e 'for(1..30000){print "$_\n"}' | $NICEPAR --xargs -k echo | perl -ne 'print length $_,"\n"'
2013-08-15 17:38:39 +00:00
2014-08-22 21:30:39 +00:00
echo '### --delay should grow by 3 sec per arg'
stdout /usr/bin/time -f %e parallel --delay 3 true ::: 1 2 | perl -ne '$_ >= 3 and $_ <= 8 and print "OK\n"'
stdout /usr/bin/time -f %e parallel --delay 3 true ::: 1 2 3 | perl -ne '$_ >= 6 and $_ <= 11 and print "OK\n"'
2013-08-16 11:11:35 +00:00
echo '### Exit value should not be affected if an earlier job times out'
2014-08-22 21:30:39 +00:00
$NICEPAR -j2 --timeout 1 --joblog - -k ::: "sleep 10" "exit 255" | field 7
2013-08-15 17:38:39 +00:00
2013-08-17 16:24:51 +00:00
echo '### --header regexp'
2014-08-22 21:30:39 +00:00
( echo %head1; echo %head2; seq 5) | $NICEPAR -kj2 --pipe -N2 --header '(%.*\n)*' echo JOB{ #}\;cat
2013-08-17 16:24:51 +00:00
echo '### --header num'
2014-08-22 21:30:39 +00:00
( echo %head1; echo %head2; seq 5) | $NICEPAR -kj2 --pipe -N2 --header 2 echo JOB{ #}\;cat
2013-08-17 16:24:51 +00:00
echo '### --header regexp --round-robin'
2014-08-22 21:30:39 +00:00
( echo %head1; echo %head2; seq 5) | $NICEPAR -kj2 --pipe -N2 --round --header '(%.*\n)*' echo JOB\; wc | sort
2013-08-17 16:24:51 +00:00
echo '### --header num --round-robin'
2014-08-22 21:30:39 +00:00
( echo %head1; echo %head2; seq 5) | $NICEPAR -kj2 --pipe -N2 --round --header 2 echo JOB{ #}\;wc | sort
2013-08-19 09:15:39 +00:00
2015-01-18 21:09:30 +00:00
echo 'bug #43967: Error if there exists a bin/zsh or bin/bash dir (with zsh or bash).'
mkdir -p /tmp/bash$$ /bash; PATH = /tmp/bash$$ :$PATH parallel echo ::: OK; rm -rf /tmp/bash$$
2013-07-30 21:15:40 +00:00
EOF
2007-09-10 20:28:03 +00:00
rm -rf tmp