Lines Matching defs:test
11 #include <kunit/test.h>
118 static void stringify_free_seq(struct kunit *test, int *seq, struct seq_buf *sb)
125 KUNIT_EXPECT_FALSE(test, seq_buf_has_overflowed(sb));
128 static void stringify_alignments(struct kunit *test, int *alignments,
137 KUNIT_EXPECT_FALSE(test, seq_buf_has_overflowed(sb));
140 static bool check_buffer_pages_allocated(struct kunit *test,
155 kunit_err(test, "expect alloc but is %s at page index %d\n",
164 static unsigned long binder_alloc_test_alloc_buf(struct kunit *test,
175 !check_buffer_pages_allocated(test, alloc, buffers[i], sizes[i]))
182 static unsigned long binder_alloc_test_free_buf(struct kunit *test,
195 kunit_err(test, "expect lru but is %s at page index %d\n",
204 static unsigned long binder_alloc_test_free_page(struct kunit *test,
218 kunit_err(test, "expect free but is %s at page index %d\n",
228 /* Executes one full test run for the given test case. */
229 static bool binder_alloc_test_alloc_free(struct kunit *test,
239 failures = binder_alloc_test_alloc_buf(test, alloc, buffers,
243 KUNIT_EXPECT_EQ_MSG(test, failures, 0,
247 failures = binder_alloc_test_free_buf(test, alloc, buffers,
251 KUNIT_EXPECT_EQ_MSG(test, failures, 0,
256 failures = binder_alloc_test_alloc_buf(test, alloc, buffers,
260 KUNIT_EXPECT_EQ_MSG(test, failures, 0,
266 KUNIT_EXPECT_EQ_MSG(test, failures, 0,
270 failures = binder_alloc_test_free_buf(test, alloc, buffers,
274 KUNIT_EXPECT_EQ_MSG(test, failures, 0,
278 failures = binder_alloc_test_free_page(test, alloc);
280 KUNIT_EXPECT_EQ_MSG(test, failures, 0,
299 static void permute_frees(struct kunit *test, struct binder_alloc *alloc,
310 case_failed = binder_alloc_test_alloc_free(test, alloc, tc, end);
315 stringify_free_seq(test, tc->free_sequence,
317 kunit_err(test, "case %lu: [%s] | %s - %s - %s", *runs,
330 permute_frees(test, alloc, tc, runs, failures, index + 1, end);
334 static void gen_buf_sizes(struct kunit *test,
362 permute_frees(test, alloc, tc, runs, failures, 0,
367 permute_frees(test, alloc, tc, runs, failures, 0, alloc->buffer_size);
370 static void gen_buf_offsets(struct kunit *test, struct binder_alloc *alloc,
383 stringify_alignments(test, alignments, &tc.alignments_sb);
385 gen_buf_sizes(test, alloc, &tc, end_offset, runs, failures);
400 gen_buf_offsets(test, alloc, end_offset, alignments, runs,
412 static void binder_alloc_test_init_freelist(struct kunit *test)
414 struct binder_alloc_test *priv = test->priv;
416 KUNIT_EXPECT_PTR_EQ(test, priv->alloc.freelist,
420 static void binder_alloc_test_mmap(struct kunit *test)
422 struct binder_alloc_test *priv = test->priv;
427 KUNIT_EXPECT_EQ(test, alloc->mapped, true);
428 KUNIT_EXPECT_EQ(test, alloc->buffer_size, BINDER_MMAP_SIZE);
431 KUNIT_EXPECT_PTR_EQ(test, n, NULL);
435 KUNIT_EXPECT_EQ(test, binder_alloc_buffer_size(alloc, buf),
437 KUNIT_EXPECT_TRUE(test, list_is_last(&buf->entry, &alloc->buffers));
441 * binder_alloc_exhaustive_test() - Exhaustively test alloc and free of buffer pages.
442 * @test: The test context object.
449 static void binder_alloc_exhaustive_test(struct kunit *test)
451 struct binder_alloc_test *priv = test->priv;
457 gen_buf_offsets(test, &priv->alloc, end_offset, alignments, &runs,
460 KUNIT_EXPECT_EQ(test, runs, TOTAL_EXHAUSTIVE_CASES);
461 KUNIT_EXPECT_EQ(test, failures, 0);
464 /* ===== End test cases ===== */
495 static int binder_alloc_test_init(struct kunit *test)
500 priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
503 test->priv = priv;
507 kunit_err(test, "Failed to initialize test freelist\n");
514 kunit_err(test, "Failed to attach mm\n");
523 kunit_err(test, "Failed to open binder alloc test driver file\n");
527 priv->mmap_uaddr = kunit_vm_mmap(test, priv->filp, 0, BINDER_MMAP_SIZE,
531 kunit_err(test, "Could not map the test's transaction memory\n");
538 static void binder_alloc_test_exit(struct kunit *test)
540 struct binder_alloc_test *priv = test->priv;
550 KUNIT_EXPECT_EQ(test, list_lru_count(&priv->binder_test_freelist), 0);