What am I doing:
I use cmocka to run unit tests for a large embedded project. An embedded project is compiled with arm-gcc-compiler. Unit tests are compiled with the usual one gccusing fragments of the built-in code and the cmocka library.
Usually cmocka recommends using -Wl,--wrap=functionNamesome unnecessary ones for ridicule (replacement) -Wl,--wrap=functionName. This works pretty well.
This problem:
Well, inside my inline code, there is one header file ( foo.h) that contains some functions (declared as inline). One of these functions contains assembler code for arm-gcc-compiler, which, of course, cannot be compiled gcc.
Stupidly wrap-flag, it does not seem to work with the functions, which are placed in header files.
Question:
How to mock this function in the header file?
How I tried to solve the problem:
I was thinking of inserting some macros #idefto exclude the mentioned section in assembler. But this cannot be done, because this file belongs to the licensed library, and I am not allowed to modify its contents.
I could extract my test subject function into additional files, so I foo.hdonβt need to include more. But this can lead to confusion in the structure of embedded source codes.
Exact problem lines
The exact code is placed in portmacro.h freeRtos on line 233:
portFORCE_INLINE static void vPortRaiseBASEPRI( void )
{
uint32_t ulNewBASEPRI;
__asm volatile
(
" mov %0, %1 \n" \
" msr basepri, %0 \n" \
" isb \n" \
" dsb \n" \
:"=r" (ulNewBASEPRI) : "i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY )
);
}
where is portFORCE_INLINEdefined as:
#define portFORCE_INLINE inline __attribute__(( always_inline))