From 15f23bc6ace0c204ec79dc903e9bd6b39dc3b479 Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Tue, 6 Dec 2016 12:10:32 +0100 Subject: [PATCH] test: fix apparmor detection Signed-off-by: Antonio Murdaca --- test/apparmor.bats | 8 ++++---- test/helpers.bash | 12 ++++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/test/apparmor.bats b/test/apparmor.bats index 97e9ac9d..d4300c92 100644 --- a/test/apparmor.bats +++ b/test/apparmor.bats @@ -16,7 +16,7 @@ function teardown() { # this test requires apparmor, so skip this test if apparmor is not enabled. enabled=is_apparmor_enabled - if [[ "$enabled" =~ "0" ]]; then + if [[ "$enabled" = "0" ]]; then skip "skip this test since apparmor is not enabled." fi @@ -53,7 +53,7 @@ function teardown() { # this test requires apparmor, so skip this test if apparmor is not enabled. enabled=is_apparmor_enabled - if [[ "$enabled" =~ "0" ]]; then + if [[ "$enabled" -eq "0" ]]; then skip "skip this test since apparmor is not enabled." fi @@ -92,7 +92,7 @@ function teardown() { # this test requires apparmor, so skip this test if apparmor is not enabled. enabled=is_apparmor_enabled - if [[ "$enabled" =~ "0" ]]; then + if [[ "$enabled" -eq "0" ]]; then skip "skip this test since apparmor is not enabled." fi @@ -131,7 +131,7 @@ function teardown() { # this test requires apparmor, so skip this test if apparmor is not enabled. enabled=is_apparmor_enabled - if [[ "$enabled" =~ "0" ]]; then + if [[ "$enabled" -eq "0" ]]; then skip "skip this test since apparmor is not enabled." fi diff --git a/test/helpers.bash b/test/helpers.bash index 9db9e839..3d61d1a5 100644 --- a/test/helpers.bash +++ b/test/helpers.bash @@ -161,12 +161,10 @@ function is_seccomp_enabled() { out=$(cat "$BOOT_CONFIG_FILE_PATH" | grep CONFIG_SECCOMP=) if [[ "$out" =~ "CONFIG_SECCOMP=y" ]]; then echo 1 - else - echo 0 + return fi - else - echo 0 fi + echo 0 } function is_apparmor_enabled() { @@ -174,10 +172,8 @@ function is_apparmor_enabled() { out=$(cat "$APPARMOR_PARAMETERS_FILE_PATH") if [[ "$out" =~ "Y" ]]; then echo 1 - else - echo 0 + return fi - else - echo 0 fi + echo 0 }