parallel/testsuite/tests-to-run/parallel-local-1s.sh

337 lines
11 KiB
Bash
Raw Permalink Normal View History

2015-05-15 15:25:19 +00:00
#!/bin/bash
# Simple jobs that never fails
# Each should be taking 1-3s and be possible to run in parallel
# I.e.: No race conditions, no logins
2016-05-17 00:11:38 +00:00
par_max_length_len_128k() {
echo "### BUG: The length for -X is not close to max (131072)"
2016-05-17 00:11:38 +00:00
seq 1 60000 | parallel -X echo {.} aa {}{.} {}{}d{} {}dd{}d{.} |head -n 1 |wc
seq 1 60000 | parallel -X echo a{}b{}c |head -n 1 |wc
seq 1 60000 | parallel -X echo |head -n 1 |wc
seq 1 60000 | parallel -X echo a{}b{}c {} |head -n 1 |wc
seq 1 60000 | parallel -X echo {}aa{} |head -n 1 |wc
seq 1 60000 | parallel -X echo {} aa {} |head -n 1 |wc
}
2016-05-17 00:11:38 +00:00
par_fifo_under_csh() {
echo '### Test --fifo under csh'
2016-05-17 00:11:38 +00:00
csh -c "seq 3000000 | parallel -k --pipe --fifo 'sleep .{#};cat {}|wc -c ; false; echo \$status; false'"
echo exit $?
}
2016-05-17 00:11:38 +00:00
par_compress_prg_fails() {
echo '### bug #44546: If --compress-program fails: fail'
doit() {
(parallel $* --compress-program false \
echo \; sleep 1\; ls ::: /no-existing
echo $?) | tail -n1
}
export -f doit
parallel --tag -k doit ::: '' --line-buffer ::: '' --tag ::: '' --files
}
2016-05-17 00:11:38 +00:00
par_pxz_complains() {
echo 'bug #44250: pxz complains File format not recognized but decompresses anyway'
2016-05-17 00:11:38 +00:00
# The first line dumps core if run from make file. Why?!
stdout parallel --compress --compress-program pxz ls /{} ::: OK-if-missing-file
stdout parallel --compress --compress-program pixz --decompress-program 'pixz -d' ls /{} ::: OK-if-missing-file
stdout parallel --compress --compress-program pixz --decompress-program 'pixz -d' true ::: OK-if-no-output
stdout parallel --compress --compress-program pxz true ::: OK-if-no-output
}
2016-05-17 00:11:38 +00:00
par_test_XI_mI() {
echo "### Test -I"
seq 1 10 | parallel -k 'seq 1 {} | parallel -k -I :: echo {} ::'
2016-05-17 00:11:38 +00:00
echo "### Test -X -I"
seq 1 10 | parallel -k 'seq 1 {} | parallel -j1 -X -k -I :: echo a{} b::'
2016-05-17 00:11:38 +00:00
echo "### Test -m -I"
seq 1 10 | parallel -k 'seq 1 {} | parallel -j1 -m -k -I :: echo a{} b::'
}
par_linebuffer_files() {
echo 'bug #48658: --linebuffer --files'
rm -rf /tmp/par48658-*
doit() {
compress="$1"
echo "normal"
parallel --linebuffer --compress-program $compress seq ::: 100000 |
wc -l
echo "--files"
parallel --files --linebuffer --compress-program $1 seq ::: 100000 |
wc -l
echo "--results"
parallel --results /tmp/par48658-$compress --linebuffer --compress-program $compress seq ::: 100000 |
wc -l
rm -rf "/tmp/par48658-$compress"
}
export -f doit
parallel --tag -k doit ::: zstd pzstd clzip lz4 lzop pigz pxz gzip plzip pbzip2 lzma xz lzip bzip2 lbzip2 lrz
}
par_no_newline_compress() {
echo 'bug #41613: --compress --line-buffer - no newline';
pipe_doit() {
tagstring="$1"
compress="$2"
echo tagstring="$tagstring" compress="$compress"
perl -e 'print "O"'|
parallel "$compress" $tagstring --pipe --line-buffer cat
echo "K"
}
export -f pipe_doit
nopipe_doit() {
tagstring="$1"
compress="$2"
echo tagstring="$tagstring" compress="$compress"
parallel "$compress" $tagstring --line-buffer echo {} O ::: -n
echo "K"
}
export -f nopipe_doit
parallel -qk --header : {pipe}_doit {tagstring} {compress} \
::: tagstring '--tagstring {#}' -k \
::: compress --compress -k \
::: pipe pipe nopipe
}
par_failing_compressor() {
echo 'Compress with failing (de)compressor'
echo 'Test --tag/--line-buffer/--files in all combinations'
echo 'Test working/failing compressor/decompressor in all combinations'
echo '(-k is used as a dummy argument)'
stdout parallel -vk --header : --argsep ,,, \
parallel -k {tag} {lb} {files} --compress --compress-program {comp} --decompress-program {decomp} echo ::: C={comp},D={decomp} \
,,, tag --tag -k \
,,, lb --line-buffer -k \
,,, files --files -k \
,,, comp 'cat;true' 'cat;false' \
,,, decomp 'cat;true' 'cat;false' |
perl -pe 's:/par......par:/tmpfile:'
}
par_result() {
echo "### Test --results"
mkdir -p /tmp/parallel_results_test
parallel -k --results /tmp/parallel_results_test/testA echo {1} {2} ::: I II ::: III IIII
ls /tmp/parallel_results_test/testA/*/*/*/*/*
rm -rf /tmp/parallel_results_test/testA*
echo "### Test --res"
mkdir -p /tmp/parallel_results_test
parallel -k --res /tmp/parallel_results_test/testD echo {1} {2} ::: I II ::: III IIII
ls /tmp/parallel_results_test/testD/*/*/*/*/*
rm -rf /tmp/parallel_results_test/testD*
echo "### Test --result"
mkdir -p /tmp/parallel_results_test
parallel -k --result /tmp/parallel_results_test/testE echo {1} {2} ::: I II ::: III IIII
ls /tmp/parallel_results_test/testE/*/*/*/*/*
rm -rf /tmp/parallel_results_test/testE*
echo "### Test --results --header :"
mkdir -p /tmp/parallel_results_test
parallel -k --header : --results /tmp/parallel_results_test/testB echo {1} {2} ::: a I II ::: b III IIII
ls /tmp/parallel_results_test/testB/*/*/*/*/*
rm -rf /tmp/parallel_results_test/testB*
echo "### Test --results --header : named - a/b swapped"
mkdir -p /tmp/parallel_results_test
parallel -k --header : --results /tmp/parallel_results_test/testC echo {a} {b} ::: b III IIII ::: a I II
ls /tmp/parallel_results_test/testC/*/*/*/*/*
rm -rf /tmp/parallel_results_test/testC*
echo "### Test --results --header : piped"
mkdir -p /tmp/parallel_results_test
(echo Col; perl -e 'print "backslash\\tab\tslash/null\0eof\n"') | parallel --header : --result /tmp/parallel_results_test/testF true
find /tmp/parallel_results_test/testF/*/*/* | sort
rm -rf /tmp/parallel_results_test/testF*
echo "### Test --results --header : piped - non-existing column header"
mkdir -p /tmp/parallel_results_test
(printf "Col1\t\n"; printf "v1\tv2\tv3\n"; perl -e 'print "backslash\\tab\tslash/null\0eof\n"') |
parallel --header : --result /tmp/parallel_results_test/testG true
find /tmp/parallel_results_test/testG/ | sort
rm -rf /tmp/parallel_results_test/testG*
}
par_result_replace() {
echo '### bug #49983: --results with {1}'
parallel --results /tmp/par_{}_49983 -k echo ::: foo bar baz
find /tmp/par_*_49983 | sort
rm -rf /tmp/par_*_49983
parallel --results /tmp/par_{}_49983 -k echo ::: foo bar baz ::: A B C
find /tmp/par_*_49983 | sort
rm -rf /tmp/par_*_49983
parallel --results /tmp/par_{1}-{2}_49983 -k echo ::: foo bar baz ::: A B C
find /tmp/par_*_49983 | sort
rm -rf /tmp/par_*_49983
parallel --results /tmp/par__49983 -k echo ::: foo bar baz ::: A B C
find /tmp/par_*_49983 | sort
rm -rf /tmp/par_*_49983
parallel --results /tmp/par__49983 --header : -k echo ::: foo bar baz ::: A B C
find /tmp/par_*_49983 | sort
rm -rf /tmp/par_*_49983
parallel --results /tmp/par__49983-{}/ --header : -k echo ::: foo bar baz ::: A B C
find /tmp/par_*_49983-* | sort
rm -rf /tmp/par_*_49983-*
}
par_parset() {
echo '### test parset'
. `which env_parallel.bash`
echo 'Put output into $myarray'
parset myarray -k seq 10 ::: 14 15 16
echo "${myarray[1]}"
echo 'Put output into vars "$seq, $pwd, $ls"'
parset "seq pwd ls" -k ::: "seq 10" pwd ls
echo "$seq"
echo 'Put output into vars ($seq, $pwd, $ls)':
into_vars=(seq pwd ls)
parset "${into_vars[*]}" -k ::: "seq 5" pwd ls
echo "$seq"
echo 'The commands to run can be an array'
cmd=("echo '<<joe \"double space\" cartoon>>'" "pwd")
parset data -k ::: "${cmd[@]}"
echo "${data[0]}"
echo "${data[1]}"
echo 'You cannot pipe into parset, but must use a tempfile'
seq 10 > /tmp/parset_input_$$
parset res -k echo :::: /tmp/parset_input_$$
echo "${res[0]}"
echo "${res[9]}"
rm /tmp/parset_input_$$
echo 'or process substitution'
parset res -k echo :::: <(seq 0 10)
echo "${res[0]}"
echo "${res[9]}"
echo 'Commands with newline require -0'
parset var -k -0 ::: 'echo "line1
line2"' 'echo "command2"'
echo "${var[0]}"
}
par_incomplete_linebuffer() {
echo 'bug #51337: --lb does not kill jobs at sigpipe'
cat > /tmp/parallel--lb-test <<'_EOF'
#!/usr/bin/perl
while(1){ print ++$t,"\n"}
_EOF
chmod +x /tmp/parallel--lb-test
parallel --lb /tmp/parallel--lb-test ::: 1 | head
# Should be empty
ps aux | grep parallel[-]-lb-test
}
par_macron() {
print_it() {
parallel ::: "echo $1"
parallel echo ::: "$1"
parallel echo "$1" ::: "$1"
parallel echo \""$1"\" ::: "$1"
parallel -q echo ::: "$1"
parallel -q echo "$1" ::: "$1"
parallel -q echo \""$1"\" ::: "$1"
}
print_it "$(perl -e 'print "\257"')"
print_it "$(perl -e 'print "\257\256"')"
print_it "$(perl -e 'print "\257<\257<\257>\257>"')"
}
par_header_parens() {
echo 'bug #49538: --header and {= =}'
parallel --header : echo '{=v2=}{=v1 $_=Q($_)=}' ::: v1 K ::: v2 O
parallel --header : echo '{2}{=1 $_=Q($_)=}' ::: v2 K ::: v1 O
parallel --header : echo {var/.} ::: var sub/dir/file.ext
parallel --header : echo {var//} ::: var sub/dir/file.ext
parallel --header : echo {var/.} ::: var sub/dir/file.ext
parallel --header : echo {var/} ::: var sub/dir/file.ext
parallel --header : echo {var.} ::: var sub/dir/file.ext
}
par_parset2() {
. `which env_parallel.bash`
echo '### parset into array'
parset arr1 echo ::: foo bar baz
echo ${arr1[0]} ${arr1[1]} ${arr1[2]}
echo '### parset into vars with comma'
parset comma3,comma2,comma1 echo ::: baz bar foo
echo $comma1 $comma2 $comma3
echo '### parset into vars with space'
parset 'space3 space2 space1' echo ::: baz bar foo
echo $space1 $space2 $space3
echo '### parset with newlines'
parset 'newline3 newline2 newline1' seq ::: 3 2 1
echo "$newline1"
echo "$newline2"
echo "$newline3"
echo '### parset into indexed array vars'
parset 'myarray[6],myarray[5],myarray[4]' echo ::: baz bar foo
echo ${myarray[*]}
echo ${myarray[4]} ${myarray[5]} ${myarray[5]}
echo '### env_parset'
alias myecho='echo myecho "$myvar" "${myarr[1]}"'
myvar="myvar"
myarr=("myarr 0" "myarr 1" "myarr 2")
mynewline="`echo newline1;echo newline2;`"
env_parset arr1 myecho ::: foo bar baz
echo "${arr1[0]} ${arr1[1]} ${arr1[2]}"
env_parset comma3,comma2,comma1 myecho ::: baz bar foo
echo "$comma1 $comma2 $comma3"
env_parset 'space3 space2 space1' myecho ::: baz bar foo
echo "$space1 $space2 $space3"
env_parset 'newline3 newline2 newline1' 'echo "$mynewline";seq' ::: 3 2 1
echo "$newline1"
echo "$newline2"
echo "$newline3"
env_parset 'myarray[6],myarray[5],myarray[4]' myecho ::: baz bar foo
echo "${myarray[*]}"
echo "${myarray[4]} ${myarray[5]} ${myarray[5]}"
echo 'bug #52507: parset arr1 -v echo ::: fails'
parset arr1 -v seq ::: 1 2 3
echo "${arr1[2]}"
}
par_pipe_compress_blocks() {
echo "### bug #41482: --pipe --compress blocks at different -j/seq combinations"
seq 1 | parallel -k -j2 --compress -N1 -L1 --pipe cat
echo echo 1-4 + 1-4
seq 4 | parallel -k -j3 --compress -N1 -L1 -vv echo
echo 4 times wc to stderr to stdout
(seq 4 | parallel -k -j3 --compress -N1 -L1 --pipe wc '>&2') 2>&1 >/dev/null
echo 1 2 3 4
seq 4 | parallel -k -j3 --compress echo
echo 1 2 3 4
seq 4 | parallel -k -j1 --compress echo
echo 1 2
seq 2 | parallel -k -j1 --compress echo
echo 1 2 3
seq 3 | parallel -k -j2 --compress -N1 -L1 --pipe cat
}
export -f $(compgen -A function | grep par_)
compgen -A function | grep par_ | sort |
parallel -j6 --tag -k --joblog +/tmp/jl-`basename $0` '{} 2>&1'