I am writing unit tests for some embedded C that run on the host machine (not yet tested on the target computer) and compiled using GCC. I am using Ceedling build system with Unity testing base for testing.
One of the files I would like to test includes a file (say ah), which includes another file (say cpu.h), which is part of the board support package from the vendor of embedded devices, and uses keywords specific for (e.g. __cregister, e.g., c extern __cregister volatile unsigned int IER;.
Another problem, again with such a file included in the BSP, is the built-in assemblies asm(), for example, in #define FOO_ASM asm("FOO").
They, of course, cause an error in the construction of tests, because GCC does not recognize these keywords.
I thought I could prevent these BSP headers from being added when Ceedling generates a layout by adding #include "mock_a.h"to my test file, but GCC still compiles ah and therefore bh
Is there a better way to solve such problems?
I could add something like the following to the BSP file, but I do not want to change the code of the provider that will change or rewrite my changes with the new version, I would better understand how to properly isolate the device.
#ifdef TEST
#undef __cregister
#define __cregister
#endif
extern __cregister volatile unsigned int IER;
source
share