Good afternoon devs,
When I checkout the latest cmocka version and try to compile cmocka with the xc8 compiler version 1.41 the code wont compile syntaxis error.
It isnt recommend or the solution to change this cmocka source, because in the future…
I have a C project that I am trying to compile using CMake. This is my project structure:
root
├─ CMakeLists.txt
├─ docs
├─ build
└─ src
├─ main.c
├─ library1.h
├─ library2.h
├─ ...
The project needs unit tests for which I'm using…
I'm trying to unit test some source code using cmocka. Basically the (relevant) source code looks similar to Source.c.
The unit test calls each function separately. When testing the Add() function this function will eventually call util_malloc()…
I would like to test some functions by implementing unit tests with cmocka framework.
For example I have a non-static function under test which calls two static functions. Because of the fact that these static functions interact with hardware I want…
I got task to write unit tests(using cunit and cmocka) for existing project(written in C), and a met following problem. When I wrap function that is defined in tested file, only original function is called. Additional, a can't change source of…
I am trying to mock C functions using CMocka and GCC's --wrap linker option. So far this technique has worked well for mocking stdlib functions such as fgets, popen, pclose, etc.
However now I am trying to mock functions that are in a static library…
I have been trying to learn cmocka to perform unitest. After looking at various examples on internet, I am confused as to how I should do unit testing, specifically I am unable to understand following syntax:
static int functionname(void **state) {
…
I am building unit tests with CMocka. My function char some_func(some_enum e) maps valid values of e to a char. It uses assert to check e is valid, which by definition calls abort if not.
Mocking abort is proving to be hard. Following this example…
I am using cmocka on an embedded arm microcontroller (stm32) which is running FreeRTOS.
Well, cmocka seems to have some problems when it is running as a FreeRTOS Task. In line 2953 some signals are initialized and this causes an stack overflow in…
I am adding quite a few mocks, using cmocka, which require me to alias them using the GC Clinker opetion --wrap=
I am passing a linker option of the format
-Wl,--wrap=foo,--wrap=bar,--wrap=baz,--wrap= ...
Is there any way to shorten…
I am writing a series of mock functions in C using CMocka
Some of these take pointers as input variables and I am not sure whether I should check them (ptr != NULL) or not.
In general, is the mock function responsible to perform input checking?
If…
I'm using CTest to run tests written with cmocka. I'd like to know if it's possible to have CTest read the test names from my cmocka source and give them to me on the output. For example, if my test source contains 3 tests: test_order_correct,…
I am using Eclipse under Ubuntu.
I just installed cmocka:
Install the project...
-- Install configuration: "Debug"
-- Installing: /usr/lib/pkgconfig/cmocka.pc
-- Installing: /usr/lib/cmake/cmocka/cmocka-config.cmake
-- Installing:…
I would like to print a list of all the tests that have failed to be used at the end of the session. In CMocka framework failed tests are shown after each cmocka_run_group_tests call. Is there a standard solution to show all failed tests after…
I have this piece of code here:
assert_ptr_equals(get_data(hm,key_three),NULL);
assert_true((int*)get_data(hm,key_three)==NULL);
The get_data function returns a void pointer.
The first assert is true but second one fails. Any idea why?
Here…