I have created the unit test using ZTest framework unable to run with zephyr/kernel.h file

i am unable to build the unit test code with kernel file  

FAILED: CMakeFiles/testbinary.dir/home/avinash/zephyrproject/unittesting/gce-source_code_latest/app/vipr/model/gas.c.o
/usr/bin/gcc -DUNIT_TEST -DZTEST_UNITTEST -I/home/avinash/zephyrproject/unittesting/gce-source_code_latest/tests/model_test -I/home/avinash/zephyrproject/unittesting/gce-source_code_latest/tests/model_test/../app/vipr/model -I/home/avinash/zephyrproject/zephyr/subsys/testsuite/ztest/include/zephyr -I/home/avinash/zephyrproject/zephyr/subsys/testsuite/ztest/unittest/include -I/home/avinash/zephyrproject/zephyr/subsys/testsuite/include/zephyr -I/home/avinash/zephyrproject/zephyr/subsys/testsuite/ztest/include -I/home/avinash/zephyrproject/zephyr/subsys/testsuite/include -I/home/avinash/zephyrproject/zephyr/include/zephyr -I/home/avinash/zephyrproject/zephyr/include -I/home/avinash/zephyrproject/zephyr/. -m32 -imacros /home/avinash/zephyrproject/unittesting/gce-source_code_latest/build/zephyr/include/generated/zephyr/autoconf.h -Wall -I /home/avinash/zephyrproject/unittesting/gce-source_code_latest/build/zephyr/include/generated -g -gdwarf-4 -MD -MT CMakeFiles/testbinary.dir/home/avinash/zephyrproject/unittesting/gce-source_code_latest/app/vipr/model/gas.c.o -MF CMakeFiles/testbinary.dir/home/avinash/zephyrproject/unittesting/gce-source_code_latest/app/vipr/model/gas.c.o.d -o CMakeFiles/testbinary.dir/home/avinash/zephyrproject/unittesting/gce-source_code_latest/app/vipr/model/gas.c.o -c /home/avinash/zephyrproject/unittesting/gce-source_code_latest/app/vipr/model/gas.c
In file included from /home/avinash/zephyrproject/zephyr/include/zephyr/sys/atomic.h:18,
from /home/avinash/zephyrproject/zephyr/include/zephyr/kernel_includes.h:25,
from /home/avinash/zephyrproject/zephyr/include/zephyr/kernel.h:17,
from /home/avinash/zephyrproject/unittesting/gce-source_code_latest/app/vipr/model/gas.c:15:
/home/avinash/zephyrproject/zephyr/include/zephyr/kernel/thread_stack.h: In function ‘z_stack_ptr_align’:
/home/avinash/zephyrproject/zephyr/include/zephyr/kernel/thread_stack.h:71:40: error: ‘ARCH_STACK_PTR_ALIGN’ undeclared (first use in this function)


71 | return (char *)ROUND_DOWN(ptr, ARCH_STACK_PTR_ALIGN);
| ^~~~~~~~~~~~~~~~~~~~
/home/avinash/zephyrproject/zephyr/include/zephyr/sys/util.h:330:48: note: in definition of macro ‘ROUND_DOWN’
330 | (((unsigned long)(x) / (unsigned long)(align)) * (unsigned long)(align))
| ^~~~~
/home/avinash/zephyrproject/zephyr/include/zephyr/kernel/thread_stack.h:71:40: note: each undeclared identifier is reported only once for each function it appears in
71 | return (char *)ROUND_DOWN(ptr, ARCH_STACK_PTR_ALIGN);
| ^~~~~~~~~~~~~~~~~~~~
/home/avinash/zephyrproject/zephyr/include/zephyr/sys/util.h:330:48: note: in definition of macro ‘ROUND_DOWN’
330 | (((unsigned long)(x) / (unsigned long)(align)) * (unsigned long)(align))
| ^~~~~
[7/8] Building C object CMakeFiles/testbinary.dir/test_model_gas.c.o

Can you please help me to resolve this issue

Parents
  • Hi,

    Which version of the SDK do you use?

    What is the command you use to build?

    Regards,
    Sigurd Hellesvik

  • SDK version  is 2.8.0 

    The command to build:

     west build -p -b unit_testing/unit_testing tests/Peripherial_test

  • Trying to build this sample for boards "nrf52840dk/nrf52840" or "native_sim", both builds for me without issue. Also with the "<zephyr/kernel.h>" include you have added.

    In which case this could look like your custom build target is causing the issue. Can you tell me more about your build target?

  • i have created the unit test cases 

    Run this command :

    west build -p -b unit_testing/unit_testing

    board name as unit_testing/unit_testing

    And cmake file 

    cmake_minimum_required(VERSION 3.20.0)

    project(app)

    find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
     
    And Testcase.yaml file as 
    tests:
      sample.model:
        tags:
          - sample
        type: unit
  • Where does the board target "unit_testing/unit_testing" come from?

  • i need to run unit test cases without hardware or development kit and i have to run on myPC

  • I mean:

    I try to build for "unit_testing/unit_testing".

    My PC can not find this.

    Do you have any official documentation or source code that references "unit_testing/unit_testing"?

Reply
  • I mean:

    I try to build for "unit_testing/unit_testing".

    My PC can not find this.

    Do you have any official documentation or source code that references "unit_testing/unit_testing"?

Children
No Data