I am somewhat new to TDD, although I have been using C for some time. As a result, I am using ceedling to test my embedded project.
I can rake test:all
in gcc, but I am now trying to move that to an embedded target simulator. I am specifying my cross-compiler, linker, etc. through the 'project.yml' file.
When I rake test:all
, I get an error when "compiling cmock.c" (several other files compile without problems):
< path_to_cmock >/cmock.c:17:31: error: size of array 'CMock_Guts_Buffer' is too large
There are other errors after this, but this is the one that kicks them off.
When I go to cmock.c
, I see this at the top of the file:
#ifdef CMOCK_MEM_DYNAMIC
static unsigned char* CMock_Guts_Buffer = NULL;
static CMOCK_MEM_INDEX_TYPE CMock_Guts_BufferSize = CMOCK_MEM_ALIGN_SIZE;
static CMOCK_MEM_INDEX_TYPE CMock_Guts_FreePtr;
#else
static unsigned char CMock_Guts_Buffer[CMOCK_MEM_SIZE + CMOCK_MEM_ALIGN_SIZE];
static CMOCK_MEM_INDEX_TYPE CMock_Guts_BufferSize = CMOCK_MEM_SIZE + CMOCK_MEM_ALIGN_SIZE;
static CMOCK_MEM_INDEX_TYPE CMock_Guts_FreePtr;
#endif
Perfect, so I just need to find where these are declared. I do a text search only to find that they aren't declared anywhere... so I suspect that they are coming from the defaults within ceedling.
I found the documentation for CMOCK and, under "Compiled Options",
A number of #defines also exist for customizing the cmock experience...
It goes on to list the #defines that I have found in the source code, but it does not state where to find them. I have tried to make an include file with the appropriate defines and pass the include file through the 'project.yml' with no luck.
I suspect that the answer is unbelievably simple, it just isn't outlined anywhere that I have searched. Thank you for your time,
The proper way to setup the cmock for your prohect is as slightlynybbled pointed in previous answer, bu you could also provide a hidden setup for your cmocks into your project.yml file as follow:
This setup have been tested with Ceedling 0.27, 0.28 and 0.28.1
Of course, the answer was staring me in the face.
In the 'project.yml' file, there is a section called 'defines'. The default defines are:
I simply added the defines for my target: