Freitag, 15. Februar 2013

CUnit

What is CUnit?

CUnit helps you build unit tests for C programs.

CUnit Installation and Quickstart

1. Download

Url: http://sourceforge.net/projects/cunit/
File: CUnit-2.1-2-src.tar.bz2

2. Configure and build (with optional curses support)

# Start MSYS Console
CPPFLAGS=-I/c/Users/brandin/include/pdcurses \
LDFLAGS=-L/c/Users/brandin/lib/pdcurses LIBS=-lpdcurses sh configure \
--enable-curses
make

3. Install headers

# Doing this from MSYS Console
mkdir "$USERPROFILE/include/cunit/"
mkdir "$USERPROFILE/include/cunit/CUnit"
cp -v CUnit/Headers/*.h "$USERPROFILE/include/cunit/CUnit/"

4. Install libs

mkdir "$USERPROFILE/lib/cunit/"
gnufind . -iname '*.a' -exec cp -v '{}' "$USERPROFILE/lib/cunit/" ';'

5. Install manpages

mkdir -p /c/cygwin/home/brandin/man/cunit/man3
cp -v Man/man3/CUnit.3 /c/cygwin/home/brandin/man/cunit/man3/

6. Update environment

Add %USERPROFILE%\include\cunit to CPATH
Add %USERPROFILE%\lib\cpath to LIBRARY_PATH
Add C:\cygwin\home\%USERNAME%\man\cunit to MANPATH
# Note: This environment will be added to env-mingw.bat

7. Try to compile and run an example program

# Modify the program under Examples/ExampleTests.c as follows:
---------------------------
#include "CUnit/CUnit.h"
#include "CUnit/Basic.h"
//#include "ExampleTests.h"
---------------------------
# Add the main function from Examples/BasicTest/BasicTest.c to the end of
# Examples/ExampleTests.c so that it will compile.

# Run the following under a normal Command Prompt in order to test CUnit:
cp -v Examples/ExampleTests.c /tmp
cd /tmp
gcc -o ExampleTests ExampleTests.c -lcunit
.\ExampleTests


All done. CUnit is installed.

Keine Kommentare:

Kommentar veröffentlichen