2013-12-19 01:19:19 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Simple jobs that never fails
|
|
|
|
# Each should be taking >100s and be possible to run in parallel
|
|
|
|
# I.e.: No race conditions, no logins
|
2015-07-22 06:28:05 +00:00
|
|
|
|
2016-06-27 19:00:19 +00:00
|
|
|
# tmpdir with > 5 GB available
|
2015-07-22 06:28:05 +00:00
|
|
|
TMP5G=${TMP5G:-/dev/shm}
|
|
|
|
export TMP5G
|
|
|
|
|
2016-08-03 21:45:13 +00:00
|
|
|
rm -f /tmp/*.{tmx,pac,arg,all,log,swp,loa,ssh,df,pip,tmb,chr,tms,par}
|
|
|
|
|
2018-01-06 18:58:01 +00:00
|
|
|
par_exit_code() {
|
|
|
|
echo 'bug #52207: Exit status 0 when child job is killed, even with "now,fail=1"'
|
|
|
|
in_shell_run_command() {
|
|
|
|
# Runs command in given shell via Perl's open3
|
|
|
|
shell="$1"
|
|
|
|
prg="$2"
|
|
|
|
perl -MIPC::Open3 -e 'open3($a,$b,$c,"'$shell'","-c","'"$prg"'"); wait; print $?>>8,"\n"'
|
|
|
|
}
|
|
|
|
export -f in_shell_run_command
|
|
|
|
|
|
|
|
runit() {
|
|
|
|
OK="ash bash csh dash fish mksh posh rc sash sh static-sh tcsh"
|
|
|
|
BAD="fdsh fizsh ksh ksh93 yash zsh"
|
|
|
|
s=100
|
|
|
|
cp /bin/sleep /tmp/mysleep
|
|
|
|
|
|
|
|
echo '# Ideally the command should return the same'
|
|
|
|
echo '# with or without parallel'
|
2018-07-08 18:45:39 +00:00
|
|
|
echo '# but fish 2.4.0 returns 1 while X.X.X returns 0'
|
2018-01-06 18:58:01 +00:00
|
|
|
parallel -kj500% --argsep ,, --tag in_shell_run_command {1} '{=2 $_=Q($_) =}' \
|
|
|
|
,, $OK $BAD ,, \
|
|
|
|
'/tmp/mysleep '$s \
|
|
|
|
'parallel --halt-on-error now,fail=1 /tmp/mysleep ::: '$s \
|
|
|
|
'parallel --halt-on-error now,done=1 /tmp/mysleep ::: '$s \
|
|
|
|
'parallel --halt-on-error now,done=1 true ::: '$s \
|
|
|
|
'parallel --halt-on-error now,done=1 exit ::: '$s \
|
|
|
|
'true;/tmp/mysleep '$s \
|
|
|
|
'parallel --halt-on-error now,fail=1 "true;/tmp/mysleep" ::: '$s \
|
|
|
|
'parallel --halt-on-error now,done=1 "true;/tmp/mysleep" ::: '$s \
|
|
|
|
'parallel --halt-on-error now,done=1 "true;true" ::: '$s \
|
|
|
|
'parallel --halt-on-error now,done=1 "true;exit" ::: '$s
|
|
|
|
}
|
|
|
|
export -f runit
|
|
|
|
|
|
|
|
killsleep() {
|
|
|
|
sleep 5
|
|
|
|
while true; do killall -9 mysleep 2>/dev/null; sleep 1; done
|
|
|
|
}
|
|
|
|
export -f killsleep
|
|
|
|
|
|
|
|
parallel -uj0 --halt now,done=1 ::: runit killsleep
|
|
|
|
}
|
|
|
|
|
2016-07-10 21:00:20 +00:00
|
|
|
par_retries_unreachable() {
|
|
|
|
echo '### Test of --retries on unreachable host'
|
2016-05-17 00:11:38 +00:00
|
|
|
seq 2 | stdout parallel -k --retries 2 -v -S 4.3.2.1,: echo
|
2016-07-10 21:00:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
par_outside_file_handle_limit() {
|
2017-04-22 20:42:11 +00:00
|
|
|
ulimit -n 1024
|
|
|
|
echo "### Test Force outside the file handle limit, 2009-02-17 Gave fork error"
|
|
|
|
(echo echo Start; seq 1 20000 | perl -pe 's/^/true /'; echo echo end) |
|
|
|
|
stdout parallel -uj 0 | egrep -v 'processes took|adjusting' |
|
|
|
|
perl -pe 's/\d\d\d/999/'
|
2016-07-10 21:00:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
par_over_4GB() {
|
2017-04-22 20:42:11 +00:00
|
|
|
echo '### Test if we can deal with output > 4 GB'
|
|
|
|
echo |
|
|
|
|
nice parallel --tmpdir $TMP5G -q perl -e '$a="x"x1000000;for(0..4300){print $a}' |
|
|
|
|
nice md5sum
|
2016-07-10 21:00:20 +00:00
|
|
|
}
|
|
|
|
|
2017-07-21 19:43:34 +00:00
|
|
|
par_mem_leak() {
|
|
|
|
echo "### test for mem leak"
|
|
|
|
|
2018-05-08 21:16:48 +00:00
|
|
|
export parallel=parallel
|
2017-07-21 19:43:34 +00:00
|
|
|
no_mem_leak() {
|
2018-05-08 21:16:48 +00:00
|
|
|
run_measurements() {
|
|
|
|
from=$1
|
|
|
|
to=$2
|
|
|
|
pause_every=$3
|
|
|
|
measure() {
|
|
|
|
# Input:
|
|
|
|
# $1 = iterations
|
|
|
|
# $2 = sleep 1 sec for every $2
|
|
|
|
seq $1 | ramusage $parallel -u sleep '{= $_=$_%'$2'?0:1 =}'
|
|
|
|
}
|
|
|
|
export -f measure
|
|
|
|
|
|
|
|
seq $from $to | $parallel measure {} $pause_every |
|
|
|
|
sort -n
|
2017-07-21 19:43:34 +00:00
|
|
|
}
|
2018-05-08 21:16:48 +00:00
|
|
|
|
2017-07-21 19:43:34 +00:00
|
|
|
# Return false if leaking
|
2018-05-08 21:16:48 +00:00
|
|
|
# Normal: 16940-17320
|
|
|
|
max1000=$(run_measurements 1000 1007 100000 | tail -n1)
|
|
|
|
min30000=$(run_measurements 15000 15004 100000 | head -n1)
|
2016-08-14 14:54:27 +00:00
|
|
|
if [ $max1000 -gt $min30000 ] ; then
|
2018-05-08 21:16:48 +00:00
|
|
|
echo Probably no leak $max1000 -gt $min30000
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
echo Probably leaks $max1000 not -gt $min30000
|
2017-07-21 19:43:34 +00:00
|
|
|
# Make sure there are a few sleeps
|
2018-05-08 21:16:48 +00:00
|
|
|
max1000=$(run_measurements 1001 1007 100 | tail -n1)
|
|
|
|
min30000=$(run_measurements 30000 30004 100 | head -n1)
|
2017-07-21 19:43:34 +00:00
|
|
|
if [ $max1000 -gt $min30000 ] ; then
|
2018-05-08 21:16:48 +00:00
|
|
|
echo $max1000 -gt $min30000 = very likely no leak
|
2017-07-21 19:43:34 +00:00
|
|
|
return 0
|
|
|
|
else
|
2018-05-08 21:16:48 +00:00
|
|
|
echo not $max1000 -gt $min30000 = very likely leak
|
2017-07-21 19:43:34 +00:00
|
|
|
return 1
|
|
|
|
fi
|
2016-08-14 14:54:27 +00:00
|
|
|
fi
|
2017-07-21 19:43:34 +00:00
|
|
|
}
|
2016-08-14 14:54:27 +00:00
|
|
|
|
2017-07-21 19:43:34 +00:00
|
|
|
renice -n 3 $$ 2>/dev/null >/dev/null
|
2016-08-14 14:54:27 +00:00
|
|
|
if no_mem_leak >/dev/null ; then
|
|
|
|
echo no mem leak detected
|
|
|
|
else
|
|
|
|
echo possible mem leak;
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-05-15 23:27:11 +00:00
|
|
|
par_timeout() {
|
|
|
|
echo "### test --timeout"
|
|
|
|
stdout time -f %e parallel --timeout 1s sleep ::: 10 |
|
|
|
|
perl -ne '1 < $_ and $_ < 10 and print "OK\n"'
|
|
|
|
stdout time -f %e parallel --timeout 1m sleep ::: 100 |
|
|
|
|
perl -ne '10 < $_ and $_ < 100 and print "OK\n"'
|
|
|
|
}
|
|
|
|
|
2017-07-21 19:43:34 +00:00
|
|
|
par_halt_on_error() {
|
|
|
|
mytest() {
|
|
|
|
HALT=$1
|
|
|
|
BOOL1=$2
|
|
|
|
BOOL2=$3
|
|
|
|
(echo "sleep 1;$BOOL1";
|
|
|
|
echo "sleep 2;$BOOL2";
|
|
|
|
echo "sleep 3;$BOOL1") |
|
|
|
|
parallel -j10 --halt-on-error $HALT
|
|
|
|
echo $?
|
|
|
|
(echo "sleep 1;$BOOL1";
|
|
|
|
echo "sleep 2;$BOOL2";
|
|
|
|
echo "sleep 3;$BOOL1";
|
|
|
|
echo "sleep 4;non_exist";
|
|
|
|
) |
|
|
|
|
parallel -j10 --halt-on-error $HALT
|
|
|
|
echo $?
|
|
|
|
}
|
|
|
|
export -f mytest
|
|
|
|
parallel -j1 -k --tag mytest ::: -2 -1 0 1 2 ::: true false ::: true false
|
|
|
|
}
|
|
|
|
|
2018-07-08 18:45:39 +00:00
|
|
|
par_test_build_and_install() {
|
|
|
|
cd ~/privat/parallel
|
|
|
|
# Make a .tar.gz file
|
|
|
|
stdout make dist |
|
|
|
|
perl -pe 's/make\[\d\]/make[0]/g;s/\d{8}/00000000/g'
|
|
|
|
LAST=$(ls *tar.gz | tail -n1)
|
|
|
|
|
|
|
|
cd /tmp
|
|
|
|
rm -rf parallel-20??????/
|
|
|
|
tar xf ~/privat/parallel/$LAST
|
|
|
|
cd parallel-20??????/
|
|
|
|
|
|
|
|
echo "### Test normal build and install"
|
|
|
|
# Make sure files depending on *.pod have to be rebuilt
|
|
|
|
touch src/*pod src/sql
|
2018-07-11 16:46:05 +00:00
|
|
|
./configure --prefix=/tmp/parallel-install &&
|
|
|
|
(stdout nice make -j3 >/dev/null;
|
|
|
|
stdout nice make install) |
|
2018-07-08 18:45:39 +00:00
|
|
|
perl -pe 's/make\[\d\]/make[0]/g;s/\d{8}/00000000/g'
|
|
|
|
|
|
|
|
echo '### Test installation missing pod2*'
|
|
|
|
parallel which ::: pod2html pod2man pod2texi pod2pdf |
|
|
|
|
sudo parallel mv {} {}.hidden
|
|
|
|
# Make sure files depending on *.pod have to be rebuilt
|
|
|
|
touch src/*pod src/sql
|
2018-07-11 16:46:05 +00:00
|
|
|
./configure --prefix=/tmp/parallel-install &&
|
|
|
|
(stdout nice make -j3 >/dev/null;
|
|
|
|
stdout nice make install) |
|
2018-07-08 18:45:39 +00:00
|
|
|
perl -pe 's/make\[\d\]/make[0]/g;s/\d{8}/00000000/g'
|
|
|
|
|
|
|
|
parallel which {}.hidden ::: pod2html pod2man pod2texi pod2pdf |
|
|
|
|
sudo parallel mv {} {.}
|
|
|
|
}
|
2016-08-14 14:54:27 +00:00
|
|
|
|
2016-07-10 21:00:20 +00:00
|
|
|
export -f $(compgen -A function | grep par_)
|
|
|
|
compgen -A function | grep par_ | sort | parallel -vj0 -k --tag --joblog /tmp/jl-`basename $0` '{} 2>&1'
|