2017-01-06 21:53:21 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-12-26 22:29:28 +00:00
|
|
|
# SPDX-FileCopyrightText: 2021-2022 Ole Tange, http://ole.tange.dk and Free Software and Foundation, Inc.
|
2021-03-22 20:16:35 +00:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2017-01-06 21:53:21 +00:00
|
|
|
# Each test should at most run 1 ssh against parallel@lo or lo
|
|
|
|
|
2020-08-16 08:12:42 +00:00
|
|
|
par_transfer_special_char_names() {
|
|
|
|
echo '### Test --return of weirdly named file'
|
2022-02-17 12:19:55 +00:00
|
|
|
ssh parallel@lo rm -f 'aa*b'
|
2020-08-16 08:12:42 +00:00
|
|
|
rm -f 'aa<${#}" b'
|
|
|
|
stdout parallel --return {} -S parallel@lo echo '>'{} ::: 'aa<${#}" b'
|
|
|
|
ls 'aa<${#}" b'
|
|
|
|
rm -f 'aa<${#}" b'
|
|
|
|
}
|
|
|
|
|
2017-01-06 21:53:21 +00:00
|
|
|
par_path_remote_bash() {
|
|
|
|
echo 'bug #47695: How to set $PATH on remote? Bash'
|
|
|
|
rm -rf /tmp/parallel
|
|
|
|
cp /usr/local/bin/parallel /tmp
|
|
|
|
|
2020-08-07 20:20:30 +00:00
|
|
|
cat <<'_EOS' |
|
2020-10-22 19:47:01 +00:00
|
|
|
echo StArT
|
2017-01-06 21:53:21 +00:00
|
|
|
echo BASH Path before: $PATH with no parallel
|
|
|
|
parallel echo ::: 1
|
|
|
|
# Race condition stderr/stdout
|
|
|
|
sleep 1
|
|
|
|
echo '^^^^^^^^ Not found is OK'
|
|
|
|
# Exporting a big variable should not fail
|
|
|
|
export A="`seq 1000`"
|
|
|
|
PATH=$PATH:/tmp
|
|
|
|
. /usr/local/bin/env_parallel.bash
|
2021-02-17 14:49:47 +00:00
|
|
|
# --filter-hosts to see if $PATH with parallel is transferred
|
|
|
|
env_parallel --filter-hosts --env A,PATH -Slo echo '$PATH' ::: OK
|
2017-01-06 21:53:21 +00:00
|
|
|
_EOS
|
2020-08-07 20:20:30 +00:00
|
|
|
stdout ssh nopathbash@lo -T |
|
2020-10-22 19:47:01 +00:00
|
|
|
perl -ne '/StArT/..0 and print' |
|
2020-08-07 20:20:30 +00:00
|
|
|
uniq
|
2017-01-06 21:53:21 +00:00
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
par_path_remote_csh() {
|
|
|
|
echo 'bug #47695: How to set $PATH on remote? csh'
|
|
|
|
rm -rf /tmp/parallel
|
|
|
|
cp /usr/local/bin/parallel /tmp
|
|
|
|
|
2020-08-07 20:20:30 +00:00
|
|
|
cat <<'_EOS' |
|
2020-10-22 19:47:01 +00:00
|
|
|
echo StArT
|
2017-01-06 21:53:21 +00:00
|
|
|
echo CSH Path before: $PATH with no parallel
|
|
|
|
which parallel >& /dev/stdout
|
|
|
|
echo '^^^^^^^^ Not found is OK'
|
|
|
|
alias parallel=/tmp/parallel
|
|
|
|
# Exporting a big variable should not fail
|
|
|
|
setenv A "`seq 1000`"
|
|
|
|
setenv PATH ${PATH}:/tmp
|
|
|
|
cp /usr/local/bin/env_parallel* /tmp
|
2017-12-03 00:40:01 +00:00
|
|
|
rehash
|
2017-01-06 21:53:21 +00:00
|
|
|
if ("`alias env_parallel`" == '') then
|
|
|
|
source `which env_parallel.csh`
|
|
|
|
endif
|
2021-02-17 14:49:47 +00:00
|
|
|
# --filter-hosts to see if $PATH with parallel is transferred
|
|
|
|
env_parallel --filter-hosts --env A,PATH -Slo echo '$PATH' ::: OK
|
2017-06-22 11:35:58 +00:00
|
|
|
# Sleep needed to avoid stderr/stdout mixing
|
|
|
|
sleep 1
|
2017-01-06 21:53:21 +00:00
|
|
|
echo Done
|
|
|
|
_EOS
|
2020-08-07 20:20:30 +00:00
|
|
|
stdout ssh nopathcsh@lo -T |
|
2020-10-22 19:47:01 +00:00
|
|
|
perl -ne '/StArT/..0 and print' |
|
2020-08-07 20:20:30 +00:00
|
|
|
uniq
|
2017-01-06 21:53:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
par_keep_order() {
|
|
|
|
echo '### Test --keep-order'
|
|
|
|
seq 0 2 |
|
2022-02-17 12:19:55 +00:00
|
|
|
parallel --keep-order -j100% -S 1/:,2/parallel@lo -q perl -e 'sleep 1;print "job{}\n";exit({})'
|
2017-01-06 21:53:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
par_keeporder() {
|
|
|
|
echo '### Test --keeporder'
|
|
|
|
seq 0 2 |
|
2022-02-17 12:19:55 +00:00
|
|
|
parallel --keeporder -j100% -S 1/:,2/parallel@lo -q perl -e 'sleep 1;print "job{}\n";exit({})'
|
2017-01-06 21:53:21 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 14:25:58 +00:00
|
|
|
par_load_csh() {
|
|
|
|
echo '### Gave Word too long.'
|
|
|
|
parallel --load 100% -S csh@lo echo ::: a
|
|
|
|
}
|
2017-01-06 21:53:21 +00:00
|
|
|
|
2017-08-23 22:38:49 +00:00
|
|
|
par_bar_m() {
|
|
|
|
echo '### test --bar -m'
|
|
|
|
stdout parallel --bar -P 2 -m sleep ::: 1 1 2 2 3 3 |
|
|
|
|
perl -pe 's/\r/\n/g'|
|
|
|
|
grep -E '^[0-9]+ *$' |
|
|
|
|
uniq
|
|
|
|
}
|
|
|
|
|
2020-01-09 13:37:41 +00:00
|
|
|
retries() {
|
|
|
|
retries=$1
|
|
|
|
min=$2
|
|
|
|
max=$3
|
|
|
|
export PARALLEL="--retries $retries -S 12/localhost,1/:,parallel@lo -uq"
|
|
|
|
tries=$(seq 0 12 |
|
|
|
|
parallel perl -e 'print "job{}\n";exit({})' 2>/dev/null |
|
|
|
|
wc -l)
|
|
|
|
# Dont care if they are off by one
|
|
|
|
if [ $min -le $tries -o $tries -le $max ] ; then
|
|
|
|
echo OK
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
export -f retries
|
|
|
|
|
2018-04-27 16:52:00 +00:00
|
|
|
par_retries_1() {
|
|
|
|
echo '### Test of --retries - it should run 13 jobs in total';
|
2020-01-09 13:37:41 +00:00
|
|
|
retries 1 11 13
|
2018-04-27 16:52:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
par_retries_2() {
|
|
|
|
echo '### Test of --retries - it should run 25 jobs in total';
|
2020-01-09 13:37:41 +00:00
|
|
|
retries 2 24 25
|
2018-04-27 16:52:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
par_retries_4() {
|
|
|
|
echo '### Test of --retries - it should run 49 jobs in total';
|
2020-01-09 13:37:41 +00:00
|
|
|
retries 4 48 49
|
2018-04-27 16:52:00 +00:00
|
|
|
}
|
|
|
|
|
2020-08-22 23:31:39 +00:00
|
|
|
par_csh_environment_variables_set() {
|
|
|
|
echo '### Check $PARALLEL_PID $PARALLEL_SEQ are set in csh'
|
|
|
|
parallel -S csh@localhost 'echo $PARALLEL_PID $PARALLEL_SEQ {}| wc -w' ::: a
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-06 21:53:21 +00:00
|
|
|
export -f $(compgen -A function | grep par_)
|
|
|
|
#compgen -A function | grep par_ | sort | parallel --delay $D -j$P --tag -k '{} 2>&1'
|
2018-10-22 22:46:38 +00:00
|
|
|
compgen -A function | grep par_ | LC_ALL=C sort |
|
2020-08-07 20:20:30 +00:00
|
|
|
parallel --joblog /tmp/jl-`basename $0` --delay 0.1 -j10 --tag -k '{} 2>&1'
|
|
|
|
|