Lines Matching refs:test
97 static void kunit_print_test_stats(struct kunit *test, in kunit_print_test_stats() argument
103 kunit_log(KERN_INFO, test, in kunit_print_test_stats()
106 test->name, in kunit_print_test_stats()
198 static void kunit_print_ok_not_ok(struct kunit *test, in kunit_print_ok_not_ok() argument
212 WARN(!test && test_level, "suite test level can't be %u!\n", test_level); in kunit_print_ok_not_ok()
221 if (!test) in kunit_print_ok_not_ok()
227 kunit_log(KERN_INFO, test, in kunit_print_ok_not_ok()
281 static void kunit_print_string_stream(struct kunit *test, in kunit_print_string_stream() argument
292 kunit_err(test, in kunit_print_string_stream()
295 kunit_err(test, "%s", fragment->fragment); in kunit_print_string_stream()
297 kunit_err(test, "\n"); in kunit_print_string_stream()
299 kunit_err(test, "%s", buf); in kunit_print_string_stream()
300 kunit_kfree(test, buf); in kunit_print_string_stream()
304 static void kunit_fail(struct kunit *test, const struct kunit_loc *loc, in kunit_fail() argument
310 kunit_set_failure(test); in kunit_fail()
312 stream = alloc_string_stream(test, GFP_KERNEL); in kunit_fail()
324 kunit_print_string_stream(test, stream); in kunit_fail()
329 void __noreturn __kunit_abort(struct kunit *test) in __kunit_abort() argument
331 kunit_try_catch_throw(&test->try_catch); /* Does not return. */ in __kunit_abort()
343 void __kunit_do_failed_assertion(struct kunit *test, in __kunit_do_failed_assertion() argument
357 kunit_fail(test, loc, type, assert, assert_format, &message); in __kunit_do_failed_assertion()
363 void kunit_init_test(struct kunit *test, const char *name, char *log) in kunit_init_test() argument
365 spin_lock_init(&test->lock); in kunit_init_test()
366 INIT_LIST_HEAD(&test->resources); in kunit_init_test()
367 test->name = name; in kunit_init_test()
368 test->log = log; in kunit_init_test()
369 if (test->log) in kunit_init_test()
370 test->log[0] = '\0'; in kunit_init_test()
371 test->status = KUNIT_SUCCESS; in kunit_init_test()
372 test->status_comment[0] = '\0'; in kunit_init_test()
387 static void kunit_run_case_check_speed(struct kunit *test, in kunit_run_case_check_speed() argument
401 kunit_warn(test, in kunit_run_case_check_speed()
409 static void kunit_run_case_internal(struct kunit *test, in kunit_run_case_internal() argument
418 ret = suite->init(test); in kunit_run_case_internal()
420 kunit_err(test, "failed to initialize: %d\n", ret); in kunit_run_case_internal()
421 kunit_set_failure(test); in kunit_run_case_internal()
428 test_case->run_case(test); in kunit_run_case_internal()
432 kunit_run_case_check_speed(test, test_case, timespec64_sub(end, start)); in kunit_run_case_internal()
435 static void kunit_case_internal_cleanup(struct kunit *test) in kunit_case_internal_cleanup() argument
437 kunit_cleanup(test); in kunit_case_internal_cleanup()
444 static void kunit_run_case_cleanup(struct kunit *test, in kunit_run_case_cleanup() argument
448 suite->exit(test); in kunit_run_case_cleanup()
450 kunit_case_internal_cleanup(test); in kunit_run_case_cleanup()
454 struct kunit *test; member
462 struct kunit *test = ctx->test; in kunit_try_run_case() local
466 current->kunit_test = test; in kunit_try_run_case()
473 kunit_run_case_internal(test, suite, test_case); in kunit_try_run_case()
479 struct kunit *test = ctx->test; in kunit_try_run_case_cleanup() local
482 current->kunit_test = test; in kunit_try_run_case_cleanup()
484 kunit_run_case_cleanup(test, suite); in kunit_try_run_case_cleanup()
490 struct kunit *test = ctx->test; in kunit_catch_run_case_cleanup() local
491 int try_exit_code = kunit_try_catch_get_result(&test->try_catch); in kunit_catch_run_case_cleanup()
494 kunit_set_failure(test); in kunit_catch_run_case_cleanup()
502 kunit_err(test, "test case cleanup timed out\n"); in kunit_catch_run_case_cleanup()
508 kunit_err(test, "internal error occurred during test case cleanup: %d\n", in kunit_catch_run_case_cleanup()
514 kunit_err(test, "test aborted during cleanup. continuing without cleaning up\n"); in kunit_catch_run_case_cleanup()
521 struct kunit *test = ctx->test; in kunit_catch_run_case() local
522 int try_exit_code = kunit_try_catch_get_result(&test->try_catch); in kunit_catch_run_case()
525 kunit_set_failure(test); in kunit_catch_run_case()
531 kunit_err(test, "test case timed out\n"); in kunit_catch_run_case()
537 kunit_err(test, "internal error occurred preventing test case from running: %d\n", in kunit_catch_run_case()
550 struct kunit *test) in kunit_run_case_catch_errors() argument
555 try_catch = &test->try_catch; in kunit_run_case_catch_errors()
558 test, in kunit_run_case_catch_errors()
561 context.test = test; in kunit_run_case_catch_errors()
568 test, in kunit_run_case_catch_errors()
574 if (test->status == KUNIT_FAILURE) in kunit_run_case_catch_errors()
576 else if (test_case->status != KUNIT_FAILURE && test->status == KUNIT_SUCCESS) in kunit_run_case_catch_errors()
653 struct kunit test = { .param_value = NULL, .param_index = 0 }; in kunit_run_tests() local
656 kunit_init_test(&test, test_case->name, test_case->log); in kunit_run_tests()
659 test.status = KUNIT_SKIPPED; in kunit_run_tests()
660 kunit_update_stats(¶m_stats, test.status); in kunit_run_tests()
664 kunit_run_case_catch_errors(suite, test_case, &test); in kunit_run_tests()
665 kunit_update_stats(¶m_stats, test.status); in kunit_run_tests()
669 test.param_value = test_case->generate_params(NULL, param_desc); in kunit_run_tests()
671 kunit_log(KERN_INFO, &test, KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT in kunit_run_tests()
673 kunit_log(KERN_INFO, &test, KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT in kunit_run_tests()
676 while (test.param_value) { in kunit_run_tests()
677 kunit_run_case_catch_errors(suite, test_case, &test); in kunit_run_tests()
681 "param-%d", test.param_index); in kunit_run_tests()
684 kunit_print_ok_not_ok(&test, KUNIT_LEVEL_CASE_PARAM, in kunit_run_tests()
685 test.status, in kunit_run_tests()
686 test.param_index + 1, in kunit_run_tests()
688 test.status_comment); in kunit_run_tests()
692 test.param_value = test_case->generate_params(test.param_value, param_desc); in kunit_run_tests()
693 test.param_index++; in kunit_run_tests()
695 kunit_update_stats(¶m_stats, test.status); in kunit_run_tests()
701 kunit_print_test_stats(&test, param_stats); in kunit_run_tests()
703 kunit_print_ok_not_ok(&test, KUNIT_LEVEL_CASE, test_case->status, in kunit_run_tests()
706 test.status_comment); in kunit_run_tests()
853 void *kunit_kmalloc_array(struct kunit *test, size_t n, size_t size, gfp_t gfp) in kunit_kmalloc_array() argument
862 if (kunit_add_action_or_reset(test, (kunit_action_t *)kfree, data) != 0) in kunit_kmalloc_array()
869 void kunit_kfree(struct kunit *test, const void *ptr) in kunit_kfree() argument
874 kunit_release_action(test, (kunit_action_t *)kfree, (void *)ptr); in kunit_kfree()
878 void kunit_cleanup(struct kunit *test) in kunit_cleanup() argument
893 spin_lock_irqsave(&test->lock, flags); in kunit_cleanup()
894 if (list_empty(&test->resources)) { in kunit_cleanup()
895 spin_unlock_irqrestore(&test->lock, flags); in kunit_cleanup()
898 res = list_last_entry(&test->resources, in kunit_cleanup()
906 spin_unlock_irqrestore(&test->lock, flags); in kunit_cleanup()
907 kunit_remove_resource(test, res); in kunit_cleanup()