Lines Matching refs:test

85 static int cleanup_test(struct ztest_unit_test *test)  in cleanup_test()  argument
103 PRINT_DATA("Test %s failed: Unused mock parameter values\n", test->name); in cleanup_test()
106 PRINT_DATA("Test %s failed: Unused mock return values\n", test->name); in cleanup_test()
312 __maybe_unused static void run_test_rules(bool is_before, struct ztest_unit_test *test, void *data) in run_test_rules() argument
317 rule->before_each(test, data); in run_test_rules()
319 rule->after_each(test, data); in run_test_rules()
324 static void run_test_functions(struct ztest_suite_node *suite, struct ztest_unit_test *test, in run_test_functions() argument
328 test->test(data); in run_test_functions()
333 static int get_final_test_result(const struct ztest_unit_test *test, int ret) in get_final_test_result() argument
340 if (strcmp(expectation->test_name, test->name) == 0 && in get_final_test_result()
341 strcmp(expectation->test_suite_name, test->test_suite_name) == 0) { in get_final_test_result()
488 static int run_test(struct ztest_suite_node *suite, struct ztest_unit_test *test, void *data) in run_test() argument
492 TC_START(test->name); in run_test()
515 run_test_rules(/*is_before=*/true, test, data); in run_test()
519 run_test_functions(suite, test, data); in run_test()
531 run_test_rules(/*is_before=*/false, test, data); in run_test()
534 ret |= cleanup_test(test); in run_test()
536 ret = get_final_test_result(test, ret); in run_test()
537 Z_TC_END_RESULT(ret, test->name); in run_test()
649 struct ztest_unit_test *test = b; in test_cb() local
650 const bool config_user_mode = FIELD_GET(K_USER, test->thread_options) != 0; in test_cb()
654 run_test_rules(/*is_before=*/true, test, /*data=*/c); in test_cb()
662 run_test_functions(suite, test, c); in test_cb()
666 static int run_test(struct ztest_suite_node *suite, struct ztest_unit_test *test, void *data) in run_test() argument
673 TC_START(test->name); in run_test()
683 K_THREAD_STACK_SIZEOF(ztest_thread_stack), test_cb, suite, test, in run_test()
686 k_thread_access_grant(&ztest_thread, suite, test, suite->stats); in run_test()
687 if (test->name != NULL) { in run_test()
688 k_thread_name_set(&ztest_thread, test->name); in run_test()
700 run_test_rules(/*is_before=*/true, test, data); in run_test()
704 run_test_functions(suite, test, data); in run_test()
711 run_test_rules(/*is_before=*/false, test, data); in run_test()
714 if (tc_spend_time > test->stats->duration_worst_ms) { in run_test()
715 test->stats->duration_worst_ms = tc_spend_time; in run_test()
735 ret |= cleanup_test(test); in run_test()
738 ret = get_final_test_result(test, ret); in run_test()
739 Z_TC_END_RESULT(ret, test->name); in run_test()
764 struct ztest_unit_test *test = (prev == NULL) ? _ztest_unit_test_list_start : prev + 1; in z_ztest_get_next_test() local
766 for (; test < _ztest_unit_test_list_end; ++test) { in z_ztest_get_next_test()
767 if (strcmp(suite, test->test_suite_name) == 0) { in z_ztest_get_next_test()
768 return test; in z_ztest_get_next_test()
802 struct ztest_unit_test *test = NULL; in z_ztest_run_test_suite_ptr() local
852 test = tests_to_run[j]; in z_ztest_run_test_suite_ptr()
854 if (strcmp(suite->name, test->test_suite_name) != 0) { in z_ztest_run_test_suite_ptr()
857 if (ztest_api.should_test_run(suite->name, test->name)) { in z_ztest_run_test_suite_ptr()
858 test->stats->run_count++; in z_ztest_run_test_suite_ptr()
859 tc_result = run_test(suite, test, data); in z_ztest_run_test_suite_ptr()
861 test->stats->pass_count++; in z_ztest_run_test_suite_ptr()
863 test->stats->skip_count++; in z_ztest_run_test_suite_ptr()
865 test->stats->fail_count++; in z_ztest_run_test_suite_ptr()
877 while (((test = z_ztest_get_next_test(suite->name, test)) != NULL)) { in z_ztest_run_test_suite_ptr()
878 if (ztest_api.should_test_run(suite->name, test->name)) { in z_ztest_run_test_suite_ptr()
879 test->stats->run_count++; in z_ztest_run_test_suite_ptr()
880 tc_result = run_test(suite, test, data); in z_ztest_run_test_suite_ptr()
882 test->stats->pass_count++; in z_ztest_run_test_suite_ptr()
884 test->stats->skip_count++; in z_ztest_run_test_suite_ptr()
886 test->stats->fail_count++; in z_ztest_run_test_suite_ptr()
926 struct ztest_unit_test *test = NULL; in __ztest_init_unit_test_result_for_suite() local
928 while (((test = z_ztest_get_next_test(suite->name, test)) != NULL)) { in __ztest_init_unit_test_result_for_suite()
929 test->stats->run_count = 0; in __ztest_init_unit_test_result_for_suite()
930 test->stats->skip_count = 0; in __ztest_init_unit_test_result_for_suite()
931 test->stats->fail_count = 0; in __ztest_init_unit_test_result_for_suite()
932 test->stats->pass_count = 0; in __ztest_init_unit_test_result_for_suite()
933 test->stats->duration_worst_ms = 0; in __ztest_init_unit_test_result_for_suite()
960 struct ztest_unit_test *test = NULL; in __ztest_show_suite_summary_oneline() local
964 while (((test = z_ztest_get_next_test(suite->name, test)) != NULL)) { in __ztest_show_suite_summary_oneline()
966 suite_duration_worst_ms += test->stats->duration_worst_ms; in __ztest_show_suite_summary_oneline()
967 if (test->stats->skip_count == test->stats->run_count) { in __ztest_show_suite_summary_oneline()
969 } else if (test->stats->pass_count == test->stats->run_count) { in __ztest_show_suite_summary_oneline()
1002 struct ztest_unit_test *test = NULL; in __ztest_show_suite_summary_verbose() local
1010 while (((test = z_ztest_get_next_test(suite->name, test)) != NULL)) { in __ztest_show_suite_summary_verbose()
1011 if (test->stats->skip_count == test->stats->run_count) { in __ztest_show_suite_summary_verbose()
1013 } else if (test->stats->pass_count == test->stats->run_count) { in __ztest_show_suite_summary_verbose()
1015 } else if (test->stats->pass_count == 0) { in __ztest_show_suite_summary_verbose()
1025 TC_RESULT_TO_STR(tc_result), test->test_suite_name, test->name, in __ztest_show_suite_summary_verbose()
1026 test->stats->run_count - test->stats->pass_count, in __ztest_show_suite_summary_verbose()
1027 test->stats->run_count, test->stats->duration_worst_ms / 1000, in __ztest_show_suite_summary_verbose()
1028 test->stats->duration_worst_ms % 1000); in __ztest_show_suite_summary_verbose()
1031 TC_RESULT_TO_STR(tc_result), test->test_suite_name, in __ztest_show_suite_summary_verbose()
1032 test->name, test->stats->duration_worst_ms / 1000, in __ztest_show_suite_summary_verbose()
1033 test->stats->duration_worst_ms % 1000); in __ztest_show_suite_summary_verbose()
1167 struct ztest_unit_test *test; in ztest_verify_all_test_suites_ran() local
1178 for (test = _ztest_unit_test_list_start; test < _ztest_unit_test_list_end; ++test) { in ztest_verify_all_test_suites_ran()
1179 suite = ztest_find_test_suite(test->test_suite_name); in ztest_verify_all_test_suites_ran()
1184 test->name, test->test_suite_name); in ztest_verify_all_test_suites_ran()
1194 for (test = _ztest_unit_test_list_start; test < _ztest_unit_test_list_end; ++test) { in ztest_verify_all_test_suites_ran()
1195 if (test->stats->fail_count + test->stats->pass_count + test->stats->skip_count != in ztest_verify_all_test_suites_ran()
1196 test->stats->run_count) { in ztest_verify_all_test_suites_ran()
1197 PRINT_DATA("Bad stats for %s.%s\n", test->test_suite_name, test->name); in ztest_verify_all_test_suites_ran()
1256 struct ztest_unit_test *test = NULL; in cmd_list_cases() local
1260 test = NULL; in cmd_list_cases()
1261 while ((test = z_ztest_get_next_test(ptr->name, test)) != NULL) { in cmd_list_cases()
1262 shell_print(sh, "%s::%s", test->test_suite_name, test->name); in cmd_list_cases()