Released as 20231022 ('Al-Aqsa Deluge')
[parallel.git] / testsuite / tests-to-run / parallel-freebsd.sh
blobff1e91d3a4948f3d5efd06e75192779fbeaf1a3f
1 #!/bin/bash
3 # SPDX-FileCopyrightText: 2021-2023 Ole Tange, http://ole.tange.dk and Free Software and Foundation, Inc.
5 # SPDX-License-Identifier: GPL-3.0-or-later
7 echo "### These tests requires VirtualBox running with the following images"
8 SERVER1=freebsd12
9 SSHUSER1=vagrant
10 SSHLOGIN1=$SSHUSER1@$SERVER1
11 echo $SSHUSER1@$SERVER1
13 ssh $SSHLOGIN1 touch .parallel/will-cite
15 pwd=$(pwd)
16 # If not run in dir parallel/testsuite: set testsuitedir to path of testsuite
17 testsuitedir=${testsuitedir:-$pwd}
18 cd $testsuitedir
19 scp -q "$testsuitedir"/../src/{parallel,sem,sql,niceload,env_parallel*} $SSHLOGIN1:bin/
21 . `which env_parallel.bash`
22 env_parallel --session
24 par_no_more_procs() {
25 echo 'bug #40136: FreeBSD: No more processes'
26 sem --jobs 3 --id my_id -u 'echo First started; sleep 10; echo The first finished;echo' &&
27 sem --jobs 3 --id my_id -u 'echo Second started; sleep 11; echo The second finished;echo' &&
28 sem --jobs 3 --id my_id -u 'echo Third started; sleep 12; echo The third finished;echo' &&
29 sem --jobs 3 --id my_id -u 'echo Fourth started; sleep 13; echo The fourth finished;echo' &&
30 sem --wait --id my_id
33 par_compress_pipe() {
34 echo 'Test --compress --pipe'
35 jot 1000 | parallel --compress --pipe cat | wc
37 echo 'bug #41613: --compress --line-buffer no newline'
38 perl -e 'print "It worked"'| parallel --pipe --compress --line-buffer cat
39 echo
42 par_sem_fg() {
43 echo 'bug #40135: FreeBSD: sem --fg does not finish under /bin/sh'
44 sem --fg 'sleep 1; echo The job finished'
47 par_round_robin() {
48 echo 'bug #40133: FreeBSD: --round-robin gives no output'
49 jot 1000000 | parallel --round-robin --pipe -kj3 cat | wc
50 jot 1000000 | parallel --round-robin --pipe -kj4 cat | wc
53 par_shebang() {
54 echo 'bug #40134: FreeBSD: --shebang not working'
55 (echo '#!/usr/bin/env -S parallel --shebang -rk echo'
56 echo It
57 echo worked) > shebang
58 chmod 755 ./shebang; ./shebang
60 echo 'bug #40134: FreeBSD: --shebang(-wrap) not working'
61 (echo '#!/usr/bin/env -S parallel --shebang-wrap /usr/local/bin/perl :::';
62 echo 'print @ARGV,"\n";') > shebang-wrap
63 chmod 755 ./shebang-wrap
64 ./shebang-wrap wrap works | sort -r
66 echo 'bug #40134: FreeBSD: --shebang(-wrap) with options not working'
67 (echo '#!/usr/bin/env -S parallel --shebang-wrap -v -k -j 0 /usr/local/bin/perl -w :::'
68 echo 'print @ARGV,"\n";') > shebang-wrap-opt;
69 chmod 755 ./shebang-wrap-opt
70 ./shebang-wrap-opt wrap works with options
73 par_load() {
74 echo '### Test --load (must give 1=true)'
75 parallel -j0 -N0 --timeout 5 --nice 10 'bzip2 < /dev/zero >/dev/null' ::: 1 2 3 4 5 6 &
76 parallel --argsep ,, --joblog - -N0 parallel --load 100% echo ::: 1 ,, 1 |
77 # Must take > 5 sec
78 parallel -k --colsep '\t' --header : echo '{=4 $_=$_>5=}'
81 par_env_parallel() {
82 echo "### env_parallel on Freebsd"
83 . bin/env_parallel.sh
84 myvar="`echo 'myvar_line 1'; echo 'myvar_line 2'`"
85 alias myalias='echo myalias1 "$myvar";'"`echo` echo myalias2"
86 env_parallel myalias ::: foo
89 # Moving the functions to FreeBSD is a bit tricky:
90 # We use env_parallel.bash to copy the functions to FreeBSD
92 . `which env_parallel.bash`
94 # GNU/Linux runs bash, but the FreeBSD runs (a)sh,
95 # (a)sh does not support 'export -f' so any function exported
96 # must be unset
98 unset replace_tmpdir
99 unset run_once
100 unset run_test
101 unset TMPDIR
103 # As the copied environment is written in Bash dialect
104 # we get 'shopt'-errors and 'declare'-errors.
105 # We can safely ignore those.
107 export LC_ALL=C
108 PARALLEL_SHELL=sh env_parallel --timeout 100 --env _ -vj4 -k --joblog /tmp/jl-`basename $0` --retries 3 \
109 -S $SSHLOGIN1 --tag '{} 2>&1' \
110 ::: $(compgen -A function | grep par_ | sort) \
111 2> >(grep -Ev 'shopt: not found|declare: not found')