The goal of this project is to provide a powerful testing
framework for C, on different platforms and operating
systems, which only requires the standard C library.
Support for Mock Objects
Mock objects are simulation objects to mimic the real
implementation of an actual object. Useful to simulate
dependencies of an interface to help test the interface
in isolation. Some project use the mock functionality to
simulate components communicating over a network
Only requires a C library
This makes it possible that cmocka works on many of
Several supported output formats
cmocka supports several different message output formats
like Test Anything Protocol, Subunit, xUnit XML or the original
Fully documented API
The API is very well
documented and cmocka provides several examples for the
different features it provides
Test fixtures are setup and teardown functions that can
be shared across multiple test cases to provide common
functions that prepare the test environment and destroy
Exception handling for signals (SIGSEGV, SIGILL, ...)
cmocka is able to recover the test state if there are
exceptions like a segfault.
cmocka doesn't use fork() for exception handling in test cases.
Very well tested
cmocka has nightly builds to test on several platforms
and with different compilers to ensure it works
correctly. If you want to get it working on your
platform you can add a nightly build and we will make
sure not to break your platform or compiler.
Testing of memory leaks, buffer overflows and underflows.
We offer functions during test which are able to detect
some sort of memory allocation issues without running
tools like valgrind.
cmockery legacy support
cmocka is a fork and the successor for
We offer the installation of a cmockery header so that
your tests written for cmockery are still working till
you migrate to cmocka.
Platforms and compilers
cmocka works well on Linux, BSD, Solaris, Windows and
embedded platforms. It is known to be working with GCC,
LLVM, MSVC, MinGW and many more.
License: Apache License 2.0
Version 1.1.5 has been released with a set of new assert functions
and a function to skip tests.
We released version 1.1.3 to fix some smaller issues of
the last release.
Projects using cmocka
cwrap - Full server/client testing made easy
Samba - Samba is the standard Windows interoperability suite of programs for Linux and Unix.
libssh - The SSH library
coreboot - Fast, secure and flexible OpenSource firmware
BIND DNS - Versatile, Classic, Complete Name Server Software
OpenVPN - software for private tunnels (VPN)
Knot DNS - High-performance DNS server
SSSD - Security System Service Daemon
Elasto Cloud - a cloud storage client
Profanity - a console based XMPP chat client
libomemo - a C library impelementing OMEMO
Netdata - realtime monitoring for servers