Lines Matching refs:test

6 #include <kunit/test.h>
11 static int guc_dbm_test_init(struct kunit *test)
15 xe_kunit_helper_xe_device_test_init(test);
16 dbm = &xe_device_get_gt(test->priv, 0)->uc.guc.dbm;
19 test->priv = dbm;
23 static void test_empty(struct kunit *test)
25 struct xe_guc_db_mgr *dbm = test->priv;
27 KUNIT_ASSERT_EQ(test, xe_guc_db_mgr_init(dbm, 0), 0);
28 KUNIT_ASSERT_EQ(test, dbm->count, 0);
31 KUNIT_EXPECT_LT(test, xe_guc_db_mgr_reserve_id_locked(dbm), 0);
34 KUNIT_EXPECT_LT(test, xe_guc_db_mgr_reserve_range(dbm, 1, 0), 0);
37 static void test_default(struct kunit *test)
39 struct xe_guc_db_mgr *dbm = test->priv;
41 KUNIT_ASSERT_EQ(test, xe_guc_db_mgr_init(dbm, ~0), 0);
42 KUNIT_ASSERT_EQ(test, dbm->count, GUC_NUM_DOORBELLS);
59 static void test_size(struct kunit *test)
61 const unsigned int *p = test->param_value;
62 struct xe_guc_db_mgr *dbm = test->priv;
66 KUNIT_ASSERT_EQ(test, xe_guc_db_mgr_init(dbm, *p), 0);
67 KUNIT_ASSERT_EQ(test, dbm->count, *p);
71 KUNIT_EXPECT_GE(test, id = xe_guc_db_mgr_reserve_id_locked(dbm), 0);
72 KUNIT_EXPECT_LT(test, id, dbm->count);
74 KUNIT_EXPECT_LT(test, xe_guc_db_mgr_reserve_id_locked(dbm), 0);
83 static void test_reuse(struct kunit *test)
85 const unsigned int *p = test->param_value;
86 struct xe_guc_db_mgr *dbm = test->priv;
89 KUNIT_ASSERT_EQ(test, xe_guc_db_mgr_init(dbm, *p), 0);
93 KUNIT_EXPECT_GE(test, xe_guc_db_mgr_reserve_id_locked(dbm), 0);
94 KUNIT_EXPECT_LT(test, xe_guc_db_mgr_reserve_id_locked(dbm), 0);
100 KUNIT_EXPECT_EQ(test, xe_guc_db_mgr_reserve_id_locked(dbm), n);
102 KUNIT_EXPECT_LT(test, xe_guc_db_mgr_reserve_id_locked(dbm), 0);
111 static void test_range_overlap(struct kunit *test)
113 const unsigned int *p = test->param_value;
114 struct xe_guc_db_mgr *dbm = test->priv;
118 KUNIT_ASSERT_EQ(test, xe_guc_db_mgr_init(dbm, ~0), 0);
119 KUNIT_ASSERT_LE(test, *p, dbm->count);
121 KUNIT_ASSERT_GE(test, id1 = xe_guc_db_mgr_reserve_range(dbm, *p, 0), 0);
123 KUNIT_ASSERT_GE(test, id2 = xe_guc_db_mgr_reserve_range(dbm, 1, 0), 0);
124 KUNIT_ASSERT_NE(test, id2, id1);
125 KUNIT_ASSERT_NE_MSG(test, id2 < id1, id2 > id1 + *p - 1,
128 KUNIT_ASSERT_LT(test, xe_guc_db_mgr_reserve_range(dbm, 1, 0), 0);
132 KUNIT_ASSERT_GE(test, id1 = xe_guc_db_mgr_reserve_range(dbm, 1, 0), 0);
133 KUNIT_ASSERT_GE(test, id2 = xe_guc_db_mgr_reserve_range(dbm, *p - 1, 0), 0);
134 KUNIT_ASSERT_NE(test, id2, id1);
135 KUNIT_ASSERT_NE_MSG(test, id1 < id2, id1 > id2 + *p - 2,
138 KUNIT_ASSERT_GE(test, id3 = xe_guc_db_mgr_reserve_range(dbm, 1, 0), 0);
139 KUNIT_ASSERT_NE(test, id3, id1);
140 KUNIT_ASSERT_NE(test, id3, id2);
141 KUNIT_ASSERT_NE_MSG(test, id3 < id2, id3 > id2 + *p - 2,
144 KUNIT_ASSERT_LT(test, xe_guc_db_mgr_reserve_range(dbm, 1, 0), 0);
149 static void test_range_compact(struct kunit *test)
151 const unsigned int *p = test->param_value;
152 struct xe_guc_db_mgr *dbm = test->priv;
155 KUNIT_ASSERT_EQ(test, xe_guc_db_mgr_init(dbm, ~0), 0);
156 KUNIT_ASSERT_NE(test, *p, 0);
157 KUNIT_ASSERT_LE(test, *p, dbm->count);
159 kunit_skip(test, "must be divisible");
161 KUNIT_ASSERT_GE(test, xe_guc_db_mgr_reserve_range(dbm, *p, 0), 0);
163 KUNIT_ASSERT_GE(test, xe_guc_db_mgr_reserve_range(dbm, *p, 0), 0);
164 KUNIT_ASSERT_LT(test, xe_guc_db_mgr_reserve_range(dbm, 1, 0), 0);
168 static void test_range_spare(struct kunit *test)
170 const unsigned int *p = test->param_value;
171 struct xe_guc_db_mgr *dbm = test->priv;
174 KUNIT_ASSERT_EQ(test, xe_guc_db_mgr_init(dbm, ~0), 0);
175 KUNIT_ASSERT_LE(test, *p, dbm->count);
177 KUNIT_ASSERT_LT(test, xe_guc_db_mgr_reserve_range(dbm, *p, dbm->count), 0);
178 KUNIT_ASSERT_LT(test, xe_guc_db_mgr_reserve_range(dbm, *p, dbm->count - *p + 1), 0);
179 KUNIT_ASSERT_EQ(test, id = xe_guc_db_mgr_reserve_range(dbm, *p, dbm->count - *p), 0);
180 KUNIT_ASSERT_LT(test, xe_guc_db_mgr_reserve_range(dbm, 1, dbm->count - *p), 0);