From 435bcefa480e1b36e2298f863c1bb722b0adf7f4 Mon Sep 17 00:00:00 2001 From: Albert S Date: Sat, 20 Nov 2021 17:03:04 +0100 Subject: [PATCH] test: Skip landlock specific tests if unavailble during compile time --- test.c | 12 ++++++++++++ test.sh | 18 +++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/test.c b/test.c index 0c36927..4f2f1ef 100644 --- a/test.c +++ b/test.c @@ -199,6 +199,7 @@ static int test_seccomp_group() return 0; } +#if HAVE_LANDLOCK == 1 int test_landlock() { struct qssb_policy *policy = qssb_init_policy(); @@ -226,6 +227,17 @@ int test_landlock_deny_write() } return 1; } +#else +int test_landlock() +{ + return 2; +} + +int test_landlock_deny_write() +{ + return 2; +} +#endif int test_nofs() { diff --git a/test.sh b/test.sh index 19d57ce..d1e76da 100755 --- a/test.sh +++ b/test.sh @@ -1,10 +1,12 @@ #!/bin/sh GREEN='\033[0;32m' RED='\033[0;31m' +YELLOW='\033[1;33m' NC='\033[0m' COUNT_SUCCEEDED=0 COUNT_FAILED=0 +COUNT_SKIPPED=0 function print_fail() { @@ -16,6 +18,11 @@ function print_success() echo -e "${GREEN}$@${NC}" } +function print_skipped() +{ + echo -e "${YELLOW}$@${NC}" +} + function runtest_fail() { print_fail "failed" @@ -28,6 +35,12 @@ function runtest_success() COUNT_SUCCEEDED=$((COUNT_SUCCEEDED+1)) } +function runtest_skipped() +{ + print_skipped "skipped" + COUNT_SKIPPED=$((COUNT_SKIPPED+1)) +} + function runtest() { @@ -44,6 +57,9 @@ function runtest() if [ $ret -eq 0 ] ; then runtest_success SUCCESS="yes" + elif [ $ret -eq 2 ] ; then + runtest_skipped + SUCCESS="skipped" else runtest_fail fi @@ -69,7 +85,7 @@ echo echo "Tests finished. Logs in $(realpath ${LOG_OUTPUT_DIR_PATH})" echo "Succeeded: $COUNT_SUCCEEDED" echo "Failed: $COUNT_FAILED" - +echo "Skipped: $COUNT_SKIPPED" if [ $COUNT_FAILED -gt 0 ] ; then exit 1