I have a simple test code suite set up in the C language to provide a template for the use of CMake to simultaneously build unit tests with cmocka and also build the integrated code in the main.c file. The code has the following directory…
I am trying to make some unit tests for database functions in C language, but i am not aware is it possible with cmocka?
I couldn't find any example on the internet for database testing using cmocka, so i wonder if someone has an example of testing…
I have tried "cmocka" in visual studio solution, and it works fine with simple asserts. But when it comes to "mocking" I can't find a way to "mock" the functions from the library I am testing.
It is a C project in visual studio and there isn't a…
I was learning how to work with CMocka unit-testing framework in my C project.
So far everything goes well, and I can also generate a HTML report from CMocka's XML output by junit2html. When I read about what's in the report, I saw that there's an…
I'm trying to compile the chef example from the CMocka project examples - link.
When I'm compiling it without the mocking flags there are no compilation problems. When I'm trying to compile it using the defined flags I get compiling error:
gcc -g…
I'm trying to use cmocka to test a private function in a module. The method under testing also calls other private methods in that same module.
/** @file foo.c */
void foo_private();
void foo_under_test() {
foo_private();
}
void foo_private()…
I'm using Cmocka to write a unit testing suite for a shared object written in C, but I'm having some issue. Since I cannot share the source code, I have written a minimum "not-working" example to show what is the issue:
my program is composed 5…
I'm using cmocka with Bazel and I want to import cmocka library in my test files (for c embedded code) like but I'm always getting: cmocka.h: No such file or directory.
my Build is:
cc_library(
name = "mock",
srcs =…
I'm using cmocka to unit test a large code base written in C. I'd like unit tests to run at a library level, but I'm having issues mocking functions when compiled in a shared library. I believe the shared library is the issue because I can…
target : mock (main.c) without modified any original file (work.a)
objcopy work.a --add-symbol _real_test1=.text:00000000000126ed,weak --weaken work.a
00000000000126ed is test1 address by command (nm work.a)
override function and call real function…
I have recently started working on a project written in C language. To add unit test cases, I searched for C unit test frameworks and I came across this answer C-unittest-frameworks. So I chose mocka and installed it from installation steps. But I…
a little background: I wish to unit test my code which gets built into a shared object file, say libabc. This code also calls libjson-c and libcurl functions.
I am planning to write function-wise tests for each function in product code, mocking…
I am trying to put cmocka into Embedded Linux target board.
I have created rootfs using Yocto, and I have added a custom recipe for cmocka-1.1.5. The cmocka shared library gets generated using my custom bitbake recipe, but when I try to build the…
I am trying to unit test an Apache module with Cmocka.
When I run the simple tests I get an error that it can't find function ap_rprintf. I try to build like this:
gcc -o run_test mod_hello.c run_test.c \
-lcmocka -lapr-1 \
…