File tree Expand file tree Collapse file tree 6 files changed +28
-7
lines changed Expand file tree Collapse file tree 6 files changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -208,7 +208,6 @@ config ZTEST_VERBOSE_SUMMARY
208
208
209
209
config ZTEST_FAIL_ON_ASSUME
210
210
bool "Fail the test run when an assumption fails"
211
- default y
212
211
help
213
212
When enabled, the test binary will fail at the end if an assumption failed. This means
214
213
that while tests will still be marked as skipped on failed zassume calls, the final test
Original file line number Diff line number Diff line change @@ -393,8 +393,10 @@ void ztest_skip_failed_assumption(void)
393
393
{
394
394
if (IS_ENABLED (CONFIG_ZTEST_FAIL_ON_ASSUME )) {
395
395
current_test_failed_assumption = true;
396
+ ztest_test_fail ();
397
+ } else {
398
+ ztest_test_skip ();
396
399
}
397
- ztest_test_skip ();
398
400
}
399
401
400
402
#ifndef KERNEL
Original file line number Diff line number Diff line change @@ -30,7 +30,9 @@ string(REGEX MATCHALL "(^|;)CONFIG_ZTEST_FAIL_TEST_[A-Za-z0-9_]+" fail_test_conf
30
30
list (FILTER fail_test_config EXCLUDE REGEX "^$" )
31
31
list (TRANSFORM fail_test_config PREPEND "-D" )
32
32
list (TRANSFORM fail_test_config APPEND "=y" )
33
- string (REPLACE ";" " " fail_test_config "${fail_test_config} " )
33
+ if (CONFIG_ZTEST_FAIL_ON_ASSUME )
34
+ list (APPEND fail_test_config "-DCONFIG_ZTEST_FAIL_ON_ASSUME=y" )
35
+ endif ()
34
36
35
37
# Add the 'core' external project which will mirror the configs of this project.
36
38
ExternalProject_Add (core
Original file line number Diff line number Diff line change @@ -31,8 +31,10 @@ config TEST_ERROR_STRING
31
31
string
32
32
default "ERROR: cannot fail in test phase 'after()', bailing" if ZTEST_FAIL_TEST_ASSERT_AFTER
33
33
default "ERROR: cannot fail in test phase 'teardown()', bailing" if ZTEST_FAIL_TEST_ASSERT_TEARDOWN
34
- default "ERROR: cannot skip in test phase 'after()', bailing" if ZTEST_FAIL_TEST_ASSUME_AFTER
35
- default "ERROR: cannot skip in test phase 'teardown()', bailing" if ZTEST_FAIL_TEST_ASSUME_TEARDOWN
34
+ default "ERROR: cannot skip in test phase 'after()', bailing" if ZTEST_FAIL_TEST_ASSUME_AFTER && !ZTEST_FAIL_ON_ASSUME
35
+ default "ERROR: cannot skip in test phase 'teardown()', bailing" if ZTEST_FAIL_TEST_ASSUME_TEARDOWN && !ZTEST_FAIL_ON_ASSUME
36
+ default "ERROR: cannot fail in test phase 'after()', bailing" if ZTEST_FAIL_TEST_ASSUME_AFTER && ZTEST_FAIL_ON_ASSUME
37
+ default "ERROR: cannot fail in test phase 'teardown()', bailing" if ZTEST_FAIL_TEST_ASSUME_TEARDOWN && ZTEST_FAIL_ON_ASSUME
36
38
default "ERROR: cannot pass in test phase 'after()', bailing" if ZTEST_FAIL_TEST_PASS_AFTER
37
39
default "ERROR: cannot pass in test phase 'teardown()', bailing" if ZTEST_FAIL_TEST_PASS_TEARDOWN
38
40
default "Assumption failed at " if ZTEST_FAIL_TEST_UNEXPECTED_ASSUME
Original file line number Diff line number Diff line change @@ -23,6 +23,10 @@ elseif(CONFIG_ZTEST_FAIL_TEST_UNEXPECTED_ASSUME)
23
23
list (APPEND test_sources src/unexpected_assume.cpp )
24
24
endif ()
25
25
26
+ if (CONFIG_ZTEST_FAIL_ON_ASSUME )
27
+ add_definitions (-DCONFIG_ZTEST_FAIL_ON_ASSUME=1 )
28
+ endif ()
29
+
26
30
if (BOARD STREQUAL "unit_testing" OR BOARD STREQUAL "unit_testing/unit_testing" )
27
31
find_package (Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE} )
28
32
project (base )
Original file line number Diff line number Diff line change @@ -42,12 +42,22 @@ tests:
42
42
testing.fail.zephyr.assert_teardown :
43
43
extra_configs :
44
44
- CONFIG_ZTEST_FAIL_TEST_ASSERT_TEARDOWN=y
45
- testing.fail.zephyr.assume_after :
45
+ testing.fail.zephyr.assume_after.fail :
46
46
extra_configs :
47
47
- CONFIG_ZTEST_FAIL_TEST_ASSUME_AFTER=y
48
- testing.fail.zephyr.assume_teardown :
48
+ - CONFIG_ZTEST_FAIL_ON_ASSUME=y
49
+ testing.fail.zephyr.assume_teardown.fail :
49
50
extra_configs :
50
51
- CONFIG_ZTEST_FAIL_TEST_ASSUME_TEARDOWN=y
52
+ - CONFIG_ZTEST_FAIL_ON_ASSUME=y
53
+ testing.fail.zephyr.assume_after.skip :
54
+ extra_configs :
55
+ - CONFIG_ZTEST_FAIL_TEST_ASSUME_AFTER=y
56
+ - CONFIG_ZTEST_FAIL_ON_ASSUME=n
57
+ testing.fail.zephyr.assume_teardown.skip :
58
+ extra_configs :
59
+ - CONFIG_ZTEST_FAIL_TEST_ASSUME_TEARDOWN=y
60
+ - CONFIG_ZTEST_FAIL_ON_ASSUME=n
51
61
testing.fail.zephyr.pass_after :
52
62
extra_configs :
53
63
- CONFIG_ZTEST_FAIL_TEST_PASS_AFTER=y
58
68
type : unit
59
69
extra_configs :
60
70
- CONFIG_ZTEST_FAIL_TEST_UNEXPECTED_ASSUME=y
71
+ - CONFIG_ZTEST_FAIL_ON_ASSUME=y
61
72
testing.fail.zephyr.fail_on_bad_assumption :
62
73
extra_configs :
63
74
- CONFIG_ZTEST_FAIL_TEST_UNEXPECTED_ASSUME=y
75
+ - CONFIG_ZTEST_FAIL_ON_ASSUME=y
You can’t perform that action at this time.
0 commit comments