Home

Awesome

Cutest

Cutest is an acronym that can be understood as C unit test.

This library brings a bunch of macros in order to guide the implementation of unit tests for C projects.

Cutest brings a minimal memory leak detection system (fully working in Linux, Windows, FreeBSD, Solaris, NetBSD, MINIX and OpenBSD). You can also use cutest to test kernel mode stuff in Linux, FreeBSD, NetBSD and Windows.

All supported platforms by this library and other general features are listed on Table 1.

On Cutest is also possible customize the logs generated by your tests if you want to.

Table 1: Places where I have been running it. A.k.a. supported platforms. In additional, the compiler/linker options to be passed when using cutest as your unit testing library.

Operating SystemHas GNU Backtracing?Thread safe?Compiler/Linker flags to use (besides -lcutest)Kernel mode
LinuxYesYes-ldl, -lpthreadYes
FreeBSDYesYes-lexecinfo, -lpthreadYes
NetBSDYesYes-lexecinfo, -lpthreadYes
OpenBSDYesYes-lexecinfo, -lpthreadNo
MINIXYesNo-lexecinfoNo
SolarisNoYes-DNO_CUTEST_BACKTRACING, -lpthreadNo
WindowsYesYesYes

Of course, that it should run in a bunch of UNIX boxes, however I prefer listing the places where I actually watched it running and working pretty fine. If there is a specific non-listed platform that you want to use cutest, let me know, maybe I can adjust the library's build to accomplish your requirements ;)

Remark: When using cutest to test kernel mode code you do not need compiler flags because all is available in one single header file. For more details read the documentation.

How to build it

To build cutest is necessary to use my own build system called hefesto. Being Hefesto installed in your system all you need to emit on a shell inside the cutest's src sub-directory is:

hefesto

After the build a file named libcutest.a that stands for the library will be generated under the path src/lib. You should use this file and the header src/cutest.h to develop your further unit tests.

Note that the build was written based on GCC. So, you need to have the gcc/mingw installed (and well exported) in your system before going ahead.

Maybe you should read the documentation before starting.

Tip: In case of trying to compile it under a UNIX environment with no support for PTHREADS before calling hefesto you need to edit the file src/.ivk and add the following C Macro definition -DHAS_NO_PTHREAD to --cflags option:

--cflags=-DHAS_NO_PTHREAD

Note for Visual Studio users

If you want to build cutest under MSVC you need to invoke Hefesto as follows:

> hefesto --toolset=msvc-c-lib

The command above will build lib/libcutestmt.lib.

If you want to build lib/libcutestmtd.lib, use:

> hefesto --toolset=msvc-c-lib --compile-model=debug

On 64-bit environments 64-bit lib artifacts will be built, for 32-bit, use:

>hefesto --toolset=msvc-c-lib --cpu-arch=x86

After run one of the commands listed above, a file named libcutest.lib will be generated inside src/lib path. Note that use cutest on MSVC is a little bit tricky. It envolves composite the cutest with your current msvcrt.lib (it explains why the cutest.lib is so huge).

Important: When linking your test artifact. You need to add the following link option: /NODEFAULTLIB:MSVCRT,MSVCRTD.

I have tested it over Microsoft Visual Studio 2019.