Table of Contents

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.

Installation

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 http://sourceforge.net/projects/check/files/check/0.9.9/check-0.9.9.tar.gz/download
      $ 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/ld.so.conf.d ]; then \
        sudo echo "/usr/local/lib" >/etc/ld.so.conf.d/check.conf; \
        sudo ldconfig -v | grep check; \
      fi

Verification

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

  configure:     Will process unit testing?           yes (will generate report)
  configure:       (run make; make -k check)
  configure: