test_sysctl.c (cdd5b5a9761fd66d17586e4f4ba6588c70e640ea) test_sysctl.c (777740779ec5bd05eac85d9bbbb6b11457cfd238)
1// SPDX-License-Identifier: GPL-2.0-or-later OR copyleft-next-0.3.1
2/*
3 * proc sysctl test driver
4 *
5 * Copyright (C) 2017 Luis R. Rodriguez <mcgrof@kernel.org>
6 */
7
8/*

--- 21 unchanged lines hidden (view full) ---

30static int i_one_hundred = 100;
31static int match_int_ok = 1;
32
33
34static struct {
35 struct ctl_table_header *test_h_setup_node;
36 struct ctl_table_header *test_h_mnt;
37 struct ctl_table_header *test_h_mnterror;
1// SPDX-License-Identifier: GPL-2.0-or-later OR copyleft-next-0.3.1
2/*
3 * proc sysctl test driver
4 *
5 * Copyright (C) 2017 Luis R. Rodriguez <mcgrof@kernel.org>
6 */
7
8/*

--- 21 unchanged lines hidden (view full) ---

30static int i_one_hundred = 100;
31static int match_int_ok = 1;
32
33
34static struct {
35 struct ctl_table_header *test_h_setup_node;
36 struct ctl_table_header *test_h_mnt;
37 struct ctl_table_header *test_h_mnterror;
38 struct ctl_table_header *empty_add;
39 struct ctl_table_header *empty;
38} sysctl_test_headers;
39
40struct test_sysctl_data {
41 int int_0001;
42 int int_0002;
43 int int_0003[4];
44
45 int boot_int;

--- 169 unchanged lines hidden (view full) ---

215 * If it fails (expected behavior), return 0.
216 * If successful (missbehavior of register mount point), we want to see
217 * mnt_error when we run the sysctl test script
218 */
219
220 return 0;
221}
222
40} sysctl_test_headers;
41
42struct test_sysctl_data {
43 int int_0001;
44 int int_0002;
45 int int_0003[4];
46
47 int boot_int;

--- 169 unchanged lines hidden (view full) ---

217 * If it fails (expected behavior), return 0.
218 * If successful (missbehavior of register mount point), we want to see
219 * mnt_error when we run the sysctl test script
220 */
221
222 return 0;
223}
224
225static struct ctl_table test_table_empty[] = { };
226
227static int test_sysctl_run_register_empty(void)
228{
229 /* Tets that an empty dir can be created */
230 sysctl_test_headers.empty_add
231 = register_sysctl("debug/test_sysctl/empty_add", test_table_empty);
232 if (!sysctl_test_headers.empty_add)
233 return -ENOMEM;
234
235 /* Test that register on top of an empty dir works */
236 sysctl_test_headers.empty
237 = register_sysctl("debug/test_sysctl/empty_add/empty", test_table_empty);
238 if (!sysctl_test_headers.empty)
239 return -ENOMEM;
240
241 return 0;
242}
243
223static int __init test_sysctl_init(void)
224{
225 int err;
226
227 err = test_sysctl_setup_node_tests();
228 if (err)
229 goto out;
230
231 err = test_sysctl_run_unregister_nested();
232 if (err)
233 goto out;
234
235 err = test_sysctl_run_register_mount_point();
244static int __init test_sysctl_init(void)
245{
246 int err;
247
248 err = test_sysctl_setup_node_tests();
249 if (err)
250 goto out;
251
252 err = test_sysctl_run_unregister_nested();
253 if (err)
254 goto out;
255
256 err = test_sysctl_run_register_mount_point();
257 if (err)
258 goto out;
236
259
260 err = test_sysctl_run_register_empty();
261
237out:
238 return err;
239}
240module_init(test_sysctl_init);
241
242static void __exit test_sysctl_exit(void)
243{
244 kfree(test_data.bitmap_0001);
245 if (sysctl_test_headers.test_h_setup_node)
246 unregister_sysctl_table(sysctl_test_headers.test_h_setup_node);
247 if (sysctl_test_headers.test_h_mnt)
248 unregister_sysctl_table(sysctl_test_headers.test_h_mnt);
249 if (sysctl_test_headers.test_h_mnterror)
250 unregister_sysctl_table(sysctl_test_headers.test_h_mnterror);
262out:
263 return err;
264}
265module_init(test_sysctl_init);
266
267static void __exit test_sysctl_exit(void)
268{
269 kfree(test_data.bitmap_0001);
270 if (sysctl_test_headers.test_h_setup_node)
271 unregister_sysctl_table(sysctl_test_headers.test_h_setup_node);
272 if (sysctl_test_headers.test_h_mnt)
273 unregister_sysctl_table(sysctl_test_headers.test_h_mnt);
274 if (sysctl_test_headers.test_h_mnterror)
275 unregister_sysctl_table(sysctl_test_headers.test_h_mnterror);
276 if (sysctl_test_headers.empty)
277 unregister_sysctl_table(sysctl_test_headers.empty);
278 if (sysctl_test_headers.empty_add)
279 unregister_sysctl_table(sysctl_test_headers.empty_add);
251}
252
253module_exit(test_sysctl_exit);
254
255MODULE_AUTHOR("Luis R. Rodriguez <mcgrof@kernel.org>");
256MODULE_LICENSE("GPL");
280}
281
282module_exit(test_sysctl_exit);
283
284MODULE_AUTHOR("Luis R. Rodriguez <mcgrof@kernel.org>");
285MODULE_LICENSE("GPL");