I am developing an application for an NRF52840 using Zephyr and trying to run unit tests on startup. My application sources are in my src folder, and my unit ztests are in the folder called tests.
My application builds fine, but now that I am trying to enable an option to build and run the unit tests at bootup, I am having linker issues as below.
My prj.conf for my application has the the following two lines at the bottom. I have defined CONFIG_RUN_TESTS_AT_BOOT in my Kconfig file.
CONFIG_ZTEST=y CONFIG_RUN_TESTS_AT_BOOT=y
My CMakeLists.txt :
if(CONFIG_RUN_TESTS_AT_BOOT) target_sources(app PRIVATE tests/src/main.c) endif()
Then in my main application source file :
#ifdef CONFIG_RUN_TESTS_AT_BOOT ztest_run_all(NULL, false, -1, -1); #endif
Is this even the correct way to execute ztests from my application at bootup? This is the linker errors I am getting. There are many more on trying to find __device_dts_ord_186
/home/user/zephyr-sdk-0.17.0/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: modules/chester/subsys/ctr_lte_v2/lib..__chester__subsys__ctr_lte_v2.a(ctr_lte_v2_flow.c.obj): in function `ctr_lte_v2_flow_reset': /home/user/top_main/subsys/ctr_lte_v2/ctr_lte_v2_flow.c:865: undefined reference to `__device_dts_ord_186'