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


Stefan Jaritz
 

Thanks for the information and feedback. In my eyes it would be perfect if, on the long run, a formalized test system is available.

I think for the users it would be perfect to have the possibility to do tests on different levels. Like:

- functional code testing (this code uses the ZephyrOS API)-> can be done on the host system before the firmware build

- protocol/com testing via python scripts -> can be done on the host, emulator and target system

- off kernel drivers/ user extensions of the kernel API -> can be done  emulator and target system

- the possibility to debug the tests in there respective environments

+ that the test, the app , hardware/kernel firmware team can use the same platform& git repro to do there tasks ;)

The goal should be that the users can setup build and test agent in there automated infrastructure. The more test adapters zephyr provides the better it is (like ztest, cmocka, cunit, etc.)


Greetings!

Stefan

On 25/10/2018 08:15, Kumar Gala wrote:
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.