Re: How to integrate code tests into projects containing own boards and drivers? #test #ztest


Kumar Gala
 

Really quickly, I’m not sure if we’ve done anything like this. Typically the testing support has been focused on what we’d use as a developer community for the zephyr project. So we have things like tests/boards/intel_s1000_crb, I don’t we’ve thought about how to provide some framework support for an application/user testing for your own project. Its an interesting idea, and something we should look at supporting. Would love to see any contributions along this front to enhance what we have with ztest to an “user application”.

- k

On Oct 24, 2018, at 11:52 AM, Stefan Jaritz <stefan@...> wrote:

Hey,

I like to do some code tests for parts of my firmware. I struggling to find out how to setup testing.

There is some explanation at

https://docs.zephyrproject.org/1.12.0/subsystems/test/ztest.html

but I am missing something like a tutorial like "how to integrate unit testing into my project?".


So I am asking if you can help me to get a clear top down approach.

Let's setup a fictional project, called myProject. This project defines an own board "myBoard" based on the stm32f412.

For this board we wrote some firmware containing several code files and a config.

We created a ztest that should check some part of the firmware.

The filesystem structure looks like that:

myProject/

myProject/myBoard/

myProject/myBoard/myBoard.dts

myProject/myBoard/myBoard_defconfig

myProject/src/

myProject/src/drv/myDrv.c

myProject/src/drv/myDrv.h

myProject/src/main.c

myProject/CMakeLists.txt

myProject/prj.conf

myProject/myTest/

myProject/myTest/testa.c

myProject/myTest/main.c


@CMakeLists.txt

cmake_minimum_required(VERSION 3.10)

set(BOARD "myBoard")
set(BOARD_ROOT "${CMAKE_SOURCE_DIR}")

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(NONE)

list(APPEND INC
src/drv/
)

list(APPEND SRC
src/drv/myDrv.c
src/main.c
)

target_sources(app PRIVATE ${SRC})

target_include_directories(app PRIVATE ${INC})

@prj.conf

# CONFIG_TEST=y
# CONFIG_ZTEST=y
# CONFIG_DEBUG=y

CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_SHOW_COLOR=y

CONFIG_UART_LINE_CTRL=y
CONFIG_SEGGER_SYSTEMVIEW=y

How do I need to modify the cmake, configs and file structure to run the test while building the firmware?

Stefan





Join users@lists.zephyrproject.org to automatically receive all group messages.