This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf9160 ztest framework : unable to get a unit test to work

Hi. I am working on the nrf9160. I want to use a unit test framework for my application code (which is a combination of C/C++14). I thought about using gtest/gmock or ztest. For now I am trying to get to run a single sample provided: zephyr/sample/testing/integration up and running but unable to do so. I am working on a win 64 laptop.  Can you please explain how I can run a unit test please. I looked at the following webpages:https://docs.zephyrproject.org/1.12.0/subsystems/test/ztest.htmlhttps://docs.zephyrproject.org/latest/reference/kconfig/CONFIG_ZTEST.htmlhttps://developer.nordicsemi.com/nRF_Connect_SDK/doc/0.4.0/zephyr/guides/test/ztest.html. Please dont direct me to the same webpages.

what are the steps to run a unit/integration test on the win 64 enviroment? Do I have to run cmake? Trying to run the sanitycheck script fails due to several reasons:

On cmd: 

xxxxx\zephyr\scripts>python sanitycheck -s ..\samples\testing\integration
Install the anytree module to use the --test-tree option
Install tabulate python module with pip to use --device-testing option.
Renaming output directory to xxx\zephyr\scripts\sanity-out.4
INFO - JOBS: 8
INFO - Selecting default platforms per test case
INFO - Building initial testcase list...
INFO - 0 test configurations selected, 163531 configurations discarded due to filters.
INFO - Adding tasks to the queue...

INFO - [32m0 of 0[39m tests passed (0.00%), [39m0[39m failed, 0 skipped with [39m0[39m warnings in 7.89 seconds
INFO - In total 741 test cases were executed on 0 out of total 225 platforms (0.00%)
'stty' is not recognized as an internal or external command,
operable program or batch file.

On Cygwin: "/usr/bin/env: ‘python3’: No such file or directory" python3 not found. I had to change the shebang in sanitycheck to python instead. After that another error:

$ xxx/zephyr/scripts/sanitycheck -s ../samples/testing/integration
Install the anytree module to use the --test-tree option
Install tabulate python module with pip to use --device-testing option.
Traceback (most recent call last):
File "xxx/zephyr/scripts/sanitycheck", line 213, in <module>
import edtlib
ModuleNotFoundError: No module named 'edtlib'

when I try to source the zephyr env variable on cygwin: here is the error i get: 

source xxx/zephyr/zephyr-env.sh
-bash: $'\r': command not found
-bash: xxx/zephyr/zephyr-env.sh: line 70: syntax error: unexpected end of file

All I want to do is write unit tests and then eventually integration tests using the ztest framework, first on win64 platform. I hope someone can help me out. Please provide a step wise approach with commands to be run. Noob here.

Parents Reply Children
No Data
Related