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
5
votes
2 answers

Ceedling how to pass defines to CMock

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…
slightlynybbled
  • 2,408
  • 2
  • 20
  • 38
4
votes
2 answers

Example for using ExpectWithArray in CMock

I am using Ceedling under Ubuntu 16.04 and Eclipse 4.7.2. So far everything works fine with the exception that I can't make _ExpectWithArray mocking functions to work. For example I have the following function that I need to mock void…
4
votes
2 answers

Mocking C functions in MSVC (Visual Studio)

I am reading several articles on mocking C functions (like CMock, or CMocka), but I am not sure how the actual functions are replaced with mocked functions in this process. For example, CMocka relies on automatic wrapping using a GNU compiler, which…
Lou
  • 4,244
  • 3
  • 33
  • 72
4
votes
1 answer

Duplicate code between unit test and implementation

I'm currently developing some low level drivers for an embedded platform in plain C. I use unity+cmock as a unit testing framework. However while writing the low level stuff I often come across the following pattern: Test: void…
3
votes
0 answers

ceedling/cmock: mocking variadic functions, or va_list parameter

I tried to mock this code: int myPrintf(const char *fmt, ...); int myVprintf(const char *fmt, va_list args); for both functions some wrong code is generated. For example: typedef int (* CMOCK_myPrintf_CALLBACK)(const char* fmt, int…
mastupristi
  • 1,240
  • 1
  • 13
  • 29
2
votes
1 answer

__attribute__((weak) ) function result in undefined reference

I am currently trying to set up CMock for unit testing the STM32 using MinGW and CMake. In my config file, I set the :weak: option so that the generated mock would give me weak functions. One example is: #if defined (__IAR_SYSTEMS_ICC__) #pragma…
Le Hoang Long
  • 428
  • 3
  • 10
2
votes
1 answer

Ceedling CMock settings for ARM STM32

I've been setting up Ceedling for STM32. The howto is very scarce, so far I've managed to google next to nothing. Fortunately, the framework is relatively transparent for its size. This is a PIC configuration. I set up something similar…
Alexey Orlov
  • 2,412
  • 3
  • 27
  • 46
2
votes
3 answers

How to integrate CMock unit test framework with Make

Is there a way around having to switch my project to use rake as its build system? I have a large project using Make as its build system and would like to add CMock functionality for unit testing (I'm already successfully using Unity), but have…
1
vote
1 answer

Why do I have to re-include header files in C when running Ceedling?

I have a C project which I intend to test with Ceedling, CMock, and Unity stack. I do have an issue when running tests... My project structure is below mytest ├── lib │   ├── bar.c │   └── include │   └── bar.h ├──…
6b86b273ff
  • 11
  • 2
1
vote
0 answers

cmocka: wrapping a Glib library function g_string_append_c() not working

I am running UT test case for syslog-ng in cmocka, upgraded Glib library to 2.71. I am not able to call wrapper function. I tried linking option --Wl, wrap=g_string_append_c, wrap=g_string_append in make file. Here are my wrapper functions: String*…
Jagadeesh
  • 99
  • 1
  • 1
  • 7
1
vote
1 answer

CMock + Ceedling - how to mock methods imported from external library e.g.

I'm using ceedling + Cmock to unit test my methods. I've been following this guide. In my project, I have a foo.h and foo.c file: foo.c: #include #include #include "foo.h" void do_something_with_nfc() { //... other…
Tung
  • 5,334
  • 1
  • 34
  • 41
1
vote
2 answers

Ceedling unit testing in a project with FreeRTOS dependency

I'm trying to implement unit tests in Unity (Learn more about Unity) with a little help of CMock (Learn more about CMock). To do that I use the Ceedling tool which combines all Unity components into a one framework (Learn more about…
VIPPER
  • 326
  • 4
  • 24
1
vote
2 answers

Ceedling/CMock: how to make parts of a .h file visible for Cmock only

In my module there are function like macros. This is no obstacle for a module test, but it is an obstacle for other modules which include this module. My question: is there a way to make a part of the .h file visible for CMock only?…
Schmorli
  • 11
  • 3
1
vote
2 answers

How do I use Ceedling/Unity/Cmock to test embedded Systems

I am new at testing embedded systems with ceedling. I was wondering if there is a good place to start in terms of learning how to use ceedling. The project that I am working on its an embedded System for a CubeSat Project and we need a way to test…
Addi
  • 49
  • 2
  • 5
1
vote
0 answers

Finding how exactly rake invoked gcc to compile c code?

I am trying to understand how "cmock"/"unity" works under the hood. Both of this are using ruby rake build tool. Is there an easy way to show/log all shell commands and its option that were invoked by rake during build? I would expect to see among…
1
2 3