Skip to content

Commit 37da312

Browse files
nashifcfriedt
authored andcommitted
Revert "ztest: Fix test statistics reporting"
This reverts commit 2af5ac8. Failures are not being captured correctly now: - PASS - [test_c_lib.test_strtoul] duration = 0.001 seconds - PASS - [test_c_lib.test_strxspn] duration = 0.001 seconds - FAIL - [test_c_lib.test_that_fails] duration = 0.002 seconds - PASS - [test_c_lib.test_time] duration = 0.001 seconds - PASS - [test_c_lib.test_tolower_toupper] duration = 0.001 seconds ------ TESTSUITE SUMMARY END ------ =================================================================== PROJECT EXECUTION SUCCESSFUL Signed-off-by: Anas Nashif <[email protected]>
1 parent cbc5ee3 commit 37da312

File tree

2 files changed

+9
-31
lines changed

2 files changed

+9
-31
lines changed

subsys/testsuite/include/zephyr/tc_util.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
#define TC_PASS 0
6868
#define TC_FAIL 1
6969
#define TC_SKIP 2
70-
#define TC_FLAKY 3
7170

7271
#ifndef TC_PASS_STR
7372
#define TC_PASS_STR "PASS"
@@ -78,9 +77,6 @@
7877
#ifndef TC_SKIP_STR
7978
#define TC_SKIP_STR "SKIP"
8079
#endif
81-
#ifndef TC_FLAKY_STR
82-
#define TC_FLAKY_STR "FLAKY"
83-
#endif
8480

8581
static inline const char *TC_RESULT_TO_STR(int result)
8682
{
@@ -91,8 +87,6 @@ static inline const char *TC_RESULT_TO_STR(int result)
9187
return TC_FAIL_STR;
9288
case TC_SKIP:
9389
return TC_SKIP_STR;
94-
case TC_FLAKY:
95-
return TC_FLAKY_STR;
9690
default:
9791
return "?";
9892
}

subsys/testsuite/ztest/src/ztest_new.c

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ static int z_ztest_run_test_suite_ptr(struct ztest_suite_node *suite)
675675
int fail = 0;
676676
int tc_result = TC_PASS;
677677

678-
if (test_status != ZTEST_STATUS_OK) {
678+
if (test_status < 0) {
679679
return test_status;
680680
}
681681

@@ -766,7 +766,7 @@ static int z_ztest_run_test_suite_ptr(struct ztest_suite_node *suite)
766766
}
767767
#endif
768768

769-
if (test_status == ZTEST_STATUS_OK && fail != 0 && FAIL_FAST) {
769+
if (test_status == ZTEST_STATUS_OK && fail != 0) {
770770
test_status = ZTEST_STATUS_HAS_FAILURE;
771771
}
772772
}
@@ -882,28 +882,15 @@ static void __ztest_show_suite_summary_verbose(struct ztest_suite_node *suite)
882882
tc_result = TC_SKIP;
883883
} else if (test->stats->pass_count == test->stats->run_count) {
884884
tc_result = TC_PASS;
885-
} else if (test->stats->pass_count == 0) {
886-
tc_result = TC_FAIL;
887885
} else {
888-
tc_result = TC_FLAKY;
886+
tc_result = TC_FAIL;
889887
}
890888

891-
if (tc_result == TC_FLAKY) {
892-
TC_SUMMARY_PRINT(" - %s - [%s.%s] - (Failed %d of %d attempts)"
893-
" - duration = %u.%03u seconds\n",
894-
TC_RESULT_TO_STR(tc_result),
895-
test->test_suite_name, test->name,
896-
test->stats->run_count - test->stats->pass_count,
897-
test->stats->run_count,
898-
test->stats->duration_worst_ms / 1000,
899-
test->stats->duration_worst_ms % 1000);
900-
} else {
901-
TC_SUMMARY_PRINT(" - %s - [%s.%s] duration = %u.%03u seconds\n",
902-
TC_RESULT_TO_STR(tc_result),
903-
test->test_suite_name, test->name,
904-
test->stats->duration_worst_ms / 1000,
905-
test->stats->duration_worst_ms % 1000);
906-
}
889+
TC_SUMMARY_PRINT(" - %s - [%s.%s] duration = %u.%03u seconds\n",
890+
TC_RESULT_TO_STR(tc_result),
891+
test->test_suite_name, test->name,
892+
test->stats->duration_worst_ms / 1000,
893+
test->stats->duration_worst_ms % 1000);
907894

908895
if (flush_frequency % 3 == 0) {
909896
/** Reduce the flush frequencey a bit to speed up the output */
@@ -943,6 +930,7 @@ static int __ztest_run_test_suite(struct ztest_suite_node *ptr, const void *stat
943930

944931
for (int i = 0; i < NUM_ITER_PER_SUITE; i++) {
945932
if (ztest_api.should_suite_run(state, ptr)) {
933+
__ztest_init_unit_test_result_for_suite(ptr);
946934
int fail = z_ztest_run_test_suite_ptr(ptr);
947935

948936
count++;
@@ -970,9 +958,6 @@ int z_impl_ztest_run_test_suites(const void *state)
970958
memset(suites_to_run, 0, ZTEST_SUITE_COUNT * sizeof(struct ztest_suite_node *));
971959
z_ztest_shuffle((void **)suites_to_run, (intptr_t)_ztest_suite_node_list_start,
972960
ZTEST_SUITE_COUNT, sizeof(struct ztest_suite_node));
973-
for (size_t i = 0; i < ZTEST_SUITE_COUNT; ++i) {
974-
__ztest_init_unit_test_result_for_suite(suites_to_run[i]);
975-
}
976961
for (size_t i = 0; i < ZTEST_SUITE_COUNT; ++i) {
977962
count += __ztest_run_test_suite(suites_to_run[i], state);
978963
/* Stop running tests if we have a critical error or if we have a failure and
@@ -986,7 +971,6 @@ int z_impl_ztest_run_test_suites(const void *state)
986971
#else
987972
for (struct ztest_suite_node *ptr = _ztest_suite_node_list_start;
988973
ptr < _ztest_suite_node_list_end; ++ptr) {
989-
__ztest_init_unit_test_result_for_suite(ptr);
990974
count += __ztest_run_test_suite(ptr, state);
991975
/* Stop running tests if we have a critical error or if we have a failure and
992976
* FAIL_FAST was set

0 commit comments

Comments
 (0)