2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-31 06:16:03 +00:00

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 <georgia.garcia@canonical.com>
This commit is contained in:
Georgia Garcia
2023-07-18 17:58:54 -03:00
parent b6bd4f5421
commit 81f0b84da5

View File

@@ -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