Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use custom unity_config.h, because of invalid order of include directories #1406

Open
zeitgeist87 opened this issue Jun 23, 2024 · 0 comments

Comments

@zeitgeist87
Copy link

I have an unbranded esp32-c6 board. Building, uploading and monitoring works with the following platformio.ini:

[env]
platform = espressif32
framework = espidf
monitor_speed = 115200

[env:esp32-c6]
board = esp32-c6-devkitm-1

However, testing does not work. It gets stuck forever and I have to reset the device. I added a custom unity_config.h, which is simply a copy of the default one for espidf from here.

I could never get it to work until I edited .pio/libdeps/esp32-c6/Unity/src/unity.c and redefined the UNITY_OUTPUT_CHAR macro like this:

#define UNITY_OUTPUT_CHAR(c)    putchar(c)

This results in a very revealing compiler warning:

.pio/libdeps/esp32-c6/Unity/src/unity.c: In function 'UnityPrintChar':
.pio/libdeps/esp32-c6/Unity/src/unity.c:80: warning: "UNITY_OUTPUT_CHAR" redefined
   80 |     #define UNITY_OUTPUT_CHAR(c)    putchar(c)
      | 
In file included from .pio/libdeps/esp32-c6/Unity/src/unity_internals.h:11,
                 from .pio/libdeps/esp32-c6/Unity/src/unity.h:21,
                 from .pio/libdeps/esp32-c6/Unity/src/unity.c:7:
/home/vscode/.platformio/packages/framework-espidf/components/unity/include/unity_config.h:41: note: this is the location of the previous definition
   41 | #define UNITY_OUTPUT_CHAR(a)    unity_putc(a)
      | 

For some reason the wrong unity_config.h gets included: .platformio/packages/framework-espidf/components/unity/include/unity_config.h This one contains an implementation which simply doesn't work for my board. The default implementation for from here would work perfectly fine, but it is not used for some reason. My own implementation is also not used because the order of the inlcude directories is wrong:

The command looks like this:

riscv32-esp-elf-gcc ....  -DPIO_UNIT_TESTING -DUNITY_INCLUDE_CONFIG_H -I.pio/libdeps/esp32-c6/Unity/src -I/home/vscode/.platformio/packages/framework-espidf/components/unity/include -Itest ....

-Itest needs to be the first include directory so that I can override whatever comes from /home/vscode/.platformio/packages/framework-espidf/components/unity/include. However, I would prefer not needing to override it in the first place.

If I edit .pio/libdeps/esp32-c6/Unity/src/unity_internals.h and add an absolute path for unity_config.h everything works:

#ifdef UNITY_INCLUDE_CONFIG_H
#include "/workspaces/240622-200551-espidf-hello-world/test/unity_config.h"
#endif

This confirms that the wrong header was included. Is there a nicer way to work around this issue and get unit tests to run on a generic esp32-c6 board?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant