Lines Matching full:test

6 #include <kunit/test.h>
52 struct kunit *test, size_t buf_size) in build_aa_ext_struct() argument
57 buf = kunit_kzalloc(test, buf_size, GFP_USER); in build_aa_ext_struct()
58 KUNIT_EXPECT_NOT_ERR_OR_NULL(test, buf); in build_aa_ext_struct()
60 e = kunit_kmalloc(test, sizeof(*e), GFP_USER); in build_aa_ext_struct()
61 KUNIT_EXPECT_NOT_ERR_OR_NULL(test, e); in build_aa_ext_struct()
109 static int policy_unpack_test_init(struct kunit *test) in policy_unpack_test_init() argument
114 puf = kunit_kmalloc(test, sizeof(*puf), GFP_USER); in policy_unpack_test_init()
115 KUNIT_EXPECT_NOT_ERR_OR_NULL(test, puf); in policy_unpack_test_init()
118 puf->e = build_aa_ext_struct(puf, test, e_size); in policy_unpack_test_init()
120 test->priv = puf; in policy_unpack_test_init()
124 static void policy_unpack_test_inbounds_when_inbounds(struct kunit *test) in policy_unpack_test_inbounds_when_inbounds() argument
126 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_inbounds_when_inbounds()
128 KUNIT_EXPECT_TRUE(test, inbounds(puf->e, 0)); in policy_unpack_test_inbounds_when_inbounds()
129 KUNIT_EXPECT_TRUE(test, inbounds(puf->e, puf->e_size / 2)); in policy_unpack_test_inbounds_when_inbounds()
130 KUNIT_EXPECT_TRUE(test, inbounds(puf->e, puf->e_size)); in policy_unpack_test_inbounds_when_inbounds()
133 static void policy_unpack_test_inbounds_when_out_of_bounds(struct kunit *test) in policy_unpack_test_inbounds_when_out_of_bounds() argument
135 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_inbounds_when_out_of_bounds()
137 KUNIT_EXPECT_FALSE(test, inbounds(puf->e, puf->e_size + 1)); in policy_unpack_test_inbounds_when_out_of_bounds()
140 static void policy_unpack_test_unpack_array_with_null_name(struct kunit *test) in policy_unpack_test_unpack_array_with_null_name() argument
142 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_array_with_null_name()
149 KUNIT_EXPECT_EQ(test, array_size, (u16)TEST_ARRAY_SIZE); in policy_unpack_test_unpack_array_with_null_name()
150 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_array_with_null_name()
154 static void policy_unpack_test_unpack_array_with_name(struct kunit *test) in policy_unpack_test_unpack_array_with_name() argument
156 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_array_with_name()
164 KUNIT_EXPECT_EQ(test, array_size, (u16)TEST_ARRAY_SIZE); in policy_unpack_test_unpack_array_with_name()
165 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_array_with_name()
169 static void policy_unpack_test_unpack_array_out_of_bounds(struct kunit *test) in policy_unpack_test_unpack_array_out_of_bounds() argument
171 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_array_out_of_bounds()
180 KUNIT_EXPECT_EQ(test, array_size, (u16)0); in policy_unpack_test_unpack_array_out_of_bounds()
181 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_array_out_of_bounds()
185 static void policy_unpack_test_unpack_blob_with_null_name(struct kunit *test) in policy_unpack_test_unpack_blob_with_null_name() argument
187 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_blob_with_null_name()
194 KUNIT_ASSERT_EQ(test, size, TEST_BLOB_DATA_SIZE); in policy_unpack_test_unpack_blob_with_null_name()
195 KUNIT_EXPECT_TRUE(test, in policy_unpack_test_unpack_blob_with_null_name()
199 static void policy_unpack_test_unpack_blob_with_name(struct kunit *test) in policy_unpack_test_unpack_blob_with_name() argument
201 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_blob_with_name()
208 KUNIT_ASSERT_EQ(test, size, TEST_BLOB_DATA_SIZE); in policy_unpack_test_unpack_blob_with_name()
209 KUNIT_EXPECT_TRUE(test, in policy_unpack_test_unpack_blob_with_name()
213 static void policy_unpack_test_unpack_blob_out_of_bounds(struct kunit *test) in policy_unpack_test_unpack_blob_out_of_bounds() argument
215 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_blob_out_of_bounds()
227 KUNIT_EXPECT_EQ(test, size, 0); in policy_unpack_test_unpack_blob_out_of_bounds()
228 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, start); in policy_unpack_test_unpack_blob_out_of_bounds()
231 static void policy_unpack_test_unpack_str_with_null_name(struct kunit *test) in policy_unpack_test_unpack_str_with_null_name() argument
233 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_str_with_null_name()
240 KUNIT_EXPECT_EQ(test, size, strlen(TEST_STRING_DATA) + 1); in policy_unpack_test_unpack_str_with_null_name()
241 KUNIT_EXPECT_STREQ(test, string, TEST_STRING_DATA); in policy_unpack_test_unpack_str_with_null_name()
244 static void policy_unpack_test_unpack_str_with_name(struct kunit *test) in policy_unpack_test_unpack_str_with_name() argument
246 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_str_with_name()
252 KUNIT_EXPECT_EQ(test, size, strlen(TEST_STRING_DATA) + 1); in policy_unpack_test_unpack_str_with_name()
253 KUNIT_EXPECT_STREQ(test, string, TEST_STRING_DATA); in policy_unpack_test_unpack_str_with_name()
256 static void policy_unpack_test_unpack_str_out_of_bounds(struct kunit *test) in policy_unpack_test_unpack_str_out_of_bounds() argument
258 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_str_out_of_bounds()
268 KUNIT_EXPECT_EQ(test, size, 0); in policy_unpack_test_unpack_str_out_of_bounds()
269 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, start); in policy_unpack_test_unpack_str_out_of_bounds()
272 static void policy_unpack_test_unpack_strdup_with_null_name(struct kunit *test) in policy_unpack_test_unpack_strdup_with_null_name() argument
274 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_strdup_with_null_name()
281 KUNIT_EXPECT_EQ(test, size, strlen(TEST_STRING_DATA) + 1); in policy_unpack_test_unpack_strdup_with_null_name()
282 KUNIT_EXPECT_FALSE(test, in policy_unpack_test_unpack_strdup_with_null_name()
285 KUNIT_EXPECT_STREQ(test, string, TEST_STRING_DATA); in policy_unpack_test_unpack_strdup_with_null_name()
288 static void policy_unpack_test_unpack_strdup_with_name(struct kunit *test) in policy_unpack_test_unpack_strdup_with_name() argument
290 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_strdup_with_name()
296 KUNIT_EXPECT_EQ(test, size, strlen(TEST_STRING_DATA) + 1); in policy_unpack_test_unpack_strdup_with_name()
297 KUNIT_EXPECT_FALSE(test, in policy_unpack_test_unpack_strdup_with_name()
300 KUNIT_EXPECT_STREQ(test, string, TEST_STRING_DATA); in policy_unpack_test_unpack_strdup_with_name()
303 static void policy_unpack_test_unpack_strdup_out_of_bounds(struct kunit *test) in policy_unpack_test_unpack_strdup_out_of_bounds() argument
305 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_strdup_out_of_bounds()
315 KUNIT_EXPECT_EQ(test, size, 0); in policy_unpack_test_unpack_strdup_out_of_bounds()
316 KUNIT_EXPECT_PTR_EQ(test, string, (char *)NULL); in policy_unpack_test_unpack_strdup_out_of_bounds()
317 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, start); in policy_unpack_test_unpack_strdup_out_of_bounds()
320 static void policy_unpack_test_unpack_nameX_with_null_name(struct kunit *test) in policy_unpack_test_unpack_nameX_with_null_name() argument
322 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_nameX_with_null_name()
329 KUNIT_EXPECT_TRUE(test, success); in policy_unpack_test_unpack_nameX_with_null_name()
330 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_nameX_with_null_name()
334 static void policy_unpack_test_unpack_nameX_with_wrong_code(struct kunit *test) in policy_unpack_test_unpack_nameX_with_wrong_code() argument
336 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_nameX_with_wrong_code()
343 KUNIT_EXPECT_FALSE(test, success); in policy_unpack_test_unpack_nameX_with_wrong_code()
344 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_nameX_with_wrong_code()
348 static void policy_unpack_test_unpack_nameX_with_name(struct kunit *test) in policy_unpack_test_unpack_nameX_with_name() argument
350 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_nameX_with_name()
358 KUNIT_EXPECT_TRUE(test, success); in policy_unpack_test_unpack_nameX_with_name()
359 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_nameX_with_name()
363 static void policy_unpack_test_unpack_nameX_with_wrong_name(struct kunit *test) in policy_unpack_test_unpack_nameX_with_wrong_name() argument
365 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_nameX_with_wrong_name()
373 KUNIT_EXPECT_FALSE(test, success); in policy_unpack_test_unpack_nameX_with_wrong_name()
374 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_nameX_with_wrong_name()
378 static void policy_unpack_test_unpack_u16_chunk_basic(struct kunit *test) in policy_unpack_test_unpack_u16_chunk_basic() argument
380 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_u16_chunk_basic()
394 KUNIT_EXPECT_PTR_EQ(test, (void *)chunk, in policy_unpack_test_unpack_u16_chunk_basic()
396 KUNIT_EXPECT_EQ(test, size, (size_t)TEST_U16_DATA); in policy_unpack_test_unpack_u16_chunk_basic()
397 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, (void *)(chunk + TEST_U16_DATA)); in policy_unpack_test_unpack_u16_chunk_basic()
401 struct kunit *test) in policy_unpack_test_unpack_u16_chunk_out_of_bounds_1() argument
403 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_u16_chunk_out_of_bounds_1()
411 KUNIT_EXPECT_EQ(test, size, (size_t)0); in policy_unpack_test_unpack_u16_chunk_out_of_bounds_1()
412 KUNIT_EXPECT_PTR_EQ(test, chunk, (char *)NULL); in policy_unpack_test_unpack_u16_chunk_out_of_bounds_1()
413 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, puf->e->end - 1); in policy_unpack_test_unpack_u16_chunk_out_of_bounds_1()
417 struct kunit *test) in policy_unpack_test_unpack_u16_chunk_out_of_bounds_2() argument
419 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_u16_chunk_out_of_bounds_2()
433 KUNIT_EXPECT_EQ(test, size, (size_t)0); in policy_unpack_test_unpack_u16_chunk_out_of_bounds_2()
434 KUNIT_EXPECT_PTR_EQ(test, chunk, (char *)NULL); in policy_unpack_test_unpack_u16_chunk_out_of_bounds_2()
435 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, puf->e->start + TEST_U16_OFFSET); in policy_unpack_test_unpack_u16_chunk_out_of_bounds_2()
438 static void policy_unpack_test_unpack_u32_with_null_name(struct kunit *test) in policy_unpack_test_unpack_u32_with_null_name() argument
440 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_u32_with_null_name()
448 KUNIT_EXPECT_TRUE(test, success); in policy_unpack_test_unpack_u32_with_null_name()
449 KUNIT_EXPECT_EQ(test, data, TEST_U32_DATA); in policy_unpack_test_unpack_u32_with_null_name()
450 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_u32_with_null_name()
454 static void policy_unpack_test_unpack_u32_with_name(struct kunit *test) in policy_unpack_test_unpack_u32_with_name() argument
456 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_u32_with_name()
465 KUNIT_EXPECT_TRUE(test, success); in policy_unpack_test_unpack_u32_with_name()
466 KUNIT_EXPECT_EQ(test, data, TEST_U32_DATA); in policy_unpack_test_unpack_u32_with_name()
467 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_u32_with_name()
471 static void policy_unpack_test_unpack_u32_out_of_bounds(struct kunit *test) in policy_unpack_test_unpack_u32_out_of_bounds() argument
473 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_u32_out_of_bounds()
483 KUNIT_EXPECT_FALSE(test, success); in policy_unpack_test_unpack_u32_out_of_bounds()
484 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_u32_out_of_bounds()
488 static void policy_unpack_test_unpack_u64_with_null_name(struct kunit *test) in policy_unpack_test_unpack_u64_with_null_name() argument
490 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_u64_with_null_name()
498 KUNIT_EXPECT_TRUE(test, success); in policy_unpack_test_unpack_u64_with_null_name()
499 KUNIT_EXPECT_EQ(test, data, TEST_U64_DATA); in policy_unpack_test_unpack_u64_with_null_name()
500 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_u64_with_null_name()
504 static void policy_unpack_test_unpack_u64_with_name(struct kunit *test) in policy_unpack_test_unpack_u64_with_name() argument
506 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_u64_with_name()
515 KUNIT_EXPECT_TRUE(test, success); in policy_unpack_test_unpack_u64_with_name()
516 KUNIT_EXPECT_EQ(test, data, TEST_U64_DATA); in policy_unpack_test_unpack_u64_with_name()
517 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_u64_with_name()
521 static void policy_unpack_test_unpack_u64_out_of_bounds(struct kunit *test) in policy_unpack_test_unpack_u64_out_of_bounds() argument
523 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_u64_out_of_bounds()
533 KUNIT_EXPECT_FALSE(test, success); in policy_unpack_test_unpack_u64_out_of_bounds()
534 KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, in policy_unpack_test_unpack_u64_out_of_bounds()
538 static void policy_unpack_test_unpack_X_code_match(struct kunit *test) in policy_unpack_test_unpack_X_code_match() argument
540 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_X_code_match()
543 KUNIT_EXPECT_TRUE(test, success); in policy_unpack_test_unpack_X_code_match()
544 KUNIT_EXPECT_TRUE(test, puf->e->pos == puf->e->start + 1); in policy_unpack_test_unpack_X_code_match()
547 static void policy_unpack_test_unpack_X_code_mismatch(struct kunit *test) in policy_unpack_test_unpack_X_code_mismatch() argument
549 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_X_code_mismatch()
552 KUNIT_EXPECT_FALSE(test, success); in policy_unpack_test_unpack_X_code_mismatch()
553 KUNIT_EXPECT_TRUE(test, puf->e->pos == puf->e->start); in policy_unpack_test_unpack_X_code_mismatch()
556 static void policy_unpack_test_unpack_X_out_of_bounds(struct kunit *test) in policy_unpack_test_unpack_X_out_of_bounds() argument
558 struct policy_unpack_fixture *puf = test->priv; in policy_unpack_test_unpack_X_out_of_bounds()
564 KUNIT_EXPECT_FALSE(test, success); in policy_unpack_test_unpack_X_out_of_bounds()