ref: fb429bbf6788ceaef000fc685f4d6be6d99e8dcc
parent: 5449a8a548129edb3561bcdedb54ca6deffcf879
author: EKR <[email protected]>
date: Thu Dec 12 05:56:52 EST 2013
Add gtest support
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,7 @@
LIBPREFIX=lib
LIBSUFFIX=a
ROOTDIR=$(PWD)
+HAVE_GTEST=Yes
# Configurations
ifeq ($(BUILDTYPE), Release)
@@ -24,7 +25,7 @@
#### 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 @@
H264ENC_INCLUDES = $(ENCODER_INCLUDES) -Icodec/console/enc/inc
H264ENC_LDFLAGS = -L. -lencoder -lprocessing -lcommon
+CODEC_UNITTEST_LDFLAGS = -L. -lgtest
+
all: libraries binaries
clean:
@@ -61,6 +64,13 @@
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
+
+
--- a/build/mktargets.sh
+++ b/build/mktargets.sh
@@ -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)
+
--- a/codec/common/targets.mk
+++ b/codec/common/targets.mk
@@ -4,7 +4,7 @@
$(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)
--- /dev/null
+++ b/test/simple_test.cpp
@@ -1,0 +1,7 @@
+#include <gtest/gtest.h>
+
+int main(int argc, char **argv) {
+ testing::InitGoogleTest(&argc, argv);
+
+ return RUN_ALL_TESTS();
+}
--- /dev/null
+++ b/test/targets.mk
@@ -1,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