Lines Matching refs:test

3  * KUnit resource API for test managed resources (allocations, etc.).
12 #include <kunit/test.h>
25 * struct kunit_resource - represents a *test managed resource*
30 * Represents a *test managed resource*, a resource which will automatically be
31 * cleaned up at the end of a test case. This cleanup is performed by the 'free'
67 * void *kunit_kmalloc(struct kunit *test, size_t size, gfp_t gfp)
74 * return kunit_alloc_resource(test, kunit_kmalloc_init,
81 * unique within the test instance.
145 * @test: The test context object.
153 int __kunit_add_resource(struct kunit *test,
160 * kunit_add_resource() - Add a *test managed resource*.
161 * @test: The test context object.
169 static inline int kunit_add_resource(struct kunit *test,
176 return __kunit_add_resource(test, init, free, res, data);
180 kunit_find_named_resource(struct kunit *test, const char *name);
183 * kunit_add_named_resource() - Add a named *test managed resource*.
184 * @test: The test context object.
191 static inline int kunit_add_named_resource(struct kunit *test,
203 existing = kunit_find_named_resource(test, name);
212 return __kunit_add_resource(test, init, free, res, data);
216 * kunit_alloc_and_get_resource() - Allocates and returns a *test managed resource*.
217 * @test: The test context object.
223 * Allocates a *test managed resource*, a resource which will automatically be
224 * cleaned up at the end of a test case. See &struct kunit_resource for an
237 kunit_alloc_and_get_resource(struct kunit *test,
252 ret = __kunit_add_resource(test, init, free, res, context);
265 * kunit_alloc_resource() - Allocates a *test managed resource*.
266 * @test: The test context object.
272 * Allocates a *test managed resource*, a resource which will automatically be
273 * cleaned up at the end of a test case. See &struct kunit_resource for an
280 static inline void *kunit_alloc_resource(struct kunit *test,
293 if (!__kunit_add_resource(test, init, free, res, context))
299 typedef bool (*kunit_resource_match_t)(struct kunit *test,
305 * @test: Test case to which the resource belongs.
309 static inline bool kunit_resource_name_match(struct kunit *test,
318 * @test: Test case to which the resource belongs.
323 kunit_find_resource(struct kunit *test,
330 spin_lock_irqsave(&test->lock, flags);
332 list_for_each_entry_reverse(res, &test->resources, node) {
333 if (match(test, res, (void *)match_data)) {
340 spin_unlock_irqrestore(&test->lock, flags);
347 * @test: Test case to which the resource belongs.
351 kunit_find_named_resource(struct kunit *test,
354 return kunit_find_resource(test, kunit_resource_name_match,
360 * @test: Test case to which the resource belongs.
367 int kunit_destroy_resource(struct kunit *test,
371 static inline int kunit_destroy_named_resource(struct kunit *test,
374 return kunit_destroy_resource(test, kunit_resource_name_match,
380 * test.
381 * @test: The test context object.
388 void kunit_remove_resource(struct kunit *test, struct kunit_resource *res);
415 * kunit_add_action() - Call a function when the test ends.
416 * @test: Test case to associate the action with.
417 * @action: The function to run on test exit
420 * Defer the execution of a function until the test exits, either normally or
426 * functions are called even if the test aborts early due to, e.g., a failed
434 int kunit_add_action(struct kunit *test, kunit_action_t *action, void *ctx);
437 * kunit_add_action_or_reset() - Call a function when the test ends.
438 * @test: Test case to associate the action with.
439 * @action: The function to run on test exit
442 * Defer the execution of a function until the test exits, either normally or
448 * functions are called even if the test aborts early due to, e.g., a failed
459 int kunit_add_action_or_reset(struct kunit *test, kunit_action_t *action,
464 * @test: Test case the action is associated with.
469 * test terminates.
476 void kunit_remove_action(struct kunit *test,
482 * @test: Test case the action is associated with.
487 * when the test ends.
491 * the test ends.
493 * kunit_release_action(test, func, ctx);
496 * kunit_remove_action(test, func, ctx);
500 void kunit_release_action(struct kunit *test,