From 7a5c2b205e4f0c3700f41f2ccd2b104476b8f026 Mon Sep 17 00:00:00 2001 From: a1346054 <36859588+a1346054@users.noreply.github.com> Date: Tue, 13 Sep 2022 20:21:21 +0000 Subject: tests: use bash-style [[...]] instead of [...] --- test/compile/compile.sh | 2 +- test/environment/environment.sh | 2 +- test/environment/output.sh | 2 +- test/fcopy/fcopy.sh | 2 +- test/features/test.sh | 4 ++-- test/filters/filters.sh | 22 +++++++++++----------- test/fnetfilter/fnetfilter.sh | 2 +- test/fs/fs.sh | 6 +++--- test/root/root.sh | 10 +++++----- test/utils/utils.sh | 4 ++-- 10 files changed, 28 insertions(+), 28 deletions(-) diff --git a/test/compile/compile.sh b/test/compile/compile.sh index 48c8dd2c4..0285c8935 100755 --- a/test/compile/compile.sh +++ b/test/compile/compile.sh @@ -52,7 +52,7 @@ print_title() { } DIST="$1" -while [ $# -gt 0 ]; do # Until you run out of parameters . . . +while [[ $# -gt 0 ]]; do # Until you run out of parameters . . . case "$1" in --clean) cleanup diff --git a/test/environment/environment.sh b/test/environment/environment.sh index ddc9a80a9..c88c91741 100755 --- a/test/environment/environment.sh +++ b/test/environment/environment.sh @@ -38,7 +38,7 @@ echo "TESTING: environment variables (test/environment/env.exp)" echo "TESTING: firejail in firejail - single sandbox (test/environment/firejail-in-firejail.exp)" ./firejail-in-firejail.exp -if command -v aplay && [ "$(aplay -l | grep -c "List of PLAYBACK")" -gt 0 ]; +if command -v aplay && [[ $(aplay -l | grep -c "List of PLAYBACK") -gt 0 ]] then echo "TESTING: sound (test/environment/sound.exp)" ./sound.exp diff --git a/test/environment/output.sh b/test/environment/output.sh index 0872dc276..ba06f9184 100755 --- a/test/environment/output.sh +++ b/test/environment/output.sh @@ -5,7 +5,7 @@ i="0" -while [ $i -lt 150000 ] +while [[ $i -lt 150000 ]] do echo "message number $i" i=$((i+1)) diff --git a/test/fcopy/fcopy.sh b/test/fcopy/fcopy.sh index 4433f8248..72b87d14c 100755 --- a/test/fcopy/fcopy.sh +++ b/test/fcopy/fcopy.sh @@ -7,7 +7,7 @@ export MALLOC_CHECK_=3 export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) export LC_ALL=C -if [ -f /etc/debian_version ]; then +if [[ -f /etc/debian_version ]]; then libdir=$(dirname "$(dpkg -L firejail | grep fcopy)") export PATH="$PATH:$libdir" fi diff --git a/test/features/test.sh b/test/features/test.sh index aaf5fd089..44677aaa7 100755 --- a/test/features/test.sh +++ b/test/features/test.sh @@ -8,7 +8,7 @@ OVERLAY="overlay" CHROOT="chroot" NETWORK="network" -while [ $# -gt 0 ]; do # Until you run out of parameters . . . +while [[ $# -gt 0 ]]; do # Until you run out of parameters . . . case "$1" in --nooverlay) OVERLAY="none" @@ -61,7 +61,7 @@ echo "TESTING: 1.10 disable /selinux" #################### # networking features #################### -if [ $NETWORK == "network" ] +if [[ $NETWORK == "network" ]] then echo "TESTING: 2.1 hostname" ./2.1.exp "$OVERLAY" "$CHROOT" diff --git a/test/filters/filters.sh b/test/filters/filters.sh index 918f05adc..3b4a6b492 100755 --- a/test/filters/filters.sh +++ b/test/filters/filters.sh @@ -7,23 +7,23 @@ export MALLOC_CHECK_=3 export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) export LC_ALL=C -if [ -f /etc/debian_version ]; then +if [[ -f /etc/debian_version ]]; then libdir=$(dirname "$(dpkg -L firejail | grep fseccomp)") export PATH="$PATH:$libdir" fi export PATH="$PATH:/usr/lib/firejail:/usr/lib64/firejail" -if [ -f /sys/kernel/security/apparmor/profiles ]; then +if [[ -f /sys/kernel/security/apparmor/profiles ]]; then echo "TESTING: apparmor (test/filters/apparmor.exp)" ./apparmor.exp else echo "TESTING SKIP: no apparmor support in Linux kernel (test/filters/apparmor.exp)" fi -if [ "$(uname -m)" = "x86_64" ]; then +if [[ $(uname -m) == "x86_64" ]]; then echo "TESTING: memory-deny-write-execute (test/filters/memwrexe.exp)" ./memwrexe.exp -elif [ "$(uname -m)" = "i686" ]; then +elif [[ $(uname -m) == "i686" ]]; then echo "TESTING: memory-deny-write-execute (test/filters/memwrexe-32.exp)" ./memwrexe-32.exp else @@ -33,7 +33,7 @@ fi echo "TESTING: debug options (test/filters/debug.exp)" ./debug.exp -if [ "$(uname -m)" = "x86_64" ]; then +if [[ $(uname -m) == "x86_64" ]]; then echo "TESTING: seccomp run files (test/filters/seccomp-run-files.exp)" ./seccomp-run-files.exp else @@ -61,7 +61,7 @@ echo "TESTING: capabilities join (test/filters/caps-join.exp)" ./caps-join.exp rm -f seccomp-test-file -if [ "$(uname -m)" = "x86_64" ]; then +if [[ $(uname -m) == "x86_64" ]]; then echo "TESTING: fseccomp (test/filters/fseccomp.exp)" ./fseccomp.exp else @@ -70,7 +70,7 @@ fi rm -f seccomp-test-file -if [ "$(uname -m)" = "x86_64" ]; then +if [[ $(uname -m) == "x86_64" ]]; then echo "TESTING: protocol (test/filters/protocol.exp)" ./protocol.exp else @@ -80,10 +80,10 @@ fi echo "TESTING: seccomp bad empty (test/filters/seccomp-bad-empty.exp)" ./seccomp-bad-empty.exp -if [ "$(uname -m)" = "x86_64" ]; then +if [[ $(uname -m) == "x86_64" ]]; then echo "TESTING: seccomp debug (test/filters/seccomp-debug.exp)" ./seccomp-debug.exp -elif [ "$(uname -m)" = "i686" ]; then +elif [[ $(uname -m) == "i686" ]]; then echo "TESTING: seccomp debug (test/filters/seccomp-debug-32.exp)" ./seccomp-debug-32.exp else @@ -114,14 +114,14 @@ echo "TESTING: seccomp chmod profile - seccomp lists (test/filters/seccomp-chmod echo "TESTING: seccomp empty (test/filters/seccomp-empty.exp)" ./seccomp-empty.exp -if [ "$(uname -m)" = "x86_64" ]; then +if [[ $(uname -m) == "x86_64" ]]; then echo "TESTING: seccomp numeric (test/filters/seccomp-numeric.exp)" ./seccomp-numeric.exp else echo "TESTING SKIP: seccomp numeric test implemented only for x86_64" fi -if [ "$(uname -m)" = "x86_64" ]; then +if [[ $(uname -m) == "x86_64" ]]; then echo "TESTING: seccomp join (test/filters/seccomp-join.exp)" ./seccomp-join.exp else diff --git a/test/fnetfilter/fnetfilter.sh b/test/fnetfilter/fnetfilter.sh index 9ad822753..52f921232 100755 --- a/test/fnetfilter/fnetfilter.sh +++ b/test/fnetfilter/fnetfilter.sh @@ -7,7 +7,7 @@ export MALLOC_CHECK_=3 export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) export LC_ALL=C -if [ -f /etc/debian_version ]; then +if [[ -f /etc/debian_version ]]; then libdir=$(dirname "$(dpkg -L firejail | grep fcopy)") export PATH="$PATH:$libdir" fi diff --git a/test/fs/fs.sh b/test/fs/fs.sh index 07d33bee6..697c86d3d 100755 --- a/test/fs/fs.sh +++ b/test/fs/fs.sh @@ -34,7 +34,7 @@ rm -f ~/_firejail_test_dir echo "TESTING: /sys/fs access (test/fs/sys_fs.exp)" ./sys_fs.exp -if [ -c /dev/kmsg ]; then +if [[ -c /dev/kmsg ]]; then echo "TESTING: kmsg access (test/fs/kmsg.exp)" ./kmsg.exp else @@ -45,7 +45,7 @@ echo "TESTING: read/write /var/tmp (test/fs/fs_var_tmp.exp)" ./fs_var_tmp.exp rm -f /var/tmp/_firejail_test_file -if [ "$(uname -m)" = "x86_64" ]; then +if [[ $(uname -m) == "x86_64" ]]; then fjconfig=/etc/firejail/firejail.config printf 'private-lib yes\n' | sudo tee -a "$fjconfig" >/dev/null echo "TESTING: private-lib (test/fs/private-lib.exp)" @@ -60,7 +60,7 @@ echo "TESTING: read/write /var/lock (test/fs/fs_var_lock.exp)" ./fs_var_lock.exp rm -f /var/lock/_firejail_test_file -if [ -w /dev/shm ]; then +if [[ -w /dev/shm ]]; then echo "TESTING: read/write /dev/shm (test/fs/fs_dev_shm.exp)" ./fs_dev_shm.exp rm -f /dev/shm/_firejail_test_file diff --git a/test/root/root.sh b/test/root/root.sh index 15c4bbd13..a39525b6e 100755 --- a/test/root/root.sh +++ b/test/root/root.sh @@ -24,7 +24,7 @@ fi #******************************** # servers #******************************** -if [ -f /etc/init.d/snmpd ] +if [[ -f /etc/init.d/snmpd ]] then echo "TESTING: snmpd (test/root/snmpd.exp)" ./snmpd.exp @@ -33,7 +33,7 @@ else fi -if [ -f /etc/init.d/apache2 ] +if [[ -f /etc/init.d/apache2 ]] then echo "TESTING: apache2 (test/root/apache2.exp)" ./apache2.exp @@ -41,7 +41,7 @@ else echo "TESTING SKIP: apache2 not found" fi -if [ -f /etc/init.d/isc-dhcp-server ] +if [[ -f /etc/init.d/isc-dhcp-server ]] then echo "TESTING: isc dhcp server (test/root/isc-dhscp.exp)" ./isc-dhcp.exp @@ -49,7 +49,7 @@ else echo "TESTING SKIP: isc dhcp server not found" fi -if [ -f /etc/init.d/unbound ] +if [[ -f /etc/init.d/unbound ]] then echo "TESTING: unbound (test/root/unbound.exp)" ./unbound.exp @@ -57,7 +57,7 @@ else echo "TESTING SKIP: unbound not found" fi -if [ -f /etc/init.d/nginx ] +if [[ -f /etc/init.d/nginx ]] then echo "TESTING: nginx (test/root/nginx.exp)" ./nginx.exp diff --git a/test/utils/utils.sh b/test/utils/utils.sh index d1d006f4f..647cbfb34 100755 --- a/test/utils/utils.sh +++ b/test/utils/utils.sh @@ -7,7 +7,7 @@ export MALLOC_CHECK_=3 export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) export LC_ALL=C -if [ -f /etc/debian_version ]; then +if [[ -f /etc/debian_version ]]; then libdir=$(dirname "$(dpkg -L firejail | grep fcopy)") export PATH="$PATH:$libdir" fi @@ -47,7 +47,7 @@ echo "TESTING: list (test/utils/list.exp)" echo "TESTING: tree (test/utils/tree.exp)" ./tree.exp -if [ $(grep -c ^processor /proc/cpuinfo) -gt 1 ]; +if [[ $(grep -c ^processor /proc/cpuinfo) -gt 1 ]] then echo "TESTING: cpu.print (test/utils/cpu-print.exp)" ./cpu-print.exp -- cgit v1.2.3-54-g00ecf