Lines Matching refs:test
19 static void sysctl_test_api_dointvec_null_tbl_data(struct kunit *test) in sysctl_test_api_dointvec_null_tbl_data() argument
39 void __user *buffer = (void __user *)kunit_kzalloc(test, sizeof(int), in sysctl_test_api_dointvec_null_tbl_data()
49 KUNIT_EXPECT_EQ(test, 0, proc_dointvec(&null_data_table, in sysctl_test_api_dointvec_null_tbl_data()
52 KUNIT_EXPECT_EQ(test, 0, len); in sysctl_test_api_dointvec_null_tbl_data()
58 KUNIT_EXPECT_EQ(test, 0, proc_dointvec(&null_data_table, in sysctl_test_api_dointvec_null_tbl_data()
61 KUNIT_EXPECT_EQ(test, 0, len); in sysctl_test_api_dointvec_null_tbl_data()
69 static void sysctl_test_api_dointvec_table_maxlen_unset(struct kunit *test) in sysctl_test_api_dointvec_table_maxlen_unset() argument
85 void __user *buffer = (void __user *)kunit_kzalloc(test, sizeof(int), in sysctl_test_api_dointvec_table_maxlen_unset()
95 KUNIT_EXPECT_EQ(test, 0, proc_dointvec(&data_maxlen_unset_table, in sysctl_test_api_dointvec_table_maxlen_unset()
98 KUNIT_EXPECT_EQ(test, 0, len); in sysctl_test_api_dointvec_table_maxlen_unset()
104 KUNIT_EXPECT_EQ(test, 0, proc_dointvec(&data_maxlen_unset_table, in sysctl_test_api_dointvec_table_maxlen_unset()
107 KUNIT_EXPECT_EQ(test, 0, len); in sysctl_test_api_dointvec_table_maxlen_unset()
115 static void sysctl_test_api_dointvec_table_len_is_zero(struct kunit *test) in sysctl_test_api_dointvec_table_len_is_zero() argument
128 void __user *buffer = (void __user *)kunit_kzalloc(test, sizeof(int), in sysctl_test_api_dointvec_table_len_is_zero()
136 KUNIT_EXPECT_EQ(test, 0, proc_dointvec(&table, KUNIT_PROC_READ, buffer, in sysctl_test_api_dointvec_table_len_is_zero()
138 KUNIT_EXPECT_EQ(test, 0, len); in sysctl_test_api_dointvec_table_len_is_zero()
140 KUNIT_EXPECT_EQ(test, 0, proc_dointvec(&table, KUNIT_PROC_WRITE, buffer, in sysctl_test_api_dointvec_table_len_is_zero()
142 KUNIT_EXPECT_EQ(test, 0, len); in sysctl_test_api_dointvec_table_len_is_zero()
149 struct kunit *test) in sysctl_test_api_dointvec_table_read_but_position_set() argument
162 void __user *buffer = (void __user *)kunit_kzalloc(test, sizeof(int), in sysctl_test_api_dointvec_table_read_but_position_set()
175 KUNIT_EXPECT_EQ(test, 0, proc_dointvec(&table, KUNIT_PROC_READ, buffer, in sysctl_test_api_dointvec_table_read_but_position_set()
177 KUNIT_EXPECT_EQ(test, 0, len); in sysctl_test_api_dointvec_table_read_but_position_set()
184 static void sysctl_test_dointvec_read_happy_single_positive(struct kunit *test) in sysctl_test_dointvec_read_happy_single_positive() argument
199 char *buffer = kunit_kzalloc(test, len, GFP_USER); in sysctl_test_dointvec_read_happy_single_positive()
204 KUNIT_EXPECT_EQ(test, 0, proc_dointvec(&table, KUNIT_PROC_READ, in sysctl_test_dointvec_read_happy_single_positive()
206 KUNIT_ASSERT_EQ(test, 3, len); in sysctl_test_dointvec_read_happy_single_positive()
209 KUNIT_EXPECT_STREQ(test, "13\n", buffer); in sysctl_test_dointvec_read_happy_single_positive()
215 static void sysctl_test_dointvec_read_happy_single_negative(struct kunit *test) in sysctl_test_dointvec_read_happy_single_negative() argument
230 char *buffer = kunit_kzalloc(test, len, GFP_USER); in sysctl_test_dointvec_read_happy_single_negative()
234 KUNIT_EXPECT_EQ(test, 0, proc_dointvec(&table, KUNIT_PROC_READ, in sysctl_test_dointvec_read_happy_single_negative()
236 KUNIT_ASSERT_EQ(test, 4, len); in sysctl_test_dointvec_read_happy_single_negative()
238 KUNIT_EXPECT_STREQ(test, "-16\n", buffer); in sysctl_test_dointvec_read_happy_single_negative()
244 static void sysctl_test_dointvec_write_happy_single_positive(struct kunit *test) in sysctl_test_dointvec_write_happy_single_positive() argument
260 char *buffer = kunit_kzalloc(test, len, GFP_USER); in sysctl_test_dointvec_write_happy_single_positive()
265 KUNIT_EXPECT_EQ(test, 0, proc_dointvec(&table, KUNIT_PROC_WRITE, in sysctl_test_dointvec_write_happy_single_positive()
267 KUNIT_EXPECT_EQ(test, sizeof(input) - 1, len); in sysctl_test_dointvec_write_happy_single_positive()
268 KUNIT_EXPECT_EQ(test, sizeof(input) - 1, pos); in sysctl_test_dointvec_write_happy_single_positive()
269 KUNIT_EXPECT_EQ(test, 9, *((int *)table.data)); in sysctl_test_dointvec_write_happy_single_positive()
275 static void sysctl_test_dointvec_write_happy_single_negative(struct kunit *test) in sysctl_test_dointvec_write_happy_single_negative() argument
290 char *buffer = kunit_kzalloc(test, len, GFP_USER); in sysctl_test_dointvec_write_happy_single_negative()
295 KUNIT_EXPECT_EQ(test, 0, proc_dointvec(&table, KUNIT_PROC_WRITE, in sysctl_test_dointvec_write_happy_single_negative()
297 KUNIT_EXPECT_EQ(test, sizeof(input) - 1, len); in sysctl_test_dointvec_write_happy_single_negative()
298 KUNIT_EXPECT_EQ(test, sizeof(input) - 1, pos); in sysctl_test_dointvec_write_happy_single_negative()
299 KUNIT_EXPECT_EQ(test, -9, *((int *)table.data)); in sysctl_test_dointvec_write_happy_single_negative()
307 struct kunit *test) in sysctl_test_api_dointvec_write_single_less_int_min() argument
321 char *buffer = kunit_kzalloc(test, max_len, GFP_USER); in sysctl_test_api_dointvec_write_single_less_int_min()
330 KUNIT_ASSERT_LT(test, in sysctl_test_api_dointvec_write_single_less_int_min()
335 KUNIT_EXPECT_EQ(test, -EINVAL, proc_dointvec(&table, KUNIT_PROC_WRITE, in sysctl_test_api_dointvec_write_single_less_int_min()
337 KUNIT_EXPECT_EQ(test, max_len, len); in sysctl_test_api_dointvec_write_single_less_int_min()
338 KUNIT_EXPECT_EQ(test, 0, *((int *)table.data)); in sysctl_test_api_dointvec_write_single_less_int_min()
345 struct kunit *test) in sysctl_test_api_dointvec_write_single_greater_int_max() argument
359 char *buffer = kunit_kzalloc(test, max_len, GFP_USER); in sysctl_test_api_dointvec_write_single_greater_int_max()
363 KUNIT_ASSERT_GT(test, greater_than_max, (unsigned long)INT_MAX); in sysctl_test_api_dointvec_write_single_greater_int_max()
364 KUNIT_ASSERT_LT(test, (size_t)snprintf(buffer, max_len, "%lu", in sysctl_test_api_dointvec_write_single_greater_int_max()
367 KUNIT_EXPECT_EQ(test, -EINVAL, proc_dointvec(&table, KUNIT_PROC_WRITE, in sysctl_test_api_dointvec_write_single_greater_int_max()
369 KUNIT_ASSERT_EQ(test, max_len, len); in sysctl_test_api_dointvec_write_single_greater_int_max()
370 KUNIT_EXPECT_EQ(test, 0, *((int *)table.data)); in sysctl_test_api_dointvec_write_single_greater_int_max()