]> WPIA git - cassiopeia.git/commitdiff
add: Basic Unit Test setup using Boost UTF
authorBenny Baumann <BenBE@geshi.org>
Thu, 13 Nov 2014 18:32:59 +0000 (19:32 +0100)
committerBenny Baumann <BenBE@geshi.org>
Thu, 13 Nov 2014 18:44:56 +0000 (19:44 +0100)
debian/control
test/Makefile
test/src/main.cpp [new file with mode: 0644]
test/src/sanity.cpp [new file with mode: 0644]

index 4d4c742c61ff41b08f8ded13ebf707f4d2995f16..6ac64498e5e1cf8e5b7f76bed422322ad29b3c0c 100644 (file)
@@ -2,7 +2,7 @@ Source: cacert-cassiopeia
 Section: utils
 Priority: extra
 Maintainer: CAcert Software Team <cacert-devel@cacert.org>
-Build-Depends: debhelper (>= 8.0.0), libtool, libmysqlclient-dev (>= 5.5), libssl-dev
+Build-Depends: debhelper (>= 8.0.0), libtool, libmysqlclient-dev (>= 5.5), libssl-dev, libboost-test-dev
 Standards-Version: 3.9.4
 Homepage: https://cacert.org/
 #Vcs-Git: git://git.debian.org/collab-maint/cassiopeia.git
index 4618c427d5cf296f1e2381abcd74d4dc99bf0132..a765a9a333d3888b2d566199c74d2e97daefd9b0 100644 (file)
@@ -1,7 +1,93 @@
+MKDIR = mkdir -p
+
+ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
+    CFLAGS += -O0
+else
+    CFLAGS += -O2
+endif
+
+BIN="bin/cassiopeia-test"
+LIBS=openssl collissiondetect
+
+LT_CC=libtool --mode=compile gcc
+LT_CC_DEP=g++
+LT_CXX=libtool --mode=compile g++
+LT_CXX_DEP=g++
+LT_LD=libtool --mode=link g++
+
+CC=${LT_CC}
+CC_DEP=${LT_CC_DEP}
+CXX=${LT_CXX}
+CXX_DEP=${LT_CXX_DEP}
+LD=${LT_LD}
+
+ifneq (,$(filter debug,$(DEB_BUILD_OPTIONS)))
+ADDFLAGS=-DNO_DAEMON
+endif
+
+CFLAGS=-O3 -g -flto -Wall -Werror -Wextra -pedantic -std=c++11 ${ADDFLAGS}
+CXXFLAGS=$(CFLAGS)
+LDFLAGS=-O3 -g -flto -lmysqlclient -lssl -lcrypto -ldl -lboost_unit_test_framework
+
+SRC_DIR=src
+OBJ_DIR=obj
+DEP_DIR=dep
+
+FS_SRC=$(wildcard ${SRC_DIR}/*.cpp)
+FS_BIN=$(wildcard ${SRC_DIR}/app/*.cpp)
+FS_LIBS=$(wildcard lib/*/)
+FS_OBJ=$(FS_SRC:${SRC_DIR}/%.cpp=${OBJ_DIR}/%.lo)
+FS_DEP=$(FS_SRC:${SRC_DIR}/%.cpp=${DEP_DIR}/%.d)
+
+.SUFFIXES: .c .cpp .d
+
 .PHONY: all
-all:
-       @echo 'Performing some important tests ...'
+all: build
 
 .PHONY: clean
-clean:
-       @echo 'Cleaning up behind us ...'
+clean::
+       -rm -rf .libs
+       -rm -rf *.a
+       -rm -rf *.d
+       -rm -rf *.o
+       -rm -rf *.la
+       -rm -rf *.lo
+       -rm -rf *.so
+       -rm -rf ${OBJ_DIR}
+       -rm -rf ${DEP_DIR}
+
+build: cassiopeia-test
+       ${BIN}
+
+.PHONY: install
+install: build
+
+.PHONY: libs
+libs: ${LIBS}
+
+.PHONY: openssl
+openssl:
+       ${MAKE} -C ../lib/openssl
+
+.PHONY: collissiondetect
+collissiondetect:
+       ${MAKE} -C ../lib/collissiondetect
+
+# --------
+
+cassiopeia-test: bin/cassiopeia-test
+
+bin/cassiopeia-test: libs ${FS_OBJ}
+       ${MKDIR} $(shell dirname $@) && ${LT_LD} ${LDFLAGS} -o $@ ${FS_OBJ}
+
+${DEP_DIR}/%.d: ${SRC_DIR}/%.cpp
+       ${MKDIR} $(shell dirname $@) && $(CXX_DEP) $(CXXFLAGS) -M -MF $@ $<
+${DEP_DIR}/%.d: ${SRC_DIR}/%.c
+       ${MKDIR} $(shell dirname $@) && $(CC) $(CXXFLAGS) -M -MF $@ $<
+
+${OBJ_DIR}/%.lo ${OBJ_DIR}/%.o: ${SRC_DIR}/%.c ${DEP_DIR}/%.d
+       ${MKDIR} $(shell dirname $@) && $(CC) $(CFLAGS) -o $@ -c $<
+${OBJ_DIR}/%.lo ${OBJ_DIR}/%.o: ${SRC_DIR}/%.cpp ${DEP_DIR}/%.d
+       ${MKDIR} $(shell dirname $@) && $(CXX) $(CXXFLAGS) -o $@ -c $<
+
+-include $(FS_DEP)
diff --git a/test/src/main.cpp b/test/src/main.cpp
new file mode 100644 (file)
index 0000000..313b620
--- /dev/null
@@ -0,0 +1,4 @@
+#define BOOST_TEST_DYN_LINK
+#define BOOST_TEST_MODULE Cassiopeia
+
+#include <boost/test/unit_test.hpp>
diff --git a/test/src/sanity.cpp b/test/src/sanity.cpp
new file mode 100644 (file)
index 0000000..81851bb
--- /dev/null
@@ -0,0 +1,9 @@
+#define BOOST_TEST_NO_MAIN
+#define BOOST_TEST_MODULE Cassiopeia
+
+#include <boost/test/unit_test.hpp>
+
+BOOST_AUTO_TEST_CASE(Foo)
+{
+    BOOST_REQUIRE(true);
+}