aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLibravatar a1346054 <36859588+a1346054@users.noreply.github.com>2022-09-13 18:42:15 +0000
committerLibravatar a1346054 <36859588+a1346054@users.noreply.github.com>2022-09-13 22:37:18 +0000
commite04d6b7bf58a95105a8fc79fcde7c0e98875e72a (patch)
tree6e20913ed5d4af3e1b0ef5a31ef80ee42f651376 /test
parenttests: fix unintentional overwriting of array value (diff)
downloadfirejail-e04d6b7bf58a95105a8fc79fcde7c0e98875e72a.tar.gz
firejail-e04d6b7bf58a95105a8fc79fcde7c0e98875e72a.tar.zst
firejail-e04d6b7bf58a95105a8fc79fcde7c0e98875e72a.zip
tests: directly test for presence of command
Test directly for presence of command instead of indirectly testing the return code. Additionally: * uses a shell builtin `command -v` instead of external `which` * `command -v` is the standardized version of `which`
Diffstat (limited to 'test')
-rwxr-xr-xtest/apps-x11-xorg/apps-x11-xorg.sh12
-rwxr-xr-xtest/apps-x11/apps-x11.sh27
-rwxr-xr-xtest/apps/apps.sh3
-rwxr-xr-xtest/environment/environment.sh9
-rwxr-xr-xtest/filters/filters.sh3
-rwxr-xr-xtest/overlay/overlay.sh15
-rwxr-xr-xtest/private-lib/private-lib.sh3
-rwxr-xr-xtest/root/root.sh3
-rwxr-xr-xtest/sysutils/sysutils.sh27
-rwxr-xr-xtest/utils/utils.sh3
10 files changed, 35 insertions, 70 deletions
diff --git a/test/apps-x11-xorg/apps-x11-xorg.sh b/test/apps-x11-xorg/apps-x11-xorg.sh
index 9ed123979..9dcee7aff 100755
--- a/test/apps-x11-xorg/apps-x11-xorg.sh
+++ b/test/apps-x11-xorg/apps-x11-xorg.sh
@@ -7,8 +7,7 @@ export MALLOC_CHECK_=3
7export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) 7export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
8export LC_ALL=C 8export LC_ALL=C
9 9
10which firefox 2>/dev/null 10if command -v firefox
11if [ "$?" -eq 0 ];
12then 11then
13 echo "TESTING: firefox x11 xorg" 12 echo "TESTING: firefox x11 xorg"
14 ./firefox.exp 13 ./firefox.exp
@@ -16,8 +15,7 @@ else
16 echo "TESTING SKIP: firefox not found" 15 echo "TESTING SKIP: firefox not found"
17fi 16fi
18 17
19which transmission-gtk 2>/dev/null 18if command -v transmission-gtk
20if [ "$?" -eq 0 ];
21then 19then
22 echo "TESTING: transmission-gtk x11 xorg" 20 echo "TESTING: transmission-gtk x11 xorg"
23 ./transmission-gtk.exp 21 ./transmission-gtk.exp
@@ -25,8 +23,7 @@ else
25 echo "TESTING SKIP: transmission-gtk not found" 23 echo "TESTING SKIP: transmission-gtk not found"
26fi 24fi
27 25
28which transmission-qt 2>/dev/null 26if command -v transmission-qt
29if [ "$?" -eq 0 ];
30then 27then
31 echo "TESTING: transmission-qt x11 xorg" 28 echo "TESTING: transmission-qt x11 xorg"
32 ./transmission-qt.exp 29 ./transmission-qt.exp
@@ -34,8 +31,7 @@ else
34 echo "TESTING SKIP: transmission-qt not found" 31 echo "TESTING SKIP: transmission-qt not found"
35fi 32fi
36 33
37which thunderbird 2>/dev/null 34if command -v thunderbird
38if [ "$?" -eq 0 ];
39then 35then
40 echo "TESTING: thunderbird x11 xorg" 36 echo "TESTING: thunderbird x11 xorg"
41 ./thunderbird.exp 37 ./thunderbird.exp
diff --git a/test/apps-x11/apps-x11.sh b/test/apps-x11/apps-x11.sh
index a3c946ca4..9f8102738 100755
--- a/test/apps-x11/apps-x11.sh
+++ b/test/apps-x11/apps-x11.sh
@@ -11,21 +11,18 @@ echo "TESTING: no x11 (test/apps-x11/x11-none.exp)"
11./x11-none.exp 11./x11-none.exp
12 12
13 13
14which xterm 2>/dev/null 14if command -v xterm
15if [ "$?" -eq 0 ];
16then 15then
17 echo "TESTING: xterm x11 xorg" 16 echo "TESTING: xterm x11 xorg"
18 ./xterm-xorg.exp 17 ./xterm-xorg.exp
19 18
20 which xpra 2>/dev/null 19 if command -v xpra
21 if [ "$?" -eq 0 ];
22 then 20 then
23 echo "TESTING: xterm x11 xpra" 21 echo "TESTING: xterm x11 xpra"
24 ./xterm-xpra.exp 22 ./xterm-xpra.exp
25 fi 23 fi
26 24
27 which Xephyr 2>/dev/null 25 if command -v Xephyr
28 if [ "$?" -eq 0 ];
29 then 26 then
30 echo "TESTING: xterm x11 xephyr" 27 echo "TESTING: xterm x11 xephyr"
31 ./xterm-xephyr.exp 28 ./xterm-xephyr.exp
@@ -35,14 +32,12 @@ else
35fi 32fi
36 33
37# check xpra/xephyr 34# check xpra/xephyr
38which xpra 2>/dev/null 35if command -v xpra
39if [ "$?" -eq 0 ];
40then 36then
41 echo "xpra found" 37 echo "xpra found"
42else 38else
43 echo "xpra not found" 39 echo "xpra not found"
44 which Xephyr 2>/dev/null 40 if command -v Xephyr
45 if [ "$?" -eq 0 ];
46 then 41 then
47 echo "Xephyr found" 42 echo "Xephyr found"
48 else 43 else
@@ -51,8 +46,7 @@ else
51 fi 46 fi
52fi 47fi
53 48
54which firefox 2>/dev/null 49if command -v firefox
55if [ "$?" -eq 0 ];
56then 50then
57 echo "TESTING: firefox x11" 51 echo "TESTING: firefox x11"
58 ./firefox.exp 52 ./firefox.exp
@@ -60,8 +54,7 @@ else
60 echo "TESTING SKIP: firefox not found" 54 echo "TESTING SKIP: firefox not found"
61fi 55fi
62 56
63which chromium 2>/dev/null 57if command -v chromium
64if [ "$?" -eq 0 ];
65then 58then
66 echo "TESTING: chromium x11" 59 echo "TESTING: chromium x11"
67 ./chromium.exp 60 ./chromium.exp
@@ -69,8 +62,7 @@ else
69 echo "TESTING SKIP: chromium not found" 62 echo "TESTING SKIP: chromium not found"
70fi 63fi
71 64
72which transmission-gtk 2>/dev/null 65if command -v transmission-gtk
73if [ "$?" -eq 0 ];
74then 66then
75 echo "TESTING: transmission-gtk x11" 67 echo "TESTING: transmission-gtk x11"
76 ./transmission-gtk.exp 68 ./transmission-gtk.exp
@@ -78,8 +70,7 @@ else
78 echo "TESTING SKIP: transmission-gtk not found" 70 echo "TESTING SKIP: transmission-gtk not found"
79fi 71fi
80 72
81which thunderbird 2>/dev/null 73if command -v thunderbird
82if [ "$?" -eq 0 ];
83then 74then
84 echo "TESTING: thunderbird x11" 75 echo "TESTING: thunderbird x11"
85 ./thunderbird.exp 76 ./thunderbird.exp
diff --git a/test/apps/apps.sh b/test/apps/apps.sh
index 83e977ba0..ed4b7604a 100755
--- a/test/apps/apps.sh
+++ b/test/apps/apps.sh
@@ -11,8 +11,7 @@ LIST="firefox midori chromium opera transmission-qt qbittorrent uget-gtk filezil
11LIST+="vlc fbreader deluge gnome-mplayer xchat wine kcalc ktorrent hexchat" 11LIST+="vlc fbreader deluge gnome-mplayer xchat wine kcalc ktorrent hexchat"
12 12
13for app in $LIST; do 13for app in $LIST; do
14 which $app 2>/dev/null 14 if command -v "$app"
15 if [ "$?" -eq 0 ];
16 then 15 then
17 echo "TESTING: $app" 16 echo "TESTING: $app"
18 ./$app.exp 17 ./$app.exp
diff --git a/test/environment/environment.sh b/test/environment/environment.sh
index da9c170b9..f6acada73 100755
--- a/test/environment/environment.sh
+++ b/test/environment/environment.sh
@@ -39,8 +39,7 @@ echo "TESTING: environment variables (test/environment/env.exp)"
39echo "TESTING: firejail in firejail - single sandbox (test/environment/firejail-in-firejail.exp)" 39echo "TESTING: firejail in firejail - single sandbox (test/environment/firejail-in-firejail.exp)"
40./firejail-in-firejail.exp 40./firejail-in-firejail.exp
41 41
42which aplay 2>/dev/null 42if command -v aplay && [ "$(aplay -l | grep -c "List of PLAYBACK")" -gt 0 ];
43if [ "$?" -eq 0 ] && [ "$(aplay -l | grep -c "List of PLAYBACK")" -gt 0 ];
44then 43then
45 echo "TESTING: sound (test/environment/sound.exp)" 44 echo "TESTING: sound (test/environment/sound.exp)"
46 ./sound.exp 45 ./sound.exp
@@ -54,8 +53,7 @@ echo "TESTING: nice (test/environment/nice.exp)"
54echo "TESTING: quiet (test/environment/quiet.exp)" 53echo "TESTING: quiet (test/environment/quiet.exp)"
55./quiet.exp 54./quiet.exp
56 55
57which strace 2>/dev/null 56if command -v strace
58if [ "$?" -eq 0 ];
59then 57then
60 echo "TESTING: --allow-debuggers (test/environment/allow-debuggers.exp)" 58 echo "TESTING: --allow-debuggers (test/environment/allow-debuggers.exp)"
61 ./allow-debuggers.exp 59 ./allow-debuggers.exp
@@ -67,8 +65,7 @@ fi
67# $ sudo apt-get install ibus-table-array30 65# $ sudo apt-get install ibus-table-array30
68# $ ibus-setup 66# $ ibus-setup
69 67
70find ~/.config/ibus/bus | grep unix-0 68if find ~/.config/ibus/bus | grep unix-0
71if [ "$?" -eq 0 ];
72then 69then
73 echo "TESTING: ibus (test/environment/ibus.exp)" 70 echo "TESTING: ibus (test/environment/ibus.exp)"
74 ./ibus.exp 71 ./ibus.exp
diff --git a/test/filters/filters.sh b/test/filters/filters.sh
index 04d7080d6..1c6b812ff 100755
--- a/test/filters/filters.sh
+++ b/test/filters/filters.sh
@@ -96,8 +96,7 @@ echo "TESTING: seccomp errno (test/filters/seccomp-errno.exp)"
96echo "TESTING: seccomp su (test/filters/seccomp-su.exp)" 96echo "TESTING: seccomp su (test/filters/seccomp-su.exp)"
97./seccomp-su.exp 97./seccomp-su.exp
98 98
99which strace 2>/dev/null 99if command -v strace; then
100if [ $? -eq 0 ]; then
101 echo "TESTING: seccomp ptrace (test/filters/seccomp-ptrace.exp)" 100 echo "TESTING: seccomp ptrace (test/filters/seccomp-ptrace.exp)"
102 ./seccomp-ptrace.exp 101 ./seccomp-ptrace.exp
103else 102else
diff --git a/test/overlay/overlay.sh b/test/overlay/overlay.sh
index 490b180e1..9bc458f50 100755
--- a/test/overlay/overlay.sh
+++ b/test/overlay/overlay.sh
@@ -22,8 +22,7 @@ rm -fr ~/_firejail_test_*
22./fs-tmpfs.exp 22./fs-tmpfs.exp
23rm -fr ~/_firejail_test_* 23rm -fr ~/_firejail_test_*
24 24
25which firefox 2>/dev/null 25if command -v firefox
26if [ "$?" -eq 0 ];
27then 26then
28 echo "TESTING: overlay firefox" 27 echo "TESTING: overlay firefox"
29 ./firefox.exp 28 ./firefox.exp
@@ -31,8 +30,7 @@ else
31 echo "TESTING SKIP: firefox not found" 30 echo "TESTING SKIP: firefox not found"
32fi 31fi
33 32
34which firefox 2>/dev/null 33if command -v firefox
35if [ "$?" -eq 0 ];
36then 34then
37 echo "TESTING: overlay firefox x11 xorg" 35 echo "TESTING: overlay firefox x11 xorg"
38 ./firefox.exp 36 ./firefox.exp
@@ -42,14 +40,12 @@ fi
42 40
43 41
44# check xpra/xephyr 42# check xpra/xephyr
45which xpra 2>/dev/null 43if command -v xpra
46if [ "$?" -eq 0 ];
47then 44then
48 echo "xpra found" 45 echo "xpra found"
49else 46else
50 echo "xpra not found" 47 echo "xpra not found"
51 which Xephyr 2>/dev/null 48 if command -v Xephyr
52 if [ "$?" -eq 0 ];
53 then 49 then
54 echo "Xephyr found" 50 echo "Xephyr found"
55 else 51 else
@@ -58,8 +54,7 @@ else
58 fi 54 fi
59fi 55fi
60 56
61which firefox 2>/dev/null 57if command -v firefox
62if [ "$?" -eq 0 ];
63then 58then
64 echo "TESTING: overlay firefox x11" 59 echo "TESTING: overlay firefox x11"
65 ./firefox-x11.exp 60 ./firefox-x11.exp
diff --git a/test/private-lib/private-lib.sh b/test/private-lib/private-lib.sh
index d168c2b1b..86ed7b06d 100755
--- a/test/private-lib/private-lib.sh
+++ b/test/private-lib/private-lib.sh
@@ -11,8 +11,7 @@ LIST="gnome-logs gnome-system-log gnome-nettool pavucontrol dig evince whois gal
11 11
12 12
13for app in $LIST; do 13for app in $LIST; do
14 which $app 2>/dev/null 14 if command -v "$app"
15 if [ "$?" -eq 0 ];
16 then 15 then
17 echo "TESTING: private-lib $app" 16 echo "TESTING: private-lib $app"
18 ./$app.exp 17 ./$app.exp
diff --git a/test/root/root.sh b/test/root/root.sh
index e8c0ec1ac..e3b48d15b 100755
--- a/test/root/root.sh
+++ b/test/root/root.sh
@@ -11,8 +11,7 @@ export LC_ALL=C
11#******************************** 11#********************************
12# firecfg 12# firecfg
13#******************************** 13#********************************
14which less 2>/dev/null 14if command -v less
15if [ "$?" -eq 0 ];
16then 15then
17 echo "TESTING: firecfg (test/root/firecfg.exp)" 16 echo "TESTING: firecfg (test/root/firecfg.exp)"
18 mv /home/netblue/.local/share/applications /home/netblue/.local/share/applications-store 17 mv /home/netblue/.local/share/applications /home/netblue/.local/share/applications-store
diff --git a/test/sysutils/sysutils.sh b/test/sysutils/sysutils.sh
index a903c7c6b..bfe723047 100755
--- a/test/sysutils/sysutils.sh
+++ b/test/sysutils/sysutils.sh
@@ -7,8 +7,7 @@ export MALLOC_CHECK_=3
7export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) 7export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
8export LC_ALL=C 8export LC_ALL=C
9 9
10which cpio 2>/dev/null 10if command -v cpio
11if [ "$?" -eq 0 ];
12then 11then
13 echo "TESTING: cpio" 12 echo "TESTING: cpio"
14 ./cpio.exp 13 ./cpio.exp
@@ -16,8 +15,7 @@ else
16 echo "TESTING SKIP: cpio not found" 15 echo "TESTING SKIP: cpio not found"
17fi 16fi
18 17
19#which strings 18#if command -v strings
20#if [ "$?" -eq 0 ];
21#then 19#then
22# echo "TESTING: strings" 20# echo "TESTING: strings"
23# ./strings.exp 21# ./strings.exp
@@ -25,8 +23,7 @@ fi
25# echo "TESTING SKIP: strings not found" 23# echo "TESTING SKIP: strings not found"
26#fi 24#fi
27 25
28which gzip 2>/dev/null 26if command -v gzip
29if [ "$?" -eq 0 ];
30then 27then
31 echo "TESTING: gzip" 28 echo "TESTING: gzip"
32 ./gzip.exp 29 ./gzip.exp
@@ -34,8 +31,7 @@ else
34 echo "TESTING SKIP: gzip not found" 31 echo "TESTING SKIP: gzip not found"
35fi 32fi
36 33
37which xzdec 2>/dev/null 34if command -v xzdec
38if [ "$?" -eq 0 ];
39then 35then
40 echo "TESTING: xzdec" 36 echo "TESTING: xzdec"
41 ./xzdec.exp 37 ./xzdec.exp
@@ -43,8 +39,7 @@ else
43 echo "TESTING SKIP: xzdec not found" 39 echo "TESTING SKIP: xzdec not found"
44fi 40fi
45 41
46which xz 2>/dev/null 42if command -v xz
47if [ "$?" -eq 0 ];
48then 43then
49 echo "TESTING: xz" 44 echo "TESTING: xz"
50 ./xz.exp 45 ./xz.exp
@@ -52,8 +47,7 @@ else
52 echo "TESTING SKIP: xz not found" 47 echo "TESTING SKIP: xz not found"
53fi 48fi
54 49
55which less 2>/dev/null 50if command -v less
56if [ "$?" -eq 0 ];
57then 51then
58 echo "TESTING: less" 52 echo "TESTING: less"
59 ./less.exp 53 ./less.exp
@@ -61,8 +55,7 @@ else
61 echo "TESTING SKIP: less not found" 55 echo "TESTING SKIP: less not found"
62fi 56fi
63 57
64which file 2>/dev/null 58if command -v file
65if [ "$?" -eq 0 ];
66then 59then
67 echo "TESTING: file" 60 echo "TESTING: file"
68 ./file.exp 61 ./file.exp
@@ -70,8 +63,7 @@ else
70 echo "TESTING SKIP: file not found" 63 echo "TESTING SKIP: file not found"
71fi 64fi
72 65
73which tar 2>/dev/null 66if command -v tar
74if [ "$?" -eq 0 ];
75then 67then
76 echo "TESTING: tar" 68 echo "TESTING: tar"
77 ./tar.exp 69 ./tar.exp
@@ -79,8 +71,7 @@ else
79 echo "TESTING SKIP: tar not found" 71 echo "TESTING SKIP: tar not found"
80fi 72fi
81 73
82which ping 2>/dev/null 74if command -v ping
83if [ "$?" -eq 0 ];
84then 75then
85 echo "TESTING: ping" 76 echo "TESTING: ping"
86 ./ping.exp 77 ./ping.exp
diff --git a/test/utils/utils.sh b/test/utils/utils.sh
index 102c8df17..ad36d7053 100755
--- a/test/utils/utils.sh
+++ b/test/utils/utils.sh
@@ -33,8 +33,7 @@ echo "TESTING: version (test/utils/version.exp)"
33echo "TESTING: help (test/utils/help.exp)" 33echo "TESTING: help (test/utils/help.exp)"
34./help.exp 34./help.exp
35 35
36which man 2>/dev/null 36if command -v man
37if [ "$?" -eq 0 ];
38then 37then
39 echo "TESTING: man (test/utils/man.exp)" 38 echo "TESTING: man (test/utils/man.exp)"
40 ./man.exp 39 ./man.exp