Lines Matching refs:test

3  * KUnit test for hw_breakpoint constraints accounting logic.
8 #include <kunit/test.h>
15 #define TEST_REQUIRES_BP_SLOTS(test, slots) \
18 kunit_skip((test), "Requires breakpoint slots: %d > %d", slots, \
23 #define TEST_EXPECT_NOSPC(expr) KUNIT_EXPECT_EQ(test, -ENOSPC, PTR_ERR(expr))
65 static void fill_one_bp_slot(struct kunit *test, int *id, int cpu, struct task_struct *tsk)
69 KUNIT_ASSERT_NOT_NULL(test, bp);
70 KUNIT_ASSERT_FALSE(test, IS_ERR(bp));
71 KUNIT_ASSERT_NULL(test, test_bps[*id]);
80 static bool fill_bp_slots(struct kunit *test, int *id, int cpu, struct task_struct *tsk, int skip)
83 fill_one_bp_slot(test, id, cpu, tsk);
93 static struct task_struct *get_other_task(struct kunit *test)
101 KUNIT_ASSERT_FALSE(test, IS_ERR(tsk));
122 static void test_one_cpu(struct kunit *test)
126 fill_bp_slots(test, &idx, get_test_cpu(0), NULL, 0);
131 static void test_many_cpus(struct kunit *test)
138 bool do_continue = fill_bp_slots(test, &idx, cpu, NULL, 0);
146 static void test_one_task_on_all_cpus(struct kunit *test)
150 fill_bp_slots(test, &idx, -1, current, 0);
156 fill_one_bp_slot(test, &idx, get_test_cpu(0), NULL);
159 static void test_two_tasks_on_all_cpus(struct kunit *test)
164 fill_bp_slots(test, &idx, -1, current, 0);
165 fill_bp_slots(test, &idx, -1, get_other_task(test), 0);
168 TEST_EXPECT_NOSPC(register_test_bp(-1, get_other_task(test), idx));
170 TEST_EXPECT_NOSPC(register_test_bp(get_test_cpu(0), get_other_task(test), idx));
177 static void test_one_task_on_one_cpu(struct kunit *test)
181 fill_bp_slots(test, &idx, get_test_cpu(0), current, 0);
190 fill_one_bp_slot(test, &idx, get_test_cpu(0), NULL);
193 static void test_one_task_mixed(struct kunit *test)
197 TEST_REQUIRES_BP_SLOTS(test, 3);
199 fill_one_bp_slot(test, &idx, get_test_cpu(0), current);
200 fill_bp_slots(test, &idx, -1, current, 1);
208 fill_one_bp_slot(test, &idx, get_test_cpu(0), NULL);
209 fill_one_bp_slot(test, &idx, get_test_cpu(0), NULL);
213 static void test_two_tasks_on_one_cpu(struct kunit *test)
217 fill_bp_slots(test, &idx, get_test_cpu(0), current, 0);
218 fill_bp_slots(test, &idx, get_test_cpu(0), get_other_task(test), 0);
221 TEST_EXPECT_NOSPC(register_test_bp(-1, get_other_task(test), idx));
223 TEST_EXPECT_NOSPC(register_test_bp(get_test_cpu(0), get_other_task(test), idx));
226 fill_bp_slots(test, &idx, get_test_cpu(1), NULL, 0);
229 static void test_two_tasks_on_one_all_cpus(struct kunit *test)
233 fill_bp_slots(test, &idx, get_test_cpu(0), current, 0);
234 fill_bp_slots(test, &idx, -1, get_other_task(test), 0);
237 TEST_EXPECT_NOSPC(register_test_bp(-1, get_other_task(test), idx));
239 TEST_EXPECT_NOSPC(register_test_bp(get_test_cpu(0), get_other_task(test), idx));
245 static void test_task_on_all_and_one_cpu(struct kunit *test)
250 TEST_REQUIRES_BP_SLOTS(test, 3);
252 fill_bp_slots(test, &idx, -1, current, 2);
255 fill_one_bp_slot(test, &idx, get_test_cpu(0), current);
256 fill_one_bp_slot(test, &idx, -1, current);
264 fill_one_bp_slot(test, &idx, get_test_cpu(1), NULL);
273 fill_one_bp_slot(test, &idx, -1, current);
294 static int test_init(struct kunit *test)
296 /* Most test cases want 2 distinct CPUs. */
298 kunit_skip(test, "not enough cpus");
302 kunit_skip(test, "hw breakpoint already in use");
307 static void test_exit(struct kunit *test)
320 KUNIT_EXPECT_FALSE(test, hw_breakpoint_is_used());