ZTest cmake error

Hi.  I am new to Ztest and cannot get the basic example to work.  I have taken the basic dev acadamy lesson 2 exercise 1 project and placed the test sample (samples/subsys/testsuite/integration) into the tests folder of the project as suggested in the framework guide (https://docs.zephyrproject.org/latest/develop/test/ztest.html) but get cmake errors when running twister.  It lists the tests fine:

C:\nordic\ncs-fund\v2.x.x\lesson2\fund_less2_exer2_solution>python C:\ncs\v2.3.0\zephyr\scripts\twister --list-tests -T C:\nordic\ncs-fund\v2.x.x\lesson2\fund_less2_exer2_solution\tests
ZEPHYR_BASE unset, using "C:\ncs\v2.3.0\zephyr"
Renaming output directory to C:\nordic\ncs-fund\v2.x.x\lesson2\fund_less2_exer2_solution\twister-out.4
INFO - Using Ninja..
INFO - Zephyr version: v3.2.99-ncs2
INFO - Using 'zephyr' toolchain.
- sample.testing.ztest.assert
1 total.

But when you try to run this is the build.log produced.  I assume the file it cannot fine is zephyr/ztest.h as it is red underlined in VSCode but cannot for the life of me figure out how to make this basic sample work!  I have tried modifying the test cases CMake file to include the \subsys\testsuite\ztest\include\zephyr\ folder where ztest.h is located but does not work. Thanks in advance.

Loading Zephyr default modules (Zephyr base).
-- Application: C:/nordic/ncs-fund/v2.x.x/lesson2/fund_less2_exer2_solution/tests
-- Using NCS Toolchain 2.3.0 for building. (C:/ncs/toolchains/v2.3.0/cmake)
-- Found Python3: C:/ncs/toolchains/v2.3.0/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter
-- Cache files will be written to: C:/ncs/v2.3.0/zephyr/.cache
-- Zephyr version: 3.2.99 (C:/ncs/v2.3.0/zephyr)
-- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
-- Board: native_posix
-- Found host-tools: zephyr 0.15.2 (C:/ncs/toolchains/v2.3.0/opt/zephyr-sdk)
-- Found toolchain: host (gcc/ld)
-- Found Dtc: C:/ncs/toolchains/v2.3.0/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
-- Found BOARD.dts: C:/ncs/v2.3.0/zephyr/boards/posix/native_posix/native_posix.dts
CMake Error at C:/ncs/v2.3.0/zephyr/cmake/modules/dts.cmake:191 (message):
command failed with return code: The system cannot find the file specified
Call Stack (most recent call first):
C:/ncs/v2.3.0/zephyr/cmake/modules/zephyr_default.cmake:108 (include)
C:/ncs/v2.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
C:/ncs/v2.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
CMakeLists.txt:4 (find_package)


-- Configuring incomplete, errors occurred!

Parents
  • Hi, 

    I will look into it. It might be that it's better to ask the Zephyr project here since it appears to be more Zephyr then NRF related. 

    Regards

    Runar

  • Thank you, appreciated.  I did ask on their Discord but new there and not sure how responsive it is.  I think I lack the understanding of how the tests stack on top of the parent project.  It is all just direct from samples though, no changes.  Looking at the Zephyr source having the below in the TESTS folder proj.config should include the required folder.  VSCode and seemingly twister does not pick that up though. The base project is a nRF5340 target, if that makes a difference.  Per the testsuite example though the test target/platform is just native_posix.

    CONFIG_ZTEST=y
    CONFIG_ZTEST_NEW_API=y
    From /zephyr/CMakeLists.txt:
    if(CONFIG_ZTEST)
    list(APPEND SYSCALL_INCLUDE_DIRS ${ZEPHYR_BASE}/subsys/testsuite/ztest/include)
    endif()
Reply
  • Thank you, appreciated.  I did ask on their Discord but new there and not sure how responsive it is.  I think I lack the understanding of how the tests stack on top of the parent project.  It is all just direct from samples though, no changes.  Looking at the Zephyr source having the below in the TESTS folder proj.config should include the required folder.  VSCode and seemingly twister does not pick that up though. The base project is a nRF5340 target, if that makes a difference.  Per the testsuite example though the test target/platform is just native_posix.

    CONFIG_ZTEST=y
    CONFIG_ZTEST_NEW_API=y
    From /zephyr/CMakeLists.txt:
    if(CONFIG_ZTEST)
    list(APPEND SYSCALL_INCLUDE_DIRS ${ZEPHYR_BASE}/subsys/testsuite/ztest/include)
    endif()
Children
Related