Skip to content

Commit

Permalink
ztest: remove old ztest api
Browse files Browse the repository at this point in the history
Remove old Ztest API entirely. New API is the now the default.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
  • Loading branch information
nashif committed Oct 16, 2023
1 parent 3d02e3f commit 568dee3
Show file tree
Hide file tree
Showing 15 changed files with 1,324 additions and 1,126 deletions.
3 changes: 0 additions & 3 deletions cmake/linker_script/common/common-ram.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ endif()
if(CONFIG_ZTEST)
zephyr_iterable_section(NAME ztest_suite_node GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN 4)
zephyr_iterable_section(NAME ztest_suite_stats GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN 4)
endif()

if(CONFIG_ZTEST_NEW_API)
zephyr_iterable_section(NAME ztest_unit_test GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN 4)
zephyr_iterable_section(NAME ztest_test_rule GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN 4)
zephyr_iterable_section(NAME ztest_expected_result_entry GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN 4)
Expand Down
19 changes: 6 additions & 13 deletions cmake/modules/unittest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,12 @@ if(LIBS)
message(FATAL_ERROR "This variable is not supported, see SOURCES instead")
endif()

if(CONFIG_ZTEST_NEW_API)
target_sources(testbinary PRIVATE
${ZEPHYR_BASE}/subsys/testsuite/ztest/src/ztest_new.c
${ZEPHYR_BASE}/subsys/testsuite/ztest/src/ztest_mock.c
${ZEPHYR_BASE}/subsys/testsuite/ztest/src/ztest_rules.c
${ZEPHYR_BASE}/subsys/testsuite/ztest/src/ztest_defaults.c
)
else()
target_sources(testbinary PRIVATE
${ZEPHYR_BASE}/subsys/testsuite/ztest/src/ztest.c
${ZEPHYR_BASE}/subsys/testsuite/ztest/src/ztest_mock.c
)
endif()
target_sources(testbinary PRIVATE
${ZEPHYR_BASE}/subsys/testsuite/ztest/src/ztest.c
${ZEPHYR_BASE}/subsys/testsuite/ztest/src/ztest_mock.c
${ZEPHYR_BASE}/subsys/testsuite/ztest/src/ztest_rules.c
${ZEPHYR_BASE}/subsys/testsuite/ztest/src/ztest_defaults.c
)

target_compile_definitions(test_interface INTERFACE ZTEST_UNITTEST)

Expand Down
4 changes: 2 additions & 2 deletions scripts/build/gen_kobject_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@
("k_event", ("CONFIG_EVENTS", False, True)),
("ztest_suite_node", ("CONFIG_ZTEST", True, False)),
("ztest_suite_stats", ("CONFIG_ZTEST", True, False)),
("ztest_unit_test", ("CONFIG_ZTEST_NEW_API", True, False)),
("ztest_test_rule", ("CONFIG_ZTEST_NEW_API", True, False)),
("ztest_unit_test", ("CONFIG_ZTEST", True, False)),
("ztest_test_rule", ("CONFIG_ZTEST", True, False)),
("rtio", ("CONFIG_RTIO", False, False)),
("rtio_iodev", ("CONFIG_RTIO", False, False)),
("sensor_decoder_api", ("CONFIG_SENSOR_ASYNC_API", True, False))
Expand Down
2 changes: 1 addition & 1 deletion subsys/logging/Kconfig.processing
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if !LOG_MODE_MINIMAL

config LOG_PRINTK
bool "Process printk messages"
default y if PRINTK && (!ZTEST || ZTEST_NEW_API)
default y if PRINTK && ZTEST
help
If enabled, printk messages are redirected to the logging subsystem.
The messages are formatted in place and logged unconditionally.
Expand Down
15 changes: 0 additions & 15 deletions subsys/testsuite/include/zephyr/tc_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,34 +127,23 @@ static inline void print_nothing(const char *fmt, ...)
}

#ifndef TC_PRINT
/* Need to check for CONFIG_ZTEST_NEW_API since the TC_PRINT
* is also used by the old ztest.
*/
#ifdef CONFIG_ZTEST_NEW_API
#if defined(CONFIG_ZTEST_VERBOSE_OUTPUT)
#define TC_PRINT(fmt, ...) PRINT_DATA(fmt, ##__VA_ARGS__)
#else
#define TC_PRINT(fmt, ...) print_nothing(fmt, ##__VA_ARGS__)
#endif /* CONFIG_ZTEST_VERBOSE_OUTPUT */
#else
#define TC_PRINT(fmt, ...) PRINT_DATA(fmt, ##__VA_ARGS__)
#endif /* CONFIG_ZTEST_NEW_API */
#endif /* TC_PRINT */

#ifndef TC_SUMMARY_PRINT
#define TC_SUMMARY_PRINT(fmt, ...) PRINT_DATA(fmt, ##__VA_ARGS__)
#endif

#ifndef TC_START_PRINT
#ifdef CONFIG_ZTEST_NEW_API
#if defined(CONFIG_ZTEST_VERBOSE_OUTPUT)
#define TC_START_PRINT(name) PRINT_DATA("START - %s\n", name);
#else
#define TC_START_PRINT(name) print_nothing(name)
#endif /* CONFIG_ZTEST_VERBOSE_OUTPUT */
#else
#define TC_START_PRINT(name) PRINT_DATA("START - %s\n", name);
#endif /* CONFIG_ZTEST_NEW_API */
#endif /* TC_START_PRINT */

#ifndef TC_START
Expand All @@ -169,15 +158,11 @@ static inline void print_nothing(const char *fmt, ...)
#endif

#ifndef TC_END_PRINT
#ifdef CONFIG_ZTEST_NEW_API
#if defined(CONFIG_ZTEST_VERBOSE_OUTPUT)
#define TC_END_PRINT(result, fmt, ...) PRINT_DATA(fmt, ##__VA_ARGS__); PRINT_LINE
#else
#define TC_END_PRINT(result, fmt, ...) print_nothing(fmt)
#endif /* CONFIG_ZTEST_VERBOSE_OUTPUT */
#else
#define TC_END_PRINT(result, fmt, ...) PRINT_DATA(fmt, ##__VA_ARGS__); PRINT_LINE
#endif /* CONFIG_ZTEST_NEW_API */
#endif /* TC_END_PRINT */

/* prints result and the function name */
Expand Down
14 changes: 7 additions & 7 deletions subsys/testsuite/ztest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
zephyr_syscall_header(
${ZEPHYR_BASE}/subsys/testsuite/ztest/include/zephyr/ztest_error_hook.h
${ZEPHYR_BASE}/subsys/testsuite/ztest/include/zephyr/ztest_test.h
${ZEPHYR_BASE}/subsys/testsuite/ztest/include/zephyr/ztest_test_new.h
)

zephyr_include_directories(
Expand All @@ -16,16 +15,17 @@ if(DEFINED TC_RUNID)
endif()

zephyr_library()
zephyr_library_sources_ifndef(CONFIG_ZTEST_NEW_API src/ztest.c)
zephyr_library_sources_ifdef(CONFIG_ZTEST_NEW_API src/ztest_new.c)
zephyr_library_sources( src/ztest_error_hook.c)
zephyr_library_sources_ifdef(CONFIG_ZTEST_NEW_API src/ztest_rules.c)
zephyr_library_sources(
src/ztest.c
src/ztest_error_hook.c
src/ztest_rules.c
)
zephyr_library_sources_ifdef(CONFIG_ZTEST_MOCKING src/ztest_mock.c)
zephyr_library_sources_ifdef(CONFIG_ZTRESS src/ztress.c)


if(CONFIG_ARCH_POSIX)
zephyr_library_sources_ifdef(CONFIG_ZTEST_NEW_API src/ztest_posix.c)
zephyr_library_sources(src/ztest_posix.c)
else()
zephyr_library_sources_ifdef(CONFIG_ZTEST_NEW_API src/ztest_defaults.c)
zephyr_library_sources(src/ztest_defaults.c)
endif()
13 changes: 1 addition & 12 deletions subsys/testsuite/ztest/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ config ZTEST

if ZTEST

config ZTEST_NEW_API
bool "Use the new Ztest API"
default y
help
Enables the new Ztest APIs for creating suites and unit tests in
separate compilation units as well as the new 'rules' API.

config ZTEST_STACK_SIZE
int "Test function thread stack size"
default 2048 if COVERAGE_GCOV
Expand Down Expand Up @@ -114,9 +107,7 @@ config ZTEST_WARN_NO_OPTIMIZATIONS
optimizations. Please don't file issues when running tests that are
not explicitly tuned to work in this configuration.

if ZTEST_NEW_API

menu "ztest provided rules"
menu "ZTest provided rules"

config ZTEST_RULE_1CPU
bool "Run all the tests on a single CPU"
Expand Down Expand Up @@ -185,8 +176,6 @@ config ZTEST_FAIL_ON_ASSUME
result will be shown as a failure in order to increase visibility. This precludes tests
that skipped with the ZTEST_EXPECT_SKIP annotation.

endif # ZTEST_NEW_API

config TEST_LOGGING_FLUSH_AFTER_TEST
bool "When enabled logs are flushed after each test case"
default y
Expand Down
Loading

0 comments on commit 568dee3

Please sign in to comment.