I want to unit test my application code, which in turn uses ChibiOS HAL (as well as the OS itself, but let's focus on HAL now). I'm using CMock and Unity. With CMock, I can provide a header, and CMock will automatically create mock implementations based on any function prototype it finds in the header. I build with GCC and run the unit tests on my host PC. The setup works really well for mocking other modules, but I run into several problems when trying provide the hal headers to CMock. I've managed to solve a couple of them, but wanted input from others before I jump too far down a rabbit hole.
The main issue I'm facing now is either macros or static inline functions that write directly to some memory address, causing segfaults when running on my PC. For example the macro palClearLine(). What I'd ideally need is function prototypes instead of macros, so that CMock can mock them. I've solved some other issues, and I wouldn't be surprised if I'd run into more if I kept going.
My ideas on how to continue:
* Create my own version of hal.h, where I minimally put in whatever I want, and use it for unit testing only (manual work, hard for other developers to expand, risk of making bad mistakes)
* Preprocess hal.h, and edit it to my liking (similar to the above)
* Create a simple abstraction layer between my application code and HAL, and skip HAL in my unit tests (abstraction layer of abstraction layer?)
* Edit hal.h, so that test builds come out with a different content
These all have ups and downsides, and I don't really love any of them

My question is, if someone has done something similar (mocking the HAL completely for off-target unit tests). Any input would be appreciated!
Cheers
Albin