# Check

## Unit Testing Framework for C

### Installing Check

The following instructions show how one can either install Check from a package manager or compile from source on one's platform.

- GNU/Linux

- Ubuntu/Debian via Aptitude
- Fedora via Yum
- Arch Linux via Pacman
- From Source

- GNU/Hurd

- Debian GNU/Hurd From Source

- OSX

- MacPorts
- Homebrew
- From Source

- BSD

- OpenBSD via Packages
- From Source

- Windows

- Cygwin via Package Manager
- Cygwin From Source
- MinGW/MinGW-w64 From Source
- Visual Studios From Source
- MSVC From Source

- Solaris

- From Source

### Ubuntu/Debian via Aptitude

Ubuntu and Debian both provide a Check package that can be installed. To install, in a terminal, type:

    $ sudo apt-get install check

### Fedora via Yum

Fedora provides a Check package that can be installed. To install, in a terminal, type:

    $ sudo yum install check

### Arch Linux via Pacman

Arch Linux provides a Check package that can be installed. To install, in a terminal, type:

    $ sudo pacman -S check

### GNU/Linux From Source

Check uses autotools as a build system, and the default steps work on GNU/Linux systems. After the latest Check source has been downloaded and unpacked, open a terminal in the unpacked directory, then:

    $ ./configure
    $ make
    $ make check
    $ sudo make install

If the "make check" step fails, please send an email to Check's mailing list and give details as to the failure so it may be investigated and fixed.

### Debian GNU/Hurd From Source

Debian GNU/Hurd does not yet provide a package for Check, so it must be compiled from source. Check uses autotools as a build system, and the default steps work on Debian GNU/Hurd systems. After the latest Check source has been downloaded and unpacked, open a terminal in the unpacked directory, then:

    $ ./configure
    $ make
    $ make check
    $ sudo make install

If the "make check" step fails, please send an email to Check's mailing list and give details as to the failure so it may be investigated and fixed.

### OSX via MacPorts

MacPorts provides a Check package that can be installed. First, install MacPorts if not done already. Then, in a terminal, type:

    $ sudo port install check

### OSX via Homebrew

Homebrew provides a Check package that can be installed. First, install Homebrew if not done already. Then, in a terminal, type:

    $ brew install check

### OSX From Source

Check uses autotools as a build system, and the default steps work on OSX systems. You must have Xcode installed. After the latest Check source has been downloaded and unpacked, open a terminal in the unpacked directory, then:

    $ ./configure
    $ make
    $ make check
    $ sudo make install

If the "make check" step fails, please send an email to Check's mailing list and give details as to the failure so it may be investigated and fixed.

### OpenBSD via Packages

OpenBSD provides a Check package that can be installed. To install, in a terminal, type:

    $ sudo pkg_add check

### BSD From Source

Check uses autotools as a build system, and the default steps work when building on the BSD system. Special care is required when cross compiling, which is described below.
After the latest Check source has been downloaded and unpacked, open a terminal in the unpacked directory. To compile on the BSD system directly, type:

    $ ./configure
    $ make
    $ make check
    $ sudo make install

If the "make check" step fails, please send an email to Check's mailing list and give details as to the failure so it may be investigated and fixed.

Cross compiling for BSD may require an additional configure argument: --enable-timer-replacement . Check attempts to use high resolution timers via the timer_create(), timer_settime(), and timer_delete() functions. For some BSD systems (e.g. OpenBSD), these functions exist but are non-functional stubs. If the functions are available, when compiling on the target system the configure script will verify that the calls are not stubs. If they are valid, Check will use them. When cross compiling, the validity check cannot be performed. To prevent Check from using these when cross compiling for affected BSD systems, add the --enable-timer-replacement configure option.

### Cygwin on Windows via Package Manager

Cygwin provides a Check package that can be installed. To install, launch the Cygwin setup program, locate the Check package under the Devel folder, then install.

### Cygwin on Windows From Source

Check uses autotools as a build system, and the default steps work on Cygwin. You must have gcc, and make installed. After the latest Check source has been downloaded and unpacked, open a Cygwin terminal in the unpacked directory, then:

    $ ./configure
    $ make
    $ make check
    $ sudo make install

If the "make check" step fails, please send an email to Check's mailing list and give details as to the failure so it may be investigated and fixed.

### MinGW/MinGW-w64 on Windows From Source

MinGW and MinGW-w64 do not provide a package for Check, so it must be compiled from source. Check uses autotools as a build system, and the default steps work on both MinGW and MinGW-w64. Note that because both MinGW and MinGW-w64 do not provide a fork() alternative, Check's fork mode will be disabled. After the latest Check source has been downloaded and unpacked, open a MSYS terminal in the unpacked directory, then:

    $ ./configure
    $ make
    $ make check
    $ make install

If the "make check" step fails, please send an email to Check's mailing list and give details as to the failure so it may be investigated and fixed.

### Visual Studios on Windows From Source

Check must be compiled from source for Windows. Note that no fork() call is available, and Check's fork mode will be disabled. The CMake build system is supported for compiling Check with Visual Studios, so download CMake first.

After the latest Check source has been downloaded and unpacked, open the CMake GUI program. Fill in the "Where is the source code" and "Where to build the binaries" fields to point to the unpacked location of the Check source, and press the Configure button. Select the version of Visual Studios to use, and click "OK". Once the configuration completes, CMake will highlight two settings, CMAKE_CONFIGURATION_TYPES and CMAKE_INSTALL_PREFIX. You may leave them as their defaults or modify them. Finally, click "Generate" to create the Visual Studio project files.

Open Visual Studios and load the generated project files. The following is a summary of the important build targets:

- ALL_BUILD: Build Check and all unit tests
- RUN_TESTS: Execute Check's unit tests
- INSTALL: Install Check to the CMAKE_INSTALL_PREFIX location listed from the CMake GUI

To compile, validate, and install Check, run these three targets from Visual Studios. Note that the RUN_TESTS target only runs Check's unit tests which do not require a shell interpreter. The remaining tests must be run in a MSYS or comparable environment.

If any of the build targets fail, including the RUN_TESTS target, please send an email to Check's mailing list and give details as to the failure so it may be investigated and fixed.

### MSVC on Windows From Source

Check must be compiled from source for Windows. Note that no fork() call is available, and Check's fork mode will be disabled. The CMake build system is supported for compiling Check with Visual Studios, so download CMake first.

After the latest Check source has been downloaded and unpacked, open a terminal (cmd.exe). If MSVC is not in the path, execute the bat file in the MSVC install directory to load it into the path. For example, with Visual Studios 10:

    > C:\Program Files\Microsoft Visual Studios 10.0\VC\vcvarsall.bat

Navigate to the unpacked location of the Check source, then:

    > cmake -G "NMake Makefiles" .
    > nmake
    > nmake test
    > nmake install

Note that the "nmake test" step only runs Check's unit tests which do not require a shell interpreter. The remaining tests must be run in a MSYS or comparable environment.

If the "make test" step fails, please send an email to Check's mailing list and give details as to the failure so it may be investigated and fixed.

### Solaris From Source

Check uses autotools as a build system. The PATH must be setup such that POSIX versions of tools are found before legacy once. (see also standards(5) for more details). If the compiler is GCC, setup the PATH as follows:

    PATH=/usr/xpg6/bin:/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/sbin:/usr/sbin:/opt/csw/bin

Otherwise, for Solaris Studio use the following PATH:

    PATH=/opt/solarisstudio12.3/bin:/usr/xpg6/bin:/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/sbin:/usr/sbin:/opt/csw/bin

Further, ensure that the environment variables LD_LIBRARY_PATH and LD_LIBRARY_PATH_64 are unset. It is recommended to use OpenCSW packages (/opt/csw/bin) to get recent versions of required programs. The configure script will likely find gcc by default; to use Solaris Studio also set the following environment variable:

    CC=cc

After the latest Check source has been downloaded and unpacked, open a terminal in the unpacked directory, then:

    $ ./configure CFLAGS=-m64 LDFLAGS=-m64
    $ gmake
    $ gmake check
    $ gmake install

If the "gmake check" step fails, please send an email to Check's mailing list and give details as to the failure so it may be investigated and fixed.