Lines Matching full:test
30 static int ttm_pool_test_init(struct kunit *test) in ttm_pool_test_init() argument
34 priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL); in ttm_pool_test_init()
35 KUNIT_ASSERT_NOT_NULL(test, priv); in ttm_pool_test_init()
37 priv->devs = ttm_test_devices_basic(test); in ttm_pool_test_init()
38 test->priv = priv; in ttm_pool_test_init()
43 static void ttm_pool_test_fini(struct kunit *test) in ttm_pool_test_fini() argument
45 struct ttm_pool_test_priv *priv = test->priv; in ttm_pool_test_fini()
47 ttm_test_devices_put(test, priv->devs); in ttm_pool_test_fini()
50 static struct ttm_tt *ttm_tt_kunit_init(struct kunit *test, in ttm_tt_kunit_init() argument
55 struct ttm_pool_test_priv *priv = test->priv; in ttm_tt_kunit_init()
60 bo = ttm_bo_kunit_init(test, priv->devs, size, NULL); in ttm_tt_kunit_init()
61 KUNIT_ASSERT_NOT_NULL(test, bo); in ttm_tt_kunit_init()
64 tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL); in ttm_tt_kunit_init()
65 KUNIT_ASSERT_NOT_NULL(test, tt); in ttm_tt_kunit_init()
68 KUNIT_ASSERT_EQ(test, err, 0); in ttm_tt_kunit_init()
73 static struct ttm_pool *ttm_pool_pre_populated(struct kunit *test, in ttm_pool_pre_populated() argument
77 struct ttm_pool_test_priv *priv = test->priv; in ttm_pool_pre_populated()
83 tt = ttm_tt_kunit_init(test, 0, caching, size); in ttm_pool_pre_populated()
84 KUNIT_ASSERT_NOT_NULL(test, tt); in ttm_pool_pre_populated()
86 pool = kunit_kzalloc(test, sizeof(*pool), GFP_KERNEL); in ttm_pool_pre_populated()
87 KUNIT_ASSERT_NOT_NULL(test, pool); in ttm_pool_pre_populated()
92 KUNIT_ASSERT_EQ(test, err, 0); in ttm_pool_pre_populated()
134 static void ttm_pool_alloc_basic(struct kunit *test) in ttm_pool_alloc_basic() argument
136 struct ttm_pool_test_priv *priv = test->priv; in ttm_pool_alloc_basic()
138 const struct ttm_pool_test_case *params = test->param_value; in ttm_pool_alloc_basic()
147 tt = ttm_tt_kunit_init(test, 0, caching, size); in ttm_pool_alloc_basic()
148 KUNIT_ASSERT_NOT_NULL(test, tt); in ttm_pool_alloc_basic()
150 pool = kunit_kzalloc(test, sizeof(*pool), GFP_KERNEL); in ttm_pool_alloc_basic()
151 KUNIT_ASSERT_NOT_NULL(test, pool); in ttm_pool_alloc_basic()
156 KUNIT_ASSERT_PTR_EQ(test, pool->dev, devs->dev); in ttm_pool_alloc_basic()
157 KUNIT_ASSERT_EQ(test, pool->nid, NUMA_NO_NODE); in ttm_pool_alloc_basic()
158 KUNIT_ASSERT_EQ(test, pool->use_dma_alloc, params->use_dma_alloc); in ttm_pool_alloc_basic()
161 KUNIT_ASSERT_EQ(test, err, 0); in ttm_pool_alloc_basic()
162 KUNIT_ASSERT_EQ(test, tt->num_pages, expected_num_pages); in ttm_pool_alloc_basic()
169 KUNIT_ASSERT_NOT_NULL(test, (void *)fst_page->private); in ttm_pool_alloc_basic()
170 KUNIT_ASSERT_NOT_NULL(test, (void *)last_page->private); in ttm_pool_alloc_basic()
172 KUNIT_ASSERT_EQ(test, fst_page->private, params->order); in ttm_pool_alloc_basic()
176 KUNIT_ASSERT_NOT_NULL(test, (void *)fst_page->private); in ttm_pool_alloc_basic()
177 KUNIT_ASSERT_NULL(test, (void *)last_page->private); in ttm_pool_alloc_basic()
183 KUNIT_ASSERT_EQ(test, fst_page->private, in ttm_pool_alloc_basic()
186 KUNIT_ASSERT_EQ(test, last_page->private, 0); in ttm_pool_alloc_basic()
195 static void ttm_pool_alloc_basic_dma_addr(struct kunit *test) in ttm_pool_alloc_basic_dma_addr() argument
197 struct ttm_pool_test_priv *priv = test->priv; in ttm_pool_alloc_basic_dma_addr()
199 const struct ttm_pool_test_case *params = test->param_value; in ttm_pool_alloc_basic_dma_addr()
209 tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL); in ttm_pool_alloc_basic_dma_addr()
210 KUNIT_ASSERT_NOT_NULL(test, tt); in ttm_pool_alloc_basic_dma_addr()
212 bo = ttm_bo_kunit_init(test, devs, size, NULL); in ttm_pool_alloc_basic_dma_addr()
213 KUNIT_ASSERT_NOT_NULL(test, bo); in ttm_pool_alloc_basic_dma_addr()
216 KUNIT_ASSERT_EQ(test, err, 0); in ttm_pool_alloc_basic_dma_addr()
218 pool = kunit_kzalloc(test, sizeof(*pool), GFP_KERNEL); in ttm_pool_alloc_basic_dma_addr()
219 KUNIT_ASSERT_NOT_NULL(test, pool); in ttm_pool_alloc_basic_dma_addr()
224 KUNIT_ASSERT_EQ(test, err, 0); in ttm_pool_alloc_basic_dma_addr()
225 KUNIT_ASSERT_EQ(test, tt->num_pages, expected_num_pages); in ttm_pool_alloc_basic_dma_addr()
230 KUNIT_ASSERT_NOT_NULL(test, (void *)(uintptr_t)dma1); in ttm_pool_alloc_basic_dma_addr()
231 KUNIT_ASSERT_NOT_NULL(test, (void *)(uintptr_t)dma2); in ttm_pool_alloc_basic_dma_addr()
238 static void ttm_pool_alloc_order_caching_match(struct kunit *test) in ttm_pool_alloc_order_caching_match() argument
248 pool = ttm_pool_pre_populated(test, size, caching); in ttm_pool_alloc_order_caching_match()
251 KUNIT_ASSERT_FALSE(test, list_empty(&pt->pages)); in ttm_pool_alloc_order_caching_match()
253 tt = ttm_tt_kunit_init(test, 0, caching, size); in ttm_pool_alloc_order_caching_match()
254 KUNIT_ASSERT_NOT_NULL(test, tt); in ttm_pool_alloc_order_caching_match()
257 KUNIT_ASSERT_EQ(test, err, 0); in ttm_pool_alloc_order_caching_match()
259 KUNIT_ASSERT_TRUE(test, list_empty(&pt->pages)); in ttm_pool_alloc_order_caching_match()
266 static void ttm_pool_alloc_caching_mismatch(struct kunit *test) in ttm_pool_alloc_caching_mismatch() argument
277 pool = ttm_pool_pre_populated(test, size, pool_caching); in ttm_pool_alloc_caching_mismatch()
282 tt = ttm_tt_kunit_init(test, 0, tt_caching, size); in ttm_pool_alloc_caching_mismatch()
283 KUNIT_ASSERT_NOT_NULL(test, tt); in ttm_pool_alloc_caching_mismatch()
285 KUNIT_ASSERT_FALSE(test, list_empty(&pt_pool->pages)); in ttm_pool_alloc_caching_mismatch()
286 KUNIT_ASSERT_TRUE(test, list_empty(&pt_tt->pages)); in ttm_pool_alloc_caching_mismatch()
289 KUNIT_ASSERT_EQ(test, err, 0); in ttm_pool_alloc_caching_mismatch()
294 KUNIT_ASSERT_FALSE(test, list_empty(&pt_pool->pages)); in ttm_pool_alloc_caching_mismatch()
295 KUNIT_ASSERT_FALSE(test, list_empty(&pt_tt->pages)); in ttm_pool_alloc_caching_mismatch()
300 static void ttm_pool_alloc_order_mismatch(struct kunit *test) in ttm_pool_alloc_order_mismatch() argument
311 pool = ttm_pool_pre_populated(test, fst_size, caching); in ttm_pool_alloc_order_mismatch()
316 tt = ttm_tt_kunit_init(test, 0, caching, snd_size); in ttm_pool_alloc_order_mismatch()
317 KUNIT_ASSERT_NOT_NULL(test, tt); in ttm_pool_alloc_order_mismatch()
319 KUNIT_ASSERT_FALSE(test, list_empty(&pt_pool->pages)); in ttm_pool_alloc_order_mismatch()
320 KUNIT_ASSERT_TRUE(test, list_empty(&pt_tt->pages)); in ttm_pool_alloc_order_mismatch()
323 KUNIT_ASSERT_EQ(test, err, 0); in ttm_pool_alloc_order_mismatch()
328 KUNIT_ASSERT_FALSE(test, list_empty(&pt_pool->pages)); in ttm_pool_alloc_order_mismatch()
329 KUNIT_ASSERT_FALSE(test, list_empty(&pt_tt->pages)); in ttm_pool_alloc_order_mismatch()
334 static void ttm_pool_free_dma_alloc(struct kunit *test) in ttm_pool_free_dma_alloc() argument
336 struct ttm_pool_test_priv *priv = test->priv; in ttm_pool_free_dma_alloc()
345 tt = ttm_tt_kunit_init(test, 0, caching, size); in ttm_pool_free_dma_alloc()
346 KUNIT_ASSERT_NOT_NULL(test, tt); in ttm_pool_free_dma_alloc()
348 pool = kunit_kzalloc(test, sizeof(*pool), GFP_KERNEL); in ttm_pool_free_dma_alloc()
349 KUNIT_ASSERT_NOT_NULL(test, pool); in ttm_pool_free_dma_alloc()
355 KUNIT_ASSERT_TRUE(test, list_empty(&pt->pages)); in ttm_pool_free_dma_alloc()
360 KUNIT_ASSERT_FALSE(test, list_empty(&pt->pages)); in ttm_pool_free_dma_alloc()
365 static void ttm_pool_free_no_dma_alloc(struct kunit *test) in ttm_pool_free_no_dma_alloc() argument
367 struct ttm_pool_test_priv *priv = test->priv; in ttm_pool_free_no_dma_alloc()
376 tt = ttm_tt_kunit_init(test, 0, caching, size); in ttm_pool_free_no_dma_alloc()
377 KUNIT_ASSERT_NOT_NULL(test, tt); in ttm_pool_free_no_dma_alloc()
379 pool = kunit_kzalloc(test, sizeof(*pool), GFP_KERNEL); in ttm_pool_free_no_dma_alloc()
380 KUNIT_ASSERT_NOT_NULL(test, pool); in ttm_pool_free_no_dma_alloc()
386 KUNIT_ASSERT_TRUE(test, list_is_singular(&pt->pages)); in ttm_pool_free_no_dma_alloc()
391 KUNIT_ASSERT_TRUE(test, list_is_singular(&pt->pages)); in ttm_pool_free_no_dma_alloc()
396 static void ttm_pool_fini_basic(struct kunit *test) in ttm_pool_fini_basic() argument
404 pool = ttm_pool_pre_populated(test, size, caching); in ttm_pool_fini_basic()
407 KUNIT_ASSERT_FALSE(test, list_empty(&pt->pages)); in ttm_pool_fini_basic()
411 KUNIT_ASSERT_TRUE(test, list_empty(&pt->pages)); in ttm_pool_fini_basic()