Add gtest support

This commit is contained in:
EKR
2013-12-12 10:56:52 +08:00
parent 5449a8a548
commit fb429bbf67
5 changed files with 42 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ UNAME=$(shell uname | tr A-Z a-z)
LIBPREFIX=lib
LIBSUFFIX=a
ROOTDIR=$(PWD)
HAVE_GTEST=Yes
# Configurations
ifeq ($(BUILDTYPE), Release)
@@ -24,7 +25,7 @@ ASMFLAGS += -DNO_DYNAMIC_VP -DNOPREFIX
#### No user-serviceable parts below this line
INCLUDES = -Icodec/api/svc -Icodec/common
INCLUDES = -Icodec/api/svc -Icodec/common -Igtest/include
ASM_INCLUDES = -Iprocessing/src/asm/
COMMON_INCLUDES = \
@@ -49,6 +50,8 @@ H264DEC_LDFLAGS = -L. -ldecoder -lcommon
H264ENC_INCLUDES = $(ENCODER_INCLUDES) -Icodec/console/enc/inc
H264ENC_LDFLAGS = -L. -lencoder -lprocessing -lcommon
CODEC_UNITTEST_LDFLAGS = -L. -lgtest
all: libraries binaries
clean:
@@ -62,5 +65,12 @@ include processing/targets.mk
include codec/console/dec/targets.mk
include codec/console/enc/targets.mk
ifdef HAVE_GTEST
include gtest/targets.mk
include test/targets.mk
endif

View File

@@ -6,3 +6,5 @@
(cd codec/console/dec; python ../../../build/mktargets.py --directory codec/console/dec --binary h264dec --exclude dec_console.h --exclude load_bundle_functions.cpp)
(cd codec/console/enc; python ../../../build/mktargets.py --directory codec/console/enc --binary h264enc --exclude enc_console.h --exclude bundlewelsenc.cpp)
(cd test; python ../build/mktargets.py --directory test --binary codec_unittest)

View File

@@ -4,7 +4,7 @@ COMMON_CPP_SRCS=\
$(COMMON_SRCDIR)/./logging.cpp\
COMMON_OBJS += $(COMMON_CPP_SRCS:.cpp=.o)
ifdef USE_ASM
ifeq ($(USE_ASM), Yes)
COMMON_ASM_SRCS=\
COMMON_OBJS += $(COMMON_ASM_SRCS:.asm=.o)

7
test/simple_test.cpp Normal file
View File

@@ -0,0 +1,7 @@
#include <gtest/gtest.h>
int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

21
test/targets.mk Normal file
View File

@@ -0,0 +1,21 @@
CODEC_UNITTEST_PREFIX=CODEC_UNITTEST
CODEC_UNITTEST_SRCDIR=test
CODEC_UNITTEST_CPP_SRCS=\
$(CODEC_UNITTEST_SRCDIR)/./simple_test.cpp\
CODEC_UNITTEST_OBJS += $(CODEC_UNITTEST_CPP_SRCS:.cpp=.o)
ifeq ($(USE_ASM), Yes)
CODEC_UNITTEST_ASM_SRCS=\
CODEC_UNITTEST_OBJS += $(CODEC_UNITTEST_ASM_SRCS:.asm=.o)
endif
OBJS += $(CODEC_UNITTEST_OBJS)
$(CODEC_UNITTEST_SRCDIR)/./simple_test.o: $(CODEC_UNITTEST_SRCDIR)/./simple_test.cpp
$(CXX) $(CFLAGS) $(CXXFLAGS) $(INCLUDES) $(CODEC_UNITTEST_CFLAGS) $(CODEC_UNITTEST_INCLUDES) -c -o $(CODEC_UNITTEST_SRCDIR)/./simple_test.o $(CODEC_UNITTEST_SRCDIR)/./simple_test.cpp
codec_unittest: $(CODEC_UNITTEST_OBJS) $(LIBS) $(CODEC_UNITTEST_LIBS)
$(CXX) -o $@ $(CODEC_UNITTEST_OBJS) $(CODEC_UNITTEST_LDFLAGS) $(CODEC_UNITTEST_LIBS) $(LDFLAGS) $(LIBS)
binaries: codec_unittest
BINARIES += codec_unittest