File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
tools/testing/selftests/sysctl Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -170,12 +170,42 @@ static int test_sysctl_setup_node_tests(void)
170
170
return 0 ;
171
171
}
172
172
173
+ /* Used to test that unregister actually removes the directory */
174
+ static struct ctl_table test_table_unregister [] = {
175
+ {
176
+ .procname = "unregister_error" ,
177
+ .data = & test_data .int_0001 ,
178
+ .maxlen = sizeof (int ),
179
+ .mode = 0644 ,
180
+ .proc_handler = proc_dointvec_minmax ,
181
+ },
182
+ {}
183
+ };
184
+
185
+ static int test_sysctl_run_unregister_nested (void )
186
+ {
187
+ struct ctl_table_header * unregister ;
188
+
189
+ unregister = register_sysctl ("debug/test_sysctl/unregister_error" ,
190
+ test_table_unregister );
191
+ if (!unregister )
192
+ return - ENOMEM ;
193
+
194
+ unregister_sysctl_table (unregister );
195
+ return 0 ;
196
+ }
197
+
173
198
static int __init test_sysctl_init (void )
174
199
{
175
200
int err ;
176
201
177
202
err = test_sysctl_setup_node_tests ();
203
+ if (err )
204
+ goto out ;
205
+
206
+ err = test_sysctl_run_unregister_nested ();
178
207
208
+ out :
179
209
return err ;
180
210
}
181
211
module_init (test_sysctl_init );
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ ALL_TESTS="$ALL_TESTS 0005:3:1:int_0003"
31
31
ALL_TESTS=" $ALL_TESTS 0006:50:1:bitmap_0001"
32
32
ALL_TESTS=" $ALL_TESTS 0007:1:1:boot_int"
33
33
ALL_TESTS=" $ALL_TESTS 0008:1:1:match_int"
34
+ ALL_TESTS=" $ALL_TESTS 0009:1:1:unregister_error"
34
35
35
36
function allow_user_defaults()
36
37
{
@@ -797,6 +798,20 @@ sysctl_test_0008()
797
798
return 0
798
799
}
799
800
801
+ sysctl_test_0009 ()
802
+ {
803
+ TARGET=" ${SYSCTL} /$( get_test_target 0009) "
804
+ echo -n " Testing if $TARGET unregistered correctly ..."
805
+ if [ -d $TARGET ]; then
806
+ echo " TEST FAILED"
807
+ rc=1
808
+ test_rc
809
+ fi
810
+
811
+ echo " ok"
812
+ return 0
813
+ }
814
+
800
815
list_tests ()
801
816
{
802
817
echo " Test ID list:"
@@ -813,6 +828,7 @@ list_tests()
813
828
echo " 0006 x $( get_test_count 0006) - tests proc_do_large_bitmap()"
814
829
echo " 0007 x $( get_test_count 0007) - tests setting sysctl from kernel boot param"
815
830
echo " 0008 x $( get_test_count 0008) - tests sysctl macro values match"
831
+ echo " 0009 x $( get_test_count 0009) - tests sysct unregister"
816
832
}
817
833
818
834
usage ()
You can’t perform that action at this time.
0 commit comments