Questions tagged [cmock]

`CMock` is a module/object mocking framework for `C` projects. It generates dummy modules that conform to the interface specified in a header file. This allows `API`s to be proven out and exercised before committing to an underlying implementation.

CMock is a module/object mocking framework for C projects. It generates dummy modules that conform to the interface specified in a header file. This allows APIs to be proven out and exercised before committing to an underlying implementation.

34 questions
1
vote
2 answers

How to mock function in same UUT in C

I am learning unit testing using Ceedling, with CMock for mocks, on an existing, embedded C code-base (which I can adjust to suit). I have come across the situation where one function in a unit calls a second function within the same unit. int…
Toby
  • 9,696
  • 16
  • 68
  • 132
1
vote
0 answers

CMock additional include via CLI

Introducing CMock on top of Unity into our build system (based on make) I keep struggeling with the correct handing over of additional include headers to cmock. We don't want to use configuration YML files since we like to have all config stuff…
goeck
  • 53
  • 5
1
vote
1 answer

How do you integrate CMock/Unity with Automake?

This is my first time asking a question here, so please let me know if I can improve my question.. I am looking for guidance on how to cleanly build unit tests that require replacement of source files with mocked versions of the source file…
tday03
  • 534
  • 4
  • 14
0
votes
1 answer

Ceedling/CMock: Adding va_list to :treat_as_array: produces a TypeError

I am working on developing some unit tests for some non-open source inherited code. For now I have just been testing the ceedling framework, using the autogenerated tests to ensure everything runs as it should. Everything works fine when I run tests…
Gabriel
  • 1
  • 4
0
votes
1 answer

how to use gcc to preprocess header only for #ifdef, not for #include and #defines

I have to preprocess a header, during this I want to only process the header for #ifdef, #if defined sections, other sections like Macro expansion and #include sections should not be expanded or checked. how to get this? I need to pass this output…
0
votes
0 answers

Unit test large projects with Ceedling

I've used Ceedling in the past on bare-metal projects that don't have many vendor libraries, so creating unit tests and mocking dependencies was pretty easy. Now I'm trying to integrate Ceedling on a very large project. On this project I'm…
Dani M
  • 1,173
  • 1
  • 15
  • 43
0
votes
1 answer

Add __wrap prefix to mocked functions with Cmock

I have generated mock_foo.h and mock_foo.c from my foo.h header using Ceedling. The problem is that in generated file there are function names the same as in foo.c. For example, foo_function() is now in both foo.c and mock_foo.c, and I have to…
adamm
  • 849
  • 1
  • 6
  • 17
0
votes
1 answer

Ceedling error when trying to compile/link with xc16-gcc

I am trying to implement test driven development for my Microchip embedded system process and am trying to do that via Ceedling (Unity, CMock, etc.). I have been trying to follow along with this tutorial:…
double01
  • 1
  • 1
0
votes
2 answers

Ceedling failing to mock header

I am trying to mock a header which is included by a source file I am testing. The header begins with the following: #if defined(ICM42600) #define ICM_WHOAMI ICM42600_WHOAMI #elif defined(ICM42602) #define ICM_WHOAMI ICM42602_WHOAMI #elif…
Daniel Paczuski Bak
  • 3,720
  • 8
  • 32
  • 78
0
votes
2 answers

How to unit test static callback routine called from ISR

I am using ceedling to unit test a C application and trying to achieve high coverage ~100%. I have a static callback function in one of my application module, which is registered to SDK function with function pointer and is called at certain event…
piyj
  • 19
  • 7
0
votes
1 answer

CMock mock some functions but not others from same module

//myfuncs.h void func1(void); void func2(void; I'm doing unit testing. Using CMock with ceedling, is there any way to mock func1(), but run func2() as it was originally written?
Peter Kapteyn
  • 354
  • 1
  • 13
0
votes
1 answer

How to configure expectations in cmock for a "read" function

Given a function under test that does something like: void funcUnderTest() { char buf[32]; int bufSize=32; someReadFunction(buf, size); } int someReadFunction(char* buf, int size) { int readlen; //loads buf with data …
mjs
  • 2,837
  • 4
  • 28
  • 48
0
votes
1 answer

General unit-testing: possible to mock self functions? (ceedling/CMock)

Is it principally possible to mock the functions of a file to be tested? E.g. I want to test the file self_test.c consisting of those functions: #include "self_test.h" uint8_t function_1(uint8_t argument) { return…
T.B.
  • 11
  • 4
0
votes
0 answers

Test static function after 'Extract Method' refactor of larger function

I have a large function, like the following: void processMsg(uint8_t *msg) { //Some structure initialisation, msg parsing and the like for (int i=0;i
LoPiTaL
  • 2,495
  • 16
  • 23
0
votes
1 answer

Cmock doesn't recognise function calls

I'm new to Cmock a mocking framework in C, and trying to start using it. I took the 'make_example' supplied in the exmaples dir and modified it a bit. My code is appearing underneath: /////////////////////////// foo.c…
liadd
  • 41
  • 2
  • 10