diff options
author | 2022-09-13 18:42:15 +0000 | |
---|---|---|
committer | 2022-09-13 22:37:18 +0000 | |
commit | e04d6b7bf58a95105a8fc79fcde7c0e98875e72a (patch) | |
tree | 6e20913ed5d4af3e1b0ef5a31ef80ee42f651376 /test/sysutils/sysutils.sh | |
parent | tests: fix unintentional overwriting of array value (diff) | |
download | firejail-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/sysutils/sysutils.sh')
-rwxr-xr-x | test/sysutils/sysutils.sh | 27 |
1 files changed, 9 insertions, 18 deletions
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 | |||
7 | export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) | 7 | export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) |
8 | export LC_ALL=C | 8 | export LC_ALL=C |
9 | 9 | ||
10 | which cpio 2>/dev/null | 10 | if command -v cpio |
11 | if [ "$?" -eq 0 ]; | ||
12 | then | 11 | then |
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" |
17 | fi | 16 | fi |
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 | ||
28 | which gzip 2>/dev/null | 26 | if command -v gzip |
29 | if [ "$?" -eq 0 ]; | ||
30 | then | 27 | then |
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" |
35 | fi | 32 | fi |
36 | 33 | ||
37 | which xzdec 2>/dev/null | 34 | if command -v xzdec |
38 | if [ "$?" -eq 0 ]; | ||
39 | then | 35 | then |
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" |
44 | fi | 40 | fi |
45 | 41 | ||
46 | which xz 2>/dev/null | 42 | if command -v xz |
47 | if [ "$?" -eq 0 ]; | ||
48 | then | 43 | then |
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" |
53 | fi | 48 | fi |
54 | 49 | ||
55 | which less 2>/dev/null | 50 | if command -v less |
56 | if [ "$?" -eq 0 ]; | ||
57 | then | 51 | then |
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" |
62 | fi | 56 | fi |
63 | 57 | ||
64 | which file 2>/dev/null | 58 | if command -v file |
65 | if [ "$?" -eq 0 ]; | ||
66 | then | 59 | then |
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" |
71 | fi | 64 | fi |
72 | 65 | ||
73 | which tar 2>/dev/null | 66 | if command -v tar |
74 | if [ "$?" -eq 0 ]; | ||
75 | then | 67 | then |
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" |
80 | fi | 72 | fi |
81 | 73 | ||
82 | which ping 2>/dev/null | 74 | if command -v ping |
83 | if [ "$?" -eq 0 ]; | ||
84 | then | 75 | then |
85 | echo "TESTING: ping" | 76 | echo "TESTING: ping" |
86 | ./ping.exp | 77 | ./ping.exp |