Gamma Testing Situation

We needed a simple set of tools for building and running test code, and for evaluating and reporting the success of the results.

It needed to do all of the following:

  • Build Test Code.
  • Run test code and make sure no errors.
  • Compare output files with some verified standard.
  • Compare stdout with a verified standard (golden file).
  • Read and manage input files (for test cases).

Note on unit testing

  • Evaluated the code in the src/Testing directory. It is basically a testing harness but seemed too complex for our needs.

  • Also Evaluated 3rd party testing tools. I was impressed by Google's C++ testing framework, and was also intrigued by CppUnit and CxxTest. If I was going to do ongoing development I would have gone further in this direction, but since we are moving more toward the python world, learning a new testing tool was not a priority at this time. However, if there is more development work on the C++ version of the code, then one of these, or it's replacement would be worth considering. Wikipedia has a good listing of C++ unit testing tools:

Test Directory and Organization


Created a new sub-directory of /src called "Tests", with a subdirectory called "golden". Created a script to run the test code, and compare the results with the results listed in the golden directory. Then modified Linux Makefile, and visual studio project to build the test code and call the script.


# New Test routines

test:  ${BINDIR}/${LIB_NAME}  $(BINDIR)/runtests  run

TESTS       = Tests

TESTSBASE   = testsuite runtests

TESTSHDR    = testsuite.h

TESTCCFILES += $(addsuffix .cc, $(addprefix $(TESTS)/, $(TESTSBASE)))

ALLHFILES  += $(addprefix $(TESTS)/, $(TESTSHDR))

TESTOBJFILES  += $(addsuffix .too,  $(addprefix $(BINDIR)/, $(TESTSBASE)))


${BINDIR}/%.too : ${SRCDIR}/${TESTS}/


$(BINDIR)/runtests : $(TESTOBJFILES)
	$(CXX) -static -o $@ $(LD_TESTFLAGS) ${TESTOBJFILES} -L${BINDIR}/ -lgamma 

RUNDIR = ./../../src/Tests
CURDIR = ./../../primal/Linux

run: force
	@echo Running tests:
	@cd $(RUNDIR); python$(PYVERSION) -v -p $(BINDIR)/; cd $(CURDIR)


The modifications on windows involved adding the script as a "Post-Build Event" to the test project, which was included in with the ‘static' gamma visual studio 2008 project:

cd ..\..\src\Tests
python -v -p ..\\..\\i686-pc-msvc\\
cd ..\..\msvc2008e\test

Test script

Test script was written in python for portability, and is called:

…and is now part of the repository.