Commit f2e7a626 authored by Joel Granados's avatar Joel Granados Committed by Luis Chamberlain

test_sysclt: Test for registering a mount point

Test that target gets created by register_sysctl_mount_point and that no
additional target can be created "on top" of a permanently empty sysctl
table.

Create a mount point target (mnt) in the sysctl test driver; try to
create another on top of that (mnt_error). Output an error if
"mnt_error" is present when we run the sysctl selftests.
Signed-off-by: default avatarJoel Granados <j.granados@samsung.com>
Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
parent ec866cc6
...@@ -30,6 +30,13 @@ static int i_zero; ...@@ -30,6 +30,13 @@ static int i_zero;
static int i_one_hundred = 100; static int i_one_hundred = 100;
static int match_int_ok = 1; static int match_int_ok = 1;
static struct {
struct ctl_table_header *test_h_setup_node;
struct ctl_table_header *test_h_mnt;
struct ctl_table_header *test_h_mnterror;
} sysctl_test_headers;
struct test_sysctl_data { struct test_sysctl_data {
int int_0001; int int_0001;
int int_0002; int int_0002;
...@@ -153,16 +160,14 @@ static void test_sysctl_calc_match_int_ok(void) ...@@ -153,16 +160,14 @@ static void test_sysctl_calc_match_int_ok(void)
match_int_ok = 0; match_int_ok = 0;
} }
static struct ctl_table_header *test_sysctl_header;
static int test_sysctl_setup_node_tests(void) static int test_sysctl_setup_node_tests(void)
{ {
test_sysctl_calc_match_int_ok(); test_sysctl_calc_match_int_ok();
test_data.bitmap_0001 = kzalloc(SYSCTL_TEST_BITMAP_SIZE/8, GFP_KERNEL); test_data.bitmap_0001 = kzalloc(SYSCTL_TEST_BITMAP_SIZE/8, GFP_KERNEL);
if (!test_data.bitmap_0001) if (!test_data.bitmap_0001)
return -ENOMEM; return -ENOMEM;
test_sysctl_header = register_sysctl("debug/test_sysctl", test_table); sysctl_test_headers.test_h_setup_node = register_sysctl("debug/test_sysctl", test_table);
if (!test_sysctl_header) { if (!sysctl_test_headers.test_h_setup_node) {
kfree(test_data.bitmap_0001); kfree(test_data.bitmap_0001);
return -ENOMEM; return -ENOMEM;
} }
...@@ -195,6 +200,26 @@ static int test_sysctl_run_unregister_nested(void) ...@@ -195,6 +200,26 @@ static int test_sysctl_run_unregister_nested(void)
return 0; return 0;
} }
static int test_sysctl_run_register_mount_point(void)
{
sysctl_test_headers.test_h_mnt
= register_sysctl_mount_point("debug/test_sysctl/mnt");
if (!sysctl_test_headers.test_h_mnt)
return -ENOMEM;
sysctl_test_headers.test_h_mnterror
= register_sysctl("debug/test_sysctl/mnt/mnt_error",
test_table_unregister);
/*
* Don't check the result.:
* If it fails (expected behavior), return 0.
* If successful (missbehavior of register mount point), we want to see
* mnt_error when we run the sysctl test script
*/
return 0;
}
static int __init test_sysctl_init(void) static int __init test_sysctl_init(void)
{ {
int err; int err;
...@@ -204,6 +229,10 @@ static int __init test_sysctl_init(void) ...@@ -204,6 +229,10 @@ static int __init test_sysctl_init(void)
goto out; goto out;
err = test_sysctl_run_unregister_nested(); err = test_sysctl_run_unregister_nested();
if (err)
goto out;
err = test_sysctl_run_register_mount_point();
out: out:
return err; return err;
...@@ -213,8 +242,12 @@ module_init(test_sysctl_init); ...@@ -213,8 +242,12 @@ module_init(test_sysctl_init);
static void __exit test_sysctl_exit(void) static void __exit test_sysctl_exit(void)
{ {
kfree(test_data.bitmap_0001); kfree(test_data.bitmap_0001);
if (test_sysctl_header) if (sysctl_test_headers.test_h_setup_node)
unregister_sysctl_table(test_sysctl_header); unregister_sysctl_table(sysctl_test_headers.test_h_setup_node);
if (sysctl_test_headers.test_h_mnt)
unregister_sysctl_table(sysctl_test_headers.test_h_mnt);
if (sysctl_test_headers.test_h_mnterror)
unregister_sysctl_table(sysctl_test_headers.test_h_mnterror);
} }
module_exit(test_sysctl_exit); module_exit(test_sysctl_exit);
......
...@@ -34,6 +34,7 @@ ALL_TESTS="$ALL_TESTS 0006:50:1:bitmap_0001:1" ...@@ -34,6 +34,7 @@ ALL_TESTS="$ALL_TESTS 0006:50:1:bitmap_0001:1"
ALL_TESTS="$ALL_TESTS 0007:1:1:boot_int:1" ALL_TESTS="$ALL_TESTS 0007:1:1:boot_int:1"
ALL_TESTS="$ALL_TESTS 0008:1:1:match_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 0009:1:1:unregister_error:0"
ALL_TESTS="$ALL_TESTS 0010:1:1:mnt/mnt_error:0"
function allow_user_defaults() function allow_user_defaults()
{ {
...@@ -813,6 +814,20 @@ sysctl_test_0009() ...@@ -813,6 +814,20 @@ sysctl_test_0009()
return 0 return 0
} }
sysctl_test_0010()
{
TARGET="${SYSCTL}/$(get_test_target 0010)"
echo -n "Testing that $TARGET was not created ..."
if [ -d $TARGET ]; then
echo "TEST FAILED"
rc=1
test_rc
fi
echo "ok"
return 0
}
list_tests() list_tests()
{ {
echo "Test ID list:" echo "Test ID list:"
...@@ -830,6 +845,7 @@ list_tests() ...@@ -830,6 +845,7 @@ list_tests()
echo "0007 x $(get_test_count 0007) - tests setting sysctl from kernel boot param" echo "0007 x $(get_test_count 0007) - tests setting sysctl from kernel boot param"
echo "0008 x $(get_test_count 0008) - tests sysctl macro values match" echo "0008 x $(get_test_count 0008) - tests sysctl macro values match"
echo "0009 x $(get_test_count 0009) - tests sysct unregister" echo "0009 x $(get_test_count 0009) - tests sysct unregister"
echo "0010 x $(get_test_count 0010) - tests sysct mount point"
} }
usage() usage()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment