zephyr: Windows building of ztest test cases does not work.

When trying to build a basic test case on Windows with west I get the following error:


C:\repos\converged>west build -p -b unit_testing -T zephyr\tests\unit\base64\utilities.base64 --build-dir twister_build
-- west build: generating a build system
-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/usr/bin/cc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/msys64/usr/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Loading Zephyr module(s) (Zephyr base): unittest
-- Found Python3: C:/Program Files/Python310/python.exe (found suitable version "3.10.8", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: C:/repos/converged/zephyr/.cache
-- Board: unit_testing
Parsing C:/repos/converged/zephyr/Kconfig
Loaded configuration 'C:/repos/converged/zephyr/subsys/testsuite/boards/unit_testing/unit_testing/unit_testing_defconfig'
Merged configuration 'C:/repos/converged/zephyr/tests/unit/base64/prj.conf'
Configuration saved to 'C:/repos/converged/twister_build/zephyr/.config'
Kconfig header saved to 'C:/repos/converged/twister_build/zephyr/include/generated/autoconf.h'
-- Found toolchain: host (gcc/ld)
-- Found GnuLd: C:/msys64/usr/bin/ld.bfd.exe (found version "2.37")
-- The ASM compiler identification is GNU
-- Found assembler: C:/msys64/usr/bin/gcc.exe
-- Configuring done
-- Generating done
-- Build files have been written to: C:/repos/converged/twister_build
←[92m-- west build: building application
[2/7] Building C object CMakeFiles/testbinary.dir/C_/repos/converged/zephyr/subsys/testsuite/ztest/src/ztest_new.c.obj
FAILED: CMakeFiles/testbinary.dir/C_/repos/converged/zephyr/subsys/testsuite/ztest/src/ztest_new.c.obj
C:\msys64\usr\bin\gcc.exe -DZTEST_UNITTEST -IC:/repos/converged/zephyr/subsys/testsuite/ztest/include/zephyr -IC:/repos/converged/zephyr/subsys/testsuite/include/zephyr -IC:/repos/converged/zephyr/subsys/testsuite/ztest/include -IC:/repos/converged/zephyr/subsys/testsuite/include -IC:/repos/converged/zephyr/include/zephyr -IC:/repos/converged/zephyr/include -IC:/repos/converged/zephyr/. -m32 -imacros C:/repos/converged/twister_build/zephyr/include/generated/autoconf.h -Wall -I C:/repos/converged/twister_build/zephyr/include/generated -MD -MT CMakeFiles/testbinary.dir/C_/repos/converged/zephyr/subsys/testsuite/ztest/src/ztest_new.c.obj -MF CMakeFiles\testbinary.dir\C_\repos\converged\zephyr\subsys\testsuite\ztest\src\ztest_new.c.obj.d -o CMakeFiles/testbinary.dir/C_/repos/converged/zephyr/subsys/testsuite/ztest/src/ztest_new.c.obj -c C:/repos/converged/zephyr/subsys/testsuite/ztest/src/ztest_new.c
<command-line>: fatal error: C:/repos/converged/twister_build/zephyr/include/generated/autoconf.h: No such file or directory
compilation terminated.

The generated file in question

C:/repos/converged/twister_build/zephyr/include/generated/autoconf.h 

exists and is available to be opened.

Tried different terminal options with and without privileges. This seems to be either west or west extension issue.

I am not sure if this should end up here so please correct me if so.

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Comments: 25 (15 by maintainers)

Most upvoted comments

there is no unit_testing board, this is just a dummy definition,

I know, but we are generally not testing host compiler on Windows, only cross-compiler. We do go through part of the same CMake infrastructure for toolchains in unittest as we do for a regular build, but I (and probably others as well) haven’t been verifying the host part on Windows.

Where I was in doubt on previous comment was whether we actually picked up some header from native_posix for unittesting, but I just verified that we do not do that.

So that means we should easily be able to get the unit_testing / ztest to work on Windows.

Ztest, compiler sections, mach-o, 16 characters, #53123 (comment).

yeah, emphasises the need for your multiplatform CI workflow. We could have caught this breakage soon enough 😃