2020-08-11 20:55:31 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-01-24 01:02:07 +00:00
|
|
|
# SPDX-FileCopyrightText: 2021-2024 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
|
|
|
|
|
2024-03-31 21:29:30 +00:00
|
|
|
# Clean up environment to make room for the test functions
|
|
|
|
while read f ; do
|
|
|
|
eval unset -f "$f";
|
|
|
|
done < <(compgen -A function | grep ^_)
|
|
|
|
|
2020-08-11 20:55:31 +00:00
|
|
|
. `which env_parallel.bash`
|
|
|
|
env_parallel --session
|
|
|
|
|
2020-08-20 21:07:56 +00:00
|
|
|
true <<'EOF'
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Find the command line limit formula
|
|
|
|
# macosx.p = 10.7.5
|
|
|
|
# El capitan = 10.11.4
|
|
|
|
|
2020-09-12 21:33:55 +00:00
|
|
|
. `which find-first-fail`
|
2020-08-20 21:07:56 +00:00
|
|
|
doit() {
|
|
|
|
nfunc=$1
|
|
|
|
lfunc=$2
|
|
|
|
lfuncname=$3
|
|
|
|
nvar=$4
|
|
|
|
lvar=$5
|
|
|
|
lvarname=$6
|
2020-09-12 21:33:55 +00:00
|
|
|
onechar=$7
|
2020-08-20 21:07:56 +00:00
|
|
|
varval="$(perl -e 'print "x "x('$lvar'/2)')"
|
|
|
|
varname=$(perl -e 'print "x"x'$lvarname)
|
|
|
|
funcval="$(perl -e 'print "x "x('$lfunc'/2)')"
|
|
|
|
funcname=$(perl -e 'print "x"x'$lfuncname)
|
|
|
|
for a in `seq $nvar`; do eval "export v$varname$a='$varval'" ; done
|
|
|
|
for a in `seq $nfunc`; do eval "f$funcname$a() { $funcval; }" ; done
|
|
|
|
for a in `seq $nfunc`; do eval "export -f f$funcname$a" ; done
|
|
|
|
myrun() {
|
2020-09-12 21:33:55 +00:00
|
|
|
/bin/echo $(perl -e 'print "a"x('$2')." x"x('$1'/2)')
|
2020-08-20 21:07:56 +00:00
|
|
|
}
|
|
|
|
export -f myrun
|
|
|
|
binlen=dummy
|
2020-09-12 21:33:55 +00:00
|
|
|
binlen=$(find-first-fail -q myrun $onechar)
|
2020-08-20 21:07:56 +00:00
|
|
|
perl -e '
|
|
|
|
$envc=(keys %ENV);
|
|
|
|
$envn=length join"",(keys %ENV);
|
|
|
|
$envv=length join"",(values %ENV);
|
2020-09-12 21:33:55 +00:00
|
|
|
$onechar='$onechar';
|
2020-10-22 19:47:01 +00:00
|
|
|
$maxlen=-39+262144 - $envn - $envv - $onechar*5 - $envc*10;
|
|
|
|
print("Computed max len = $maxlen\n");
|
2020-08-20 21:07:56 +00:00
|
|
|
$bin='$binlen';
|
2020-12-30 12:42:02 +00:00
|
|
|
print("Diff:",$bin-$maxlen," Actual:$bin Vars: $onechar $envc $envn $envv\n");
|
2020-08-20 21:07:56 +00:00
|
|
|
'
|
|
|
|
}
|
|
|
|
export -f doit
|
|
|
|
|
|
|
|
val="$(seq 2 100 1000)"
|
|
|
|
val="10 20 50 100 200 500 1000"
|
2020-09-12 21:33:55 +00:00
|
|
|
val="12 103 304 506 1005"
|
2020-10-22 19:47:01 +00:00
|
|
|
parallel --timeout 20 --shuf --tag -k doit ::: $val ::: $val ::: $val ::: $val ::: $val ::: $val ::: $val 2>/dev/null
|
2020-09-12 21:33:55 +00:00
|
|
|
|
|
|
|
# Test with random data
|
|
|
|
(seq 10;seq 100;seq 100;seq 100;seq 100; seq 300 ;seq 1000) |
|
|
|
|
shuf | parallel -n 7 --timeout 20 --tag -k doit
|
2020-08-20 21:07:56 +00:00
|
|
|
EOF
|
|
|
|
|
|
|
|
# Each should generate at least 2 commands
|
|
|
|
|
2020-08-16 08:12:42 +00:00
|
|
|
par_many_args() {
|
2023-02-19 13:49:30 +00:00
|
|
|
export PARALLEL="--_unsafe"
|
2020-08-16 08:12:42 +00:00
|
|
|
rm -f ~/.parallel/tmp/sshlogin/*/linelen
|
|
|
|
pecho() { perl -e 'print "@ARGV\n"' "$@"; }
|
|
|
|
export -f pecho
|
2020-08-20 21:07:56 +00:00
|
|
|
geny() { yes | head -c $1; }
|
2020-08-16 08:12:42 +00:00
|
|
|
for a in `seq 6000`; do eval "export a$a=1" ; done
|
2020-08-20 21:07:56 +00:00
|
|
|
geny 10000 | stdout parallel -Xkj1 'pecho {} {} {} {} | wc' |
|
|
|
|
perl -pe 's/( y){10,}//g'
|
2024-03-31 21:29:30 +00:00
|
|
|
echo
|
2020-08-16 08:12:42 +00:00
|
|
|
}
|
|
|
|
|
2020-08-11 20:55:31 +00:00
|
|
|
par_many_var() {
|
2020-08-20 21:07:56 +00:00
|
|
|
export LC_ALL=C
|
2020-08-16 08:12:42 +00:00
|
|
|
rm -f ~/.parallel/tmp/sshlogin/*/linelen
|
|
|
|
pecho() { perl -e 'print "@ARGV\n"' "$@"; }
|
|
|
|
export -f pecho
|
2020-08-20 21:07:56 +00:00
|
|
|
gen() { seq -f %f 1000000000000000 1000000000050000 | head -c $1; }
|
2020-08-11 20:55:31 +00:00
|
|
|
for a in `seq 6000`; do eval "export a$a=1" ; done
|
2022-11-26 20:42:41 +00:00
|
|
|
gen 40000 | stdout parallel -Xkj1 'pecho {} {} {} {} | wc -c' |
|
|
|
|
perl -pe 's/\d{10,}.\d+ //g; s/(\d+)\d\d\d/${1}XXX/g;' |
|
2024-03-31 21:29:30 +00:00
|
|
|
grep XXX
|
|
|
|
echo
|
2020-08-11 20:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
par_many_var_func() {
|
2023-02-19 13:49:30 +00:00
|
|
|
export PARALLEL="--_unsafe"
|
2020-08-20 21:07:56 +00:00
|
|
|
export LC_ALL=C
|
2020-08-16 08:12:42 +00:00
|
|
|
rm -f ~/.parallel/tmp/sshlogin/*/linelen
|
2020-08-20 21:07:56 +00:00
|
|
|
gen() { seq -f %f 1000000000000000 1000000000050000 | head -c $1; }
|
2020-08-16 08:12:42 +00:00
|
|
|
pecho() { perl -e 'print "@ARGV\n"' "$@"; }
|
|
|
|
export -f pecho
|
2020-08-20 21:07:56 +00:00
|
|
|
for a in `seq 2000`; do eval "export a$a=1" ; done
|
|
|
|
for a in `seq 2000`; do eval "a$a() { 1; }" ; done
|
|
|
|
for a in `seq 2000`; do eval export -f a$a ; done
|
2020-09-12 21:33:55 +00:00
|
|
|
gen 40000 | stdout parallel -Xkj1 'pecho {} {} {} {} | wc' |
|
2020-08-11 20:55:31 +00:00
|
|
|
perl -pe 's/\d{10,}.\d+ //g'
|
2024-03-31 21:29:30 +00:00
|
|
|
echo
|
2020-08-11 20:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
par_many_func() {
|
2023-02-19 13:49:30 +00:00
|
|
|
export PARALLEL="--_unsafe"
|
2020-08-20 21:07:56 +00:00
|
|
|
export LC_ALL=C
|
2020-08-16 08:12:42 +00:00
|
|
|
rm -f ~/.parallel/tmp/sshlogin/*/linelen
|
2020-08-20 21:07:56 +00:00
|
|
|
gen() { seq -f %f 1000000000000000 1000000000050000 | head -c $1; }
|
2020-08-16 08:12:42 +00:00
|
|
|
pecho() { perl -e 'print "@ARGV\n"' "$@"; }
|
|
|
|
export -f pecho
|
2024-03-31 21:29:30 +00:00
|
|
|
for a in `seq 3000`; do eval "a$a() { 1; }" ; done
|
|
|
|
for a in `seq 3000`; do eval export -f a$a ; done
|
|
|
|
gen 40000 | stdout parallel -Xkj1 'pecho {} {} {} {} | wc'
|
|
|
|
echo |
|
2020-08-11 20:55:31 +00:00
|
|
|
perl -pe 's/\d{10,}.\d+ //g'
|
2024-03-31 21:29:30 +00:00
|
|
|
echo
|
2020-08-11 20:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
par_big_func() {
|
2023-02-19 13:49:30 +00:00
|
|
|
export PARALLEL="--_unsafe"
|
2020-08-20 21:07:56 +00:00
|
|
|
export LC_ALL=C
|
2020-08-16 08:12:42 +00:00
|
|
|
rm -f ~/.parallel/tmp/sshlogin/*/linelen
|
2020-08-20 21:07:56 +00:00
|
|
|
gen() { seq -f %f 1000000000000000 1000000000050000 | head -c $1; }
|
2020-08-16 08:12:42 +00:00
|
|
|
pecho() { perl -e 'print "@ARGV\n"' "$@"; }
|
|
|
|
export -f pecho
|
2020-08-11 20:55:31 +00:00
|
|
|
big=`seq 1000`
|
2020-08-16 08:12:42 +00:00
|
|
|
for a in `seq 1`; do eval "a$a() { '$big'; }" ; done
|
|
|
|
for a in `seq 1`; do eval export -f a$a ; done
|
2020-09-12 21:33:55 +00:00
|
|
|
gen 80000 | stdout parallel --load 2 -Xkj1 'pecho {} {} {} {} | wc' |
|
2020-08-11 20:55:31 +00:00
|
|
|
perl -pe 's/\d{10,}.\d+ //g'
|
2024-03-31 21:29:30 +00:00
|
|
|
echo
|
2020-08-11 20:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
par_many_var_big_func() {
|
2020-08-20 21:07:56 +00:00
|
|
|
export LC_ALL=C
|
2020-08-16 08:12:42 +00:00
|
|
|
rm -f ~/.parallel/tmp/sshlogin/*/linelen
|
2020-08-20 21:07:56 +00:00
|
|
|
gen() { seq -f %f 1000000000000000 1000000000050000 | head -c $1; }
|
2020-08-16 08:12:42 +00:00
|
|
|
pecho() { perl -e 'print "@ARGV\n"' "$@"; }
|
|
|
|
export -f pecho
|
2020-08-11 20:55:31 +00:00
|
|
|
big=`seq 1000`
|
|
|
|
for a in `seq 5000`; do eval "export a$a=1" ; done
|
|
|
|
for a in `seq 10`; do eval "a$a() { '$big'; }" ; done
|
|
|
|
for a in `seq 10`; do eval export -f a$a ; done
|
2022-03-22 22:08:24 +00:00
|
|
|
gen 40000 | stdout parallel -Xkj1 'pecho {} {} {} {} | wc -c' |
|
2022-11-26 20:42:41 +00:00
|
|
|
perl -pe 's/\d{10,}.\d+ //g; s/(\d+)\d\d\d/${1}XXX/g;' |
|
|
|
|
grep 5XXX
|
2024-03-31 21:29:30 +00:00
|
|
|
echo
|
2020-08-11 20:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
par_big_func_name() {
|
2020-08-20 21:07:56 +00:00
|
|
|
export LC_ALL=C
|
2020-08-16 08:12:42 +00:00
|
|
|
rm -f ~/.parallel/tmp/sshlogin/*/linelen
|
2020-08-20 21:07:56 +00:00
|
|
|
gen() { seq -f %f 1000000000000000 1000000000050000 | head -c $1; }
|
2020-08-16 08:12:42 +00:00
|
|
|
pecho() { perl -e 'print "@ARGV\n"' "$@"; }
|
|
|
|
export -f pecho
|
2020-08-11 20:55:31 +00:00
|
|
|
big=`perl -e print\"x\"x10000`
|
|
|
|
for a in `seq 10`; do eval "export a$big$a=1" ; done
|
2022-03-22 22:08:24 +00:00
|
|
|
gen 30000 | stdout parallel -Xkj1 'pecho {} {} {} {} | wc -c' |
|
2022-11-26 20:42:41 +00:00
|
|
|
perl -pe 's/\d{10,}.\d+ //g; s/(\d+)\d\d\d/${1}XXX/g;' |
|
2024-03-31 21:29:30 +00:00
|
|
|
grep 1.XXX
|
|
|
|
echo
|
2020-08-11 20:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
par_big_var_func_name() {
|
2020-08-20 21:07:56 +00:00
|
|
|
export LC_ALL=C
|
2020-08-16 08:12:42 +00:00
|
|
|
rm -f ~/.parallel/tmp/sshlogin/*/linelen
|
2020-08-20 21:07:56 +00:00
|
|
|
gen() { seq -f %f 1000000000000000 1000000000050000 | head -c $1; }
|
2020-08-16 08:12:42 +00:00
|
|
|
pecho() { perl -e 'print "@ARGV\n"' "$@"; }
|
|
|
|
export -f pecho
|
2024-03-31 21:29:30 +00:00
|
|
|
big=`perl -e print\"x\"x5000`
|
2020-08-11 20:55:31 +00:00
|
|
|
for a in `seq 10`; do eval "export a$big$a=1" ; done
|
|
|
|
for a in `seq 10`; do eval "a$big$a() { 1; }" ; done
|
|
|
|
for a in `seq 10`; do eval export -f a$big$a ; done
|
2022-04-23 09:38:57 +00:00
|
|
|
gen 80000 | stdout parallel --load 4 -Xkj1 'pecho {} {} {} {} | wc -c' |
|
2022-11-26 20:42:41 +00:00
|
|
|
perl -pe 's/\d{10,}.\d+ //g; s/(\d+)\d\d\d/${1}XXX/g;' |
|
2024-03-31 21:29:30 +00:00
|
|
|
grep XXX
|
|
|
|
echo
|
2020-08-11 20:55:31 +00:00
|
|
|
}
|
|
|
|
|
2023-02-19 13:49:30 +00:00
|
|
|
export PARALLEL="--_unsafe"
|
2020-09-23 15:41:03 +00:00
|
|
|
macsshlogin=$(parallel --halt now,success=1 ssh {} echo {} ::: ota@mac macosx.p)
|
|
|
|
|
2023-07-21 02:33:22 +00:00
|
|
|
if scp /usr/local/bin/parallel $macsshlogin:bin/ ; then
|
|
|
|
true
|
|
|
|
else
|
2023-07-23 12:31:07 +00:00
|
|
|
echo "**"
|
|
|
|
echo "** Mac not found. Skip testing"
|
|
|
|
echo "**"
|
2023-07-21 02:33:22 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2020-08-11 20:55:31 +00:00
|
|
|
|
2020-08-20 21:07:56 +00:00
|
|
|
export LC_ALL=C
|
2020-08-11 20:55:31 +00:00
|
|
|
export -f $(compgen -A function | grep par_)
|
|
|
|
compgen -A function |
|
|
|
|
grep par_ |
|
|
|
|
LC_ALL=C sort |
|
2022-03-09 22:03:26 +00:00
|
|
|
env_parallel --timeout 3000% --tag -k -S 6/$macsshlogin 'PATH=$HOME/bin:$PATH; {}' |
|
|
|
|
perl -pe 's/(\d+)\d\d\d/${1}XXX/g'
|