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

Mocking FreeRTOS "task.h" failing due to attribute parsing #452

Open
silabs-theophilel opened this issue Aug 9, 2023 · 1 comment
Open
Labels

Comments

@silabs-theophilel
Copy link

Hello,

I am trying to mock "task.h" using CMock (in a ceedling environment).

There is one problem I encountered wich is the following:

An internal FreeRTOS symbol is defined as :

    #define portDONT_DISCARD                   __attribute__( ( used ) )

And a function is declared as follows in "task.h" header file:

portDONT_DISCARD void vTaskSwitchContext(void) PRIVILEGED_FUNCTION;

When mocking in my unit test the header file with 'mock_' prefix:

//-- mocking necessary file for compilation
#include "mock_em_core.h"
#include "mock_sid_pal_log_ifc.h"
#include "mock_sid_pal_assert_ifc.h"
#include "mock_queue.h"
#include "mock_task.h".   <----- HERE

The generated Mock is looking like this, causing a compilation error:

                                                                    --> HERE missing argument
void vTaskSwitchContext_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, )void cmock_to_return);
```

The message error:
```
In file included from build/test/runners/test_swi_runner.c:11:
build/test/mocks/mock_task.h:901:74: error: expected parameter declarator
void vTaskSwitchContext_CMockIgnoreAndReturn(UNITY_LINE_TYPE cmock_line, )void cmock_to_return);
```
@mvandervoord
Copy link
Member

If you add portDONT_DISCARD to your :strippables list, I believe this problem will go away.

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

No branches or pull requests

2 participants