diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..f682a13 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "cxxtest"] + path = cxxtest + url = https://github.com/CxxTest/cxxtest diff --git a/Makefile b/Makefile index 0b27e4a..d031026 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/build.Makefile b/build.Makefile index f94345a..d292221 100644 --- a/build.Makefile +++ b/build.Makefile @@ -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 @@ -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") diff --git a/cpp/Unittests/test_osmosis_main.h b/cpp/Unittests/test_osmosis_main.h new file mode 100644 index 0000000..a7a951f --- /dev/null +++ b/cpp/Unittests/test_osmosis_main.h @@ -0,0 +1,14 @@ +#include +#include + +std::mutex globalTraceLock; + +class MyTestSuite1 : public CxxTest::TestSuite +{ +public: + void testAddition(void) + { + TS_ASSERT(1 + 1 > 1); + TS_ASSERT_EQUALS(1 + 1, 2); + } +}; diff --git a/cxxtest b/cxxtest new file mode 160000 index 0000000..191addd --- /dev/null +++ b/cxxtest @@ -0,0 +1 @@ +Subproject commit 191adddb3876ab389c0c856e1c03874bf70f8ee4 diff --git a/targets.Makefile b/targets.Makefile index 5a25a3d..8cf25b5 100644 --- a/targets.Makefile +++ b/targets.Makefile @@ -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 \ @@ -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}