Commit b37c564b authored by Brendan Long's avatar Brendan Long

Move unit tests to Test top directory and add `make check`.

parent a2b9f593
......@@ -2,3 +2,4 @@
*.o
*.swp
moc-adapter
Tests/*Test
SRCS=VariantTest.cpp
ALLJOYN_INSTALL_DIR?=/
GTEST_DIR?=/usr/src/gtest
LIBXML_INC?=/usr/include/libxml2
CXX_WARNINGS=-Wall -Wextra -Wno-missing-field-initializers -Wno-deprecated-declarations -Wno-ignored-qualifiers
CXX_DEFINES=-D QCC_OS_GROUP_POSIX
CXX_SEARCH=-I.. -I$(ALLJOYN_INSTALL_DIR)/inc -I$(LIBXML_INC) -I$(GTEST_DIR)/include
CXXFLAGS=-isystem -std=c++0x -g $(CXX_WARNINGS) $(CXX_DEFINES) $(CXX_SEARCH)
LDFLAGS=-L$(ALLJOYN_INSTALL_DIR)/lib -lalljoyn -lcrypto -lxml2 -L$(GTEST_DIR)/libgtest.a
TEST_OBJS=$(patsubst %.cpp, %.o, $(SRCS))
OBJS=$(TEST_OBJS)
DEPS = $(OBJS:%.o=%.d)
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),Linux)
LDFLAGS += -pthread -luuid
endif
ifeq ($V, 1)
CXX_PRETTY = $(CXX)
LD_PRETTY = $(CXX)
else
CXX_PRETTY = @echo " [CXX] $<" ; $(CXX)
LD_PRETTY = @echo "[LINK] $@" ; $(CXX)
endif
ALL_TESTS=VariantTest
all: $(ALL_TESTS)
clean:
$(RM) $(ALL_TESTS) $(OBJS) $(DEPS)
VariantTest: VariantTest.cpp ../Variant.cpp
$(CXX) -isystem $(CXXFLAGS) $(LDFLAGS) $^ $(GTEST_DIR)/libgtest.a -o $@
%.o: %.cpp
$(CXX_PRETTY) $(CXXFLAGS) -MMD -c -o $@ $<
%.o: $(GTEST_DIR)/src/%.cc
$(CXX_PRETTY) $(CXXFLAGS) -MMD -c -o $@ $<
#-include $(DEPS)
Unit tests for common. Uses google gtest.
sudo apt-get install libgtest-dev
......@@ -19,6 +19,10 @@ SRCS=DeviceProviders/AllJoynProvider.cpp \
Adapters/ZigBeeAdapter/ZigBeeAdapter.cpp \
main.cpp
TEST_SRCS = Tests/VariantTest.cpp
TEST_OBJS = $(patsubst %.cpp, %.o, $(TEST_SRCS))
TESTS = $(patsubst %.cpp, %, $(TEST_SRCS))
LIBXML_INC?=/usr/include/libxml2
ALLJOYN_INSTALL_DIR?=/Users/jgladi200/Work/alljoyn/alljoyn-15.09.00a-src/build/darwin/x86/debug/dist/cpp
......@@ -27,7 +31,15 @@ CXXFLAGS=-D QCC_OS_GROUP_POSIX -Wall -Wextra -Wno-missing-field-initializers -Wn
LDFLAGS=-L $(ALLJOYN_INSTALL_DIR)/lib -lalljoyn -lcrypto -lxml2
DEV_PROVIDER_OBJS=$(patsubst %.cpp, %.o, $(SRCS))
OBJS=$(DEV_PROVIDER_OBJS)
DEPS = $(OBJS:%.o=%.d)
DEPS = $(OBJS:%.o=%.d) $(TEST_OBJS:%.o=%.d)
GTEST_DIR?=/usr/src/gtest
ifneq ("$(wildcard $(GTEST_DIR)/libgtest.a)","")
GTEST_FLAGS = $(GTEST_DIR)/libgtest.a
CXXFLAGS += -I$(GTEST_DIR)/include
else
GTEST_FLAGS = -lgtest
endif
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),Linux)
......@@ -50,12 +62,22 @@ endif
all: moc-adapter
tests: $(TESTS)
check: tests
@for test in $(TESTS) ; do \
$$test ; \
done
clean:
$(RM) moc-adapter $(OBJS) $(DEPS)
$(RM) moc-adapter $(TESTS) $(OBJS) $(DEPS) $(TEST_OBJS)
moc-adapter: $(OBJS)
$(LD_PRETTY) -o $@ $^ $(LDFLAGS)
Tests/VariantTest: Tests/VariantTest.o Common/Variant.o
$(LD_PRETTY) -o $@ $^ $(LDFLAGS) $(GTEST_FLAGS)
%.o: %.cpp
$(CXX_PRETTY) $(CXXFLAGS) -MMD -c -o $@ $<
......
#include <gtest/gtest.h>
#include <Variant.h>
#include <Common/Variant.h>
template<class T>
std::vector<T> makeVect(int n, int start = 0)
......
machine:
environment:
ALLJOYN_INSTALL_DIR: ~/alljoyn-15.09.00a-src/build/linux/x86_64/release/dist/cpp
ALLJOYN_INSTALL_DIR: \$(HOME)/alljoyn-15.09.00a-src/build/linux/x86_64/release/dist/cpp
GTEST_DIR: \$(HOME)/gtest
dependencies:
pre:
- sudo apt-get update
- sudo apt-get install libcap-dev scons
- sudo apt-get install libcap-dev scons libgtest-dev
- if [[ ! -e ~/alljoyn-15.09.00a-src ]] ; then
cd ~ ;
wget --no-check-certificate https://allseenalliance.org/releases/alljoyn/15.09/alljoyn-15.09.00a-src.tar.gz ;
......@@ -13,10 +14,22 @@ dependencies:
cd alljoyn-15.09.00a-src ;
scons BINDINGS=cpp OS=linux CPU=x86_64 VARIANT=release BUILD_SERVICE_SAMPLES=off WS=off BT=off ICE=off -j4 ;
fi
- if [[ ! -e ~/gtest ]] ; then
cd ~ ;
cp -r /usr/src/gtest . ;
cd gtest ;
cmake -DCMAKE_BUILD_TYPE=RELEASE . ;
make ;
fi
post:
- make ALLJOYN_INSTALL_DIR=~/alljoyn-15.09.00a-src/build/linux/x86_64/release/dist/cpp
- make -j4
- make tests -j4
cache_directories:
- "~/alljoyn-15.09.00a-src"
- "~/gtest"
test:
override:
- make check
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment