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

Testing with Unity and CMock - nrf9160

Hi,

I am trying to do unit testing of my application, but at the moment I am not able even to compile and run a test of the example. I am using ncs v1.1.0 following this example: 

https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.1.0/nrf/ug_unity_testing.html

and I am getting a response:

-- west build: build configuration:
       source directory: /workdir/ncs/nrf/tests/unity/example_test
       build directory: /workdir/ncs/nrf/tests/unity/example_test/build (created)
       BOARD: native_posix (origin: command line)
-- west build: generating a build system
-- Using application from '/workdir/ncs/nrf/tests/unity/example_test'
Zephyr version: 2.1.0
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.6.9", minimum required is "3.4") 
-- Selected BOARD native_posix
-- Found west: /usr/local/bin/west (found suitable version "0.7.2", minimum required is "0.6.0")
-- Cache files will be written to: /workdir/.cache//zephyr
-- Loading /workdir/ncs/zephyr/boards/posix/native_posix/native_posix.dts as base
Devicetree configuration written to /workdir/ncs/nrf/tests/unity/example_test/build/zephyr/include/generated/generated_dts_board.conf
Parsing Kconfig tree in /workdir/ncs/nrf/tests/unity/example_test/Kconfig
/workdir/ncs/mcuboot/zephyr/Kconfig:37: WARNING: dt_int_val is deprecated.
Loaded configuration '/workdir/ncs/zephyr/boards/posix/native_posix/native_posix_defconfig'
Merged configuration '/workdir/ncs/nrf/tests/unity/example_test/prj.conf'
Configuration saved to '/workdir/ncs/nrf/tests/unity/example_test/build/zephyr/.config'
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/gcc
-- Generating test runner /workdir/ncs/nrf/tests/unity/example_test/build/runner/runner_example_test.c
-- Generating cmock for header src/foo/foo.h
-- Configuring done
-- Generating done
-- Build files have been written to: /workdir/ncs/nrf/tests/unity/example_test/build
-- west build: running target run
[1/88] Preparing syscall dependency handling

[2/88] Generating include/generated/syscall_macros.h
[3/88] Generating misc/generated/syscalls_subdirs.trigger
[4/88] Generating include/generated/driver-validation.h
[5/88] Generating include/generated/kobj-types-enum.h, include/generated/otype-to-str.h
[6/88] Generating misc/generated/syscalls.json
[7/88] Generating include/generated/syscall_dispatch.c, include/generated/syscall_list.h
[8/88] Building C object zephyr/CMakeFiles/offsets.dir/arch/posix/core/offsets/offsets.c.obj
FAILED: zephyr/CMakeFiles/offsets.dir/arch/posix/core/offsets/offsets.c.obj 
/usr/bin/gcc -DBUILD_VERSION=v2.0.99-ncs1-rc1-761-g7e20180c004a -DKERNEL -DUSE_PARTITION_MANAGER=0 -D_FORTIFY_SOURCE=2 -D_POSIX_C_SOURCE=200809 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED -D__ZEPHYR__=1 -I/workdir/ncs/zephyr/kernel/include -I/workdir/ncs/zephyr/arch/posix/include -Imocks -I/workdir/ncs/zephyr/include -I/workdir/ncs/zephyr/include/drivers -Izephyr/include/generated -I/workdir/ncs/zephyr/soc/posix/inf_clock -I/workdir/ncs/zephyr/boards/posix/native_posix -I/workdir/ncs/nrf/include -I/workdir/ncs/zephyr/../test/cmock/vendor/unity/src -I/workdir/ncs/zephyr/../test/cmock/src -Os -imacros/workdir/ncs/nrf/tests/unity/example_test/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -imacros/workdir/ncs/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -ffunction-sections -fdata-sections -m32 -include /workdir/ncs/zephyr/arch/posix/include/posix_cheats.h -fno-freestanding -std=c11 -MD -MT zephyr/CMakeFiles/offsets.dir/arch/posix/core/offsets/offsets.c.obj -MF zephyr/CMakeFiles/offsets.dir/arch/posix/core/offsets/offsets.c.obj.d -o zephyr/CMakeFiles/offsets.dir/arch/posix/core/offsets/offsets.c.obj   -c /workdir/ncs/zephyr/arch/posix/core/offsets/offsets.c
In file included from /usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h:9:0,
                 from /workdir/ncs/zephyr/include/zephyr/types.h:10,
                 from /workdir/ncs/zephyr/include/kernel_includes.h:17,
                 from /workdir/ncs/zephyr/include/kernel.h:17,
                 from /workdir/ncs/zephyr/arch/posix/core/offsets/offsets.c:26:
/usr/include/stdint.h:26:10: fatal error: bits/libc-header-start.h: No such file or directory
 #include <bits/libc-header-start.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/local/bin/cmake --build /workdir/ncs/nrf/tests/unity/example_test/build --target run
Makefile:25: recipe for target 'test' failed
make: *** [test] Error 1


the command for running tests: 
cd ncs/nrf/tests/unity/example_test
west build -b native_posix -t run

I also noticed that I need to install ruby so everything can run this far. 

What is the problem with compiling and running tests?

Best regards,
Vojislav

Related