sysctl: Add a selftest for handling empty dirs

Basic test to ensure that empty directories can be registered and that
they in turn can serve as a base dir for other registrations.

Add one test to the sysctl selftest module. It first registers an empty
directory under "empty_add" and then uses that as a base to register
another empty dir.
The sysctl bash script then checks that "empty_add" is present and that
there an empty directory within it.

Signed-off-by: Joel Granados <j.granados@samsung.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
This commit is contained in:
Joel Granados
2023-11-21 12:02:19 +01:00
committed by Luis Chamberlain
parent 315552310c
commit 777740779e
2 changed files with 52 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ ALL_TESTS="$ALL_TESTS 0007:1:1:boot_int:1"
ALL_TESTS="$ALL_TESTS 0008:1:1:match_int:1"
ALL_TESTS="$ALL_TESTS 0009:1:1:unregister_error:0"
ALL_TESTS="$ALL_TESTS 0010:1:1:mnt/mnt_error:0"
ALL_TESTS="$ALL_TESTS 0011:1:1:empty_add:0"
function allow_user_defaults()
{
@@ -828,6 +829,27 @@ sysctl_test_0010()
return 0
}
sysctl_test_0011()
{
TARGET="${SYSCTL}/$(get_test_target 0011)"
echo -n "Testing empty dir handling in ${TARGET} ... "
if [ ! -d ${TARGET} ]; then
echo -e "FAIL\nCould not create ${TARGET}" >&2
rc=1
test_rc
fi
TARGET2="${TARGET}/empty"
if [ ! -d ${TARGET2} ]; then
echo -e "FAIL\nCould not create ${TARGET2}" >&2
rc=1
test_rc
fi
echo "OK"
return 0
}
list_tests()
{
echo "Test ID list:"
@@ -846,6 +868,7 @@ list_tests()
echo "0008 x $(get_test_count 0008) - tests sysctl macro values match"
echo "0009 x $(get_test_count 0009) - tests sysct unregister"
echo "0010 x $(get_test_count 0010) - tests sysct mount point"
echo "0011 x $(get_test_count 0011) - tests empty directories"
}
usage()