From 81f0b84da516c0f5511c8ea7a958e7ca795331f7 Mon Sep 17 00:00:00 2001 From: Georgia Garcia Date: Tue, 18 Jul 2023 17:58:54 -0300 Subject: [PATCH] tests: fix feature checking if it's a directory The test to check if the kernel supports a feature covers two cases: 1. The file/directory indicates a feature is supported. 2. The feature is supported if it's in the contents of the file. When the intended check is for case 1, and the file does not exist, then the code checks if it's case 2, but since it was not supposed to be, we end up grepping a directory, causing an error message. Fix this by checking if we're grepping a file. Signed-off-by: Georgia Garcia --- tests/regression/apparmor/prologue.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/regression/apparmor/prologue.inc b/tests/regression/apparmor/prologue.inc index bd04ebb48..b4e2dd59c 100755 --- a/tests/regression/apparmor/prologue.inc +++ b/tests/regression/apparmor/prologue.inc @@ -70,7 +70,7 @@ kernel_features() # check if feature is in file feature=$(basename "$features_dir/$f") file=$(dirname "$features_dir/$f") - if ! grep -q $feature $file; then + if [ -f $file ] && ! grep -q $feature $file; then echo "Required feature '$f' not available." return 2; fi