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); 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()
84 tt = ttm_tt_kunit_init(test, order, caching, size); in ttm_pool_pre_populated()
85 KUNIT_ASSERT_NOT_NULL(test, tt); in ttm_pool_pre_populated()
87 pool = kunit_kzalloc(test, sizeof(*pool), GFP_KERNEL); in ttm_pool_pre_populated()
88 KUNIT_ASSERT_NOT_NULL(test, pool); in ttm_pool_pre_populated()
93 KUNIT_ASSERT_EQ(test, err, 0); in ttm_pool_pre_populated()
135 static void ttm_pool_alloc_basic(struct kunit *test) in ttm_pool_alloc_basic() argument
137 struct ttm_pool_test_priv *priv = test->priv; in ttm_pool_alloc_basic()
139 const struct ttm_pool_test_case *params = test->param_value; in ttm_pool_alloc_basic()
148 tt = ttm_tt_kunit_init(test, 0, caching, size); in ttm_pool_alloc_basic()
149 KUNIT_ASSERT_NOT_NULL(test, tt); in ttm_pool_alloc_basic()
151 pool = kunit_kzalloc(test, sizeof(*pool), GFP_KERNEL); in ttm_pool_alloc_basic()
152 KUNIT_ASSERT_NOT_NULL(test, pool); in ttm_pool_alloc_basic()
157 KUNIT_ASSERT_PTR_EQ(test, pool->dev, devs->dev); in ttm_pool_alloc_basic()
158 KUNIT_ASSERT_EQ(test, pool->nid, NUMA_NO_NODE); in ttm_pool_alloc_basic()
159 KUNIT_ASSERT_EQ(test, pool->use_dma_alloc, params->use_dma_alloc); in ttm_pool_alloc_basic()
162 KUNIT_ASSERT_EQ(test, err, 0); in ttm_pool_alloc_basic()
163 KUNIT_ASSERT_EQ(test, tt->num_pages, expected_num_pages); in ttm_pool_alloc_basic()
170 KUNIT_ASSERT_NOT_NULL(test, (void *)fst_page->private); in ttm_pool_alloc_basic()
171 KUNIT_ASSERT_NOT_NULL(test, (void *)last_page->private); in ttm_pool_alloc_basic()
173 KUNIT_ASSERT_EQ(test, fst_page->private, params->order); in ttm_pool_alloc_basic()
177 KUNIT_ASSERT_NOT_NULL(test, (void *)fst_page->private); in ttm_pool_alloc_basic()
178 KUNIT_ASSERT_NULL(test, (void *)last_page->private); in ttm_pool_alloc_basic()
184 KUNIT_ASSERT_EQ(test, fst_page->private, in ttm_pool_alloc_basic()
187 KUNIT_ASSERT_EQ(test, last_page->private, 0); in ttm_pool_alloc_basic()
196 static void ttm_pool_alloc_basic_dma_addr(struct kunit *test) in ttm_pool_alloc_basic_dma_addr() argument
198 struct ttm_pool_test_priv *priv = test->priv; in ttm_pool_alloc_basic_dma_addr()
200 const struct ttm_pool_test_case *params = test->param_value; in ttm_pool_alloc_basic_dma_addr()
210 tt = kunit_kzalloc(test, sizeof(*tt), GFP_KERNEL); in ttm_pool_alloc_basic_dma_addr()
211 KUNIT_ASSERT_NOT_NULL(test, tt); in ttm_pool_alloc_basic_dma_addr()
213 bo = ttm_bo_kunit_init(test, devs, size); in ttm_pool_alloc_basic_dma_addr()
214 KUNIT_ASSERT_NOT_NULL(test, bo); in ttm_pool_alloc_basic_dma_addr()
217 KUNIT_ASSERT_EQ(test, err, 0); in ttm_pool_alloc_basic_dma_addr()
219 pool = kunit_kzalloc(test, sizeof(*pool), GFP_KERNEL); in ttm_pool_alloc_basic_dma_addr()
220 KUNIT_ASSERT_NOT_NULL(test, pool); in ttm_pool_alloc_basic_dma_addr()
225 KUNIT_ASSERT_EQ(test, err, 0); in ttm_pool_alloc_basic_dma_addr()
226 KUNIT_ASSERT_EQ(test, tt->num_pages, expected_num_pages); in ttm_pool_alloc_basic_dma_addr()
231 KUNIT_ASSERT_NOT_NULL(test, (void *)(uintptr_t)dma1); in ttm_pool_alloc_basic_dma_addr()
232 KUNIT_ASSERT_NOT_NULL(test, (void *)(uintptr_t)dma2); in ttm_pool_alloc_basic_dma_addr()
239 static void ttm_pool_alloc_order_caching_match(struct kunit *test) in ttm_pool_alloc_order_caching_match() argument
249 pool = ttm_pool_pre_populated(test, size, caching); in ttm_pool_alloc_order_caching_match()
252 KUNIT_ASSERT_FALSE(test, list_empty(&pt->pages)); in ttm_pool_alloc_order_caching_match()
254 tt = ttm_tt_kunit_init(test, 0, caching, size); in ttm_pool_alloc_order_caching_match()
255 KUNIT_ASSERT_NOT_NULL(test, tt); in ttm_pool_alloc_order_caching_match()
258 KUNIT_ASSERT_EQ(test, err, 0); in ttm_pool_alloc_order_caching_match()
260 KUNIT_ASSERT_TRUE(test, list_empty(&pt->pages)); in ttm_pool_alloc_order_caching_match()
267 static void ttm_pool_alloc_caching_mismatch(struct kunit *test) in ttm_pool_alloc_caching_mismatch() argument
278 pool = ttm_pool_pre_populated(test, size, pool_caching); in ttm_pool_alloc_caching_mismatch()
283 tt = ttm_tt_kunit_init(test, 0, tt_caching, size); in ttm_pool_alloc_caching_mismatch()
284 KUNIT_ASSERT_NOT_NULL(test, tt); in ttm_pool_alloc_caching_mismatch()
286 KUNIT_ASSERT_FALSE(test, list_empty(&pt_pool->pages)); in ttm_pool_alloc_caching_mismatch()
287 KUNIT_ASSERT_TRUE(test, list_empty(&pt_tt->pages)); in ttm_pool_alloc_caching_mismatch()
290 KUNIT_ASSERT_EQ(test, err, 0); in ttm_pool_alloc_caching_mismatch()
295 KUNIT_ASSERT_FALSE(test, list_empty(&pt_pool->pages)); in ttm_pool_alloc_caching_mismatch()
296 KUNIT_ASSERT_FALSE(test, list_empty(&pt_tt->pages)); in ttm_pool_alloc_caching_mismatch()
301 static void ttm_pool_alloc_order_mismatch(struct kunit *test) in ttm_pool_alloc_order_mismatch() argument
312 pool = ttm_pool_pre_populated(test, fst_size, caching); in ttm_pool_alloc_order_mismatch()
317 tt = ttm_tt_kunit_init(test, 0, caching, snd_size); in ttm_pool_alloc_order_mismatch()
318 KUNIT_ASSERT_NOT_NULL(test, tt); in ttm_pool_alloc_order_mismatch()
320 KUNIT_ASSERT_FALSE(test, list_empty(&pt_pool->pages)); in ttm_pool_alloc_order_mismatch()
321 KUNIT_ASSERT_TRUE(test, list_empty(&pt_tt->pages)); in ttm_pool_alloc_order_mismatch()
324 KUNIT_ASSERT_EQ(test, err, 0); in ttm_pool_alloc_order_mismatch()
329 KUNIT_ASSERT_FALSE(test, list_empty(&pt_pool->pages)); in ttm_pool_alloc_order_mismatch()
330 KUNIT_ASSERT_FALSE(test, list_empty(&pt_tt->pages)); in ttm_pool_alloc_order_mismatch()
335 static void ttm_pool_free_dma_alloc(struct kunit *test) in ttm_pool_free_dma_alloc() argument
337 struct ttm_pool_test_priv *priv = test->priv; in ttm_pool_free_dma_alloc()
346 tt = ttm_tt_kunit_init(test, 0, caching, size); in ttm_pool_free_dma_alloc()
347 KUNIT_ASSERT_NOT_NULL(test, tt); in ttm_pool_free_dma_alloc()
349 pool = kunit_kzalloc(test, sizeof(*pool), GFP_KERNEL); in ttm_pool_free_dma_alloc()
350 KUNIT_ASSERT_NOT_NULL(test, pool); in ttm_pool_free_dma_alloc()
356 KUNIT_ASSERT_TRUE(test, list_empty(&pt->pages)); in ttm_pool_free_dma_alloc()
361 KUNIT_ASSERT_FALSE(test, list_empty(&pt->pages)); in ttm_pool_free_dma_alloc()
366 static void ttm_pool_free_no_dma_alloc(struct kunit *test) in ttm_pool_free_no_dma_alloc() argument
368 struct ttm_pool_test_priv *priv = test->priv; in ttm_pool_free_no_dma_alloc()
377 tt = ttm_tt_kunit_init(test, 0, caching, size); in ttm_pool_free_no_dma_alloc()
378 KUNIT_ASSERT_NOT_NULL(test, tt); in ttm_pool_free_no_dma_alloc()
380 pool = kunit_kzalloc(test, sizeof(*pool), GFP_KERNEL); in ttm_pool_free_no_dma_alloc()
381 KUNIT_ASSERT_NOT_NULL(test, pool); in ttm_pool_free_no_dma_alloc()
387 KUNIT_ASSERT_TRUE(test, list_is_singular(&pt->pages)); in ttm_pool_free_no_dma_alloc()
392 KUNIT_ASSERT_TRUE(test, list_is_singular(&pt->pages)); in ttm_pool_free_no_dma_alloc()
397 static void ttm_pool_fini_basic(struct kunit *test) in ttm_pool_fini_basic() argument
405 pool = ttm_pool_pre_populated(test, size, caching); in ttm_pool_fini_basic()
408 KUNIT_ASSERT_FALSE(test, list_empty(&pt->pages)); in ttm_pool_fini_basic()
412 KUNIT_ASSERT_TRUE(test, list_empty(&pt->pages)); in ttm_pool_fini_basic()