Skip to content

Commit

Permalink
Add a CXXTest unittest framework
Browse files Browse the repository at this point in the history
  • Loading branch information
eliran-stratoscale committed Jun 8, 2016
1 parent 13fe813 commit 5651e9f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "cxxtest"]
path = cxxtest
url = https://github.com/CxxTest/cxxtest
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ egg: dist/osmosis-1.0.linux-x86_64.tar.gz
unittest: build
PYTHONPATH=py python tests/main.py
build/cpp/testtaskqueue.bin
build/cpp/testosmosis.bin

check_convention:
pep8 py tests --max-line-length=109
Expand Down
19 changes: 12 additions & 7 deletions build.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ all: all-targets

CONFIGURATION ?= RELEASE
SHELL ?= /bin/bash
COMMON_CXXFLAGS = -Ic -Icpp -I/usr/include/python2.7 -Ibuild/cpp-netlib-0.11.1-final -std=gnu++0x -Werror -Wall
COMMON_CXXFLAGS = -Ic -Icpp -I/usr/include/python2.7 -Ibuild/cpp-netlib-0.11.1-final -Icxxtest -std=gnu++0x -Werror -Wall
COMMON_CFLAGS = -Ic -Werror -Wall

DEBUG_CXXFLAGS = -ggdb -DDEBUG
Expand Down Expand Up @@ -89,30 +89,35 @@ endif

build/cpp/%.o: cpp/%.cpp
@mkdir -p $(@D)
@echo 'C++ ' $@
@echo 'C++ ' $@
$(Q)g++ $(CXXFLAGS) $($(subst /,_,$(subst .,_,$*))_o_CFLAGS) -MMD -MF $@.deps -c $< -o $@

build/c/%.o: c/%.c
@mkdir -p $(@D)
@echo 'C ' $@
@echo 'C ' $@
$(Q)gcc $(CFLAGS) $($(subst /,_,$(subst .,_,$*))_o_CFLAGS) -MMD -MF $@.deps -c $< -o $@

build/cpp/%.bin:
@mkdir -p $(@D)
@echo 'LINK++ ' $@
@echo 'LINK++ ' $@
$(Q)g++ $(LDFLAGS) -o $@ $^ $($*_LDFLAGS) $($*_LIBRARIES)

build/c/%.bin:
@mkdir -p $(@D)
@echo 'LINK ' $@
@echo 'LINK ' $@
$(Q)gcc $(LDFLAGS) -o $@ $^ $($*_LDFLAGS) $($*_LIBRARIES)

build/cpp/%.so:
@mkdir -p $(@D)
@echo 'LINK++ ' $@
@echo 'LINK++ ' $@
$(Q)g++ -shared $(LDFLAGS) -o $@ $^ $($*_LDFLAGS) $($*_LIBRARIES)

build/c/%.so:
@mkdir -p $(@D)
@echo 'LINK ' $@
@echo 'LINK ' $@
$(Q)gcc -shared $(LDFLAGS) -o $@ $^ $($*_LDFLAGS) $($*_LIBRARIES)

build/cpp/Unittests/testosmosis.cpp:
@mkdir -p $(@D)
@echo 'CXXTESTGEN ' $@
$(Q)cxxtest/bin/cxxtestgen --error-printer -o $@ $(shell find cpp/Unittests -iname "test_*.h")
14 changes: 14 additions & 0 deletions cpp/Unittests/test_osmosis_main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <mutex>
#include <cxxtest/TestSuite.h>

std::mutex globalTraceLock;

class MyTestSuite1 : public CxxTest::TestSuite
{
public:
void testAddition(void)
{
TS_ASSERT(1 + 1 > 1);
TS_ASSERT_EQUALS(1 + 1, 2);
}
};
1 change: 1 addition & 0 deletions cxxtest
Submodule cxxtest added at 191add
6 changes: 5 additions & 1 deletion targets.Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
TARGET_osmosis = $(shell find cpp/Osmosis/ -iname "*.cpp")
osmosis_SOURCES = $(shell find cpp/Osmosis/ -type f -iname "*.cpp" -not -iname "test_*.h" -not -iname "*main.cpp")
TARGET_osmosis = ${osmosis_SOURCES} cpp/Osmosis/main.cpp
osmosis_LIBRARIES = -pthread \
$(STATIC_BOOST_LIBS_DIR)/libboost_regex$(BOOST_MT).a \
$(STATIC_BOOST_LIBS_DIR)/libboost_filesystem$(BOOST_MT).a \
Expand All @@ -9,3 +10,6 @@ osmosis_LIBRARIES = -pthread \

TARGET_testtaskqueue = cpp/Common/WhiteboxTests/testtaskqueue.cpp
testtaskqueue_LIBRARIES = -pthread $(STATIC_BOOST_LIBS_DIR)/libboost_system$(BOOST_MT).a

TARGET_testosmosis = ${osmosis_SOURCES} build/cpp/Unittests/testosmosis.o
testosmosis_LIBRARIES = ${osmosis_LIBRARIES}

0 comments on commit 5651e9f

Please sign in to comment.