User Tools

Site Tools


Check: A unit test framework for C

The Crossfire project specifies that developers shall create and run unit tests built with the check framework. The framework is often not packaged by *nix distributions, but it is not hard to install.


If the *nix distribution has the check framework packaged, use the distribution's customary method of adding packages, otherwise, install the tool as follows, or in a suitably similar manner:

  1. Download the latest tarball from SourceForge. For example:
      $ mkdir -p ~/devel/check
      $ cd ~/devel/check
      $ wget
      $ mv download check-0.9.9.tar.gz
  2. Unpack the tarball.
      $ tar -xzf check-0.9.9.tar.gz
  3. Compile the framework.
      $ cd check-*
      $ ./configure --prefix=/usr/local
      $ make
  4. Install the framework.
      $ sudo make install
  5. As needed, modify the user environment to establish /usr/local/bin in the default run path. In BASH, the following is viable:
      if ! which checkmk; then \
        echo -e "\nexport PATH=\"\$\{PATH\}:/usr/local/bin\""; \
      fi >>~/.bash_profile
      . ~/.bash_profile
  6. As needed, modify the user environment to establish the location of the check resources. In BASH, following is viable:
      if pkg-config --uninstalled check; then \
        echo -e "\nexport PKG_CONFIG_PATH=\"\$\{PKG_CONFIG_PATH\}:/usr/local/lib/pkgconfig\""; \
        echo -e "export LD_LIBRARY_PATH=\"\$\{LD_LIBRARY_PATH\}:/usr/local/lib\"\n"; \
      fi >>~/.bash_profile
      . ~/.bash_profile
  7. As needed, and in lieu of defining a per-user LD_LIBRARY_PATH, the following may be viable for certain operating environments:
      if [ -d /etc/ ]; then \
        sudo echo "/usr/local/lib" >/etc/; \
        sudo ldconfig -v | grep check; \


If the check framework is installed correctly, the server ./configure or output should include:

  configure:     Will process unit testing?           yes (will generate report)
  configure:       (run make; make -k check)
dev/check.txt · Last modified: 2013/04/17 22:45 (external edit)