Skip to content
Browse files

[GSOC] Build a single 'main' test program.

This main program will be linked with all libraries in similar fashion as
xbmc.bin and libxbmc.so.

This required modifications to the build system so that the main() function
for xbmc.bin does not get linked with the main() function for the
testsuite program. This has the side effect of allowing xbmc.bin and
libxbmc.so to be built from a single build.
  • Loading branch information...
1 parent c0b4151 commit 314ffb3ddc2df9e612933d7638e62cd807526048 @amejia1 amejia1 committed Jun 21, 2012
View
44 Makefile.in
@@ -90,8 +90,8 @@ DIRECTORY_ARCHIVES=$(DVDPLAYER_ARCHIVES) \
xbmc/xbmc.a \
-NWAOBJSXBMC= xbmc/commons/commons.a \
- xbmc/threads/threads.a \
+NWAOBJSXBMC= xbmc/threads/threads.a \
+ xbmc/commons/commons.a
ifeq (@USE_WEB_SERVER@,1)
@@ -242,8 +242,18 @@ endif
FINAL_TARGETS+=Makefile externals
GTEST_DIR = lib/gtest
+GTEST_INCLUDES = -I$(GTEST_DIR)/include
+GTEST_LIBS = $(GTEST_DIR)/lib/.libs/libgtest.a
+
CHECK_DIRS = xbmc/utils/test \
- xbmc/threads/test
+ xbmc/threads/test \
+ xbmc/test
+CHECK_LIBS = xbmc/utils/test/utilsTest.a \
+ xbmc/threads/test/threadTest.a \
+ xbmc/test/xbmc-test.a
+CHECK_PROGRAMS = xbmc-test
+
+CLEAN_FILES += $(CHECK_PROGRAMS)
all : $(FINAL_TARGETS)
@echo '-----------------------'
@@ -417,14 +427,17 @@ else
$(SILENT_LD) $(CXX) $(CXXFLAGS) $(LDFLAGS) -shared -o $@ -Wl,--whole-archive $(DYNOBJSXBMC) $(OBJSXBMC) -Wl,--no-whole-archive -Wl,--no-undefined $(NWAOBJSXBMC) $(LIBS)
endif
-xbmc.bin: $(OBJSXBMC) $(DYNOBJSXBMC) $(NWAOBJSXBMC)
+xbmc.bin: xbmc/main/main.a $(OBJSXBMC) $(DYNOBJSXBMC) $(NWAOBJSXBMC)
ifeq ($(findstring osx,@ARCH@), osx)
- $(SILENT_LD) $(CXX) $(LDFLAGS) -o xbmc.bin -Wl,-all_load,-ObjC $(DYNOBJSXBMC) $(NWAOBJSXBMC) $(OBJSXBMC) $(LIBS) -rdynamic
+ $(SILENT_LD) $(CXX) $(LDFLAGS) -o xbmc.bin -Wl,-all_load,-ObjC $(DYNOBJSXBMC) $(NWAOBJSXBMC) $(OBJSXBMC) xbmc/main/main.a $(LIBS) -rdynamic
else
- $(SILENT_LD) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o xbmc.bin -Wl,--whole-archive $(DYNOBJSXBMC) $(OBJSXBMC) -Wl,--no-whole-archive $(NWAOBJSXBMC) $(LIBS) -rdynamic
+ $(SILENT_LD) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o xbmc.bin -Wl,--whole-archive $(DYNOBJSXBMC) $(OBJSXBMC) xbmc/main/main.a -Wl,--no-whole-archive $(NWAOBJSXBMC) $(LIBS) -rdynamic
endif
+xbmc/main/main.a: force
+ $(MAKE) -C xbmc/main
+
xbmc-xrandr: xbmc-xrandr.c
ifneq (1,@USE_XRANDR@)
# xbmc-xrandr.c gets picked up by the default make rules
@@ -577,17 +590,26 @@ clean-externals: clean-codecs clean-eventclients clean-xbmctex clean-libs \
ifeq (1,@GTEST_CONFIGURED@)
check: testsuite
- for d in $(CHECK_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d $@; fi; done
+ for check_program in $(CHECK_PROGRAMS); do $(CURDIR)/$$check_program; done
-testsuite: testframework
- for d in $(CHECK_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d $@; fi; done
+testsuite: $(CHECK_PROGRAMS)
-testframework: $(GTEST_DIR)/lib/.libs/libgtest.a $(GTEST_DIR)/lib/.libs/libgtest_main.a
+testframework: $(GTEST_LIBS)
-$(GTEST_DIR)/lib/.libs/libgtest.a $(GTEST_DIR)/lib/.libs/libgtest_main.a: $(GTEST_DIR)/Makefile
+$(GTEST_LIBS): $(GTEST_DIR)/Makefile
$(GTEST_DIR)/Makefile: force
$(MAKE) -C $(GTEST_DIR)
+
+$(CHECK_LIBS): force
+ @$(MAKE) $(if $(V),,-s) -C $(@D)
+
+xbmc-test: $(CHECK_LIBS) $(OBJSXBMC) $(DYNOBJSXBMC) $(NWAOBJSXBMC) $(GTEST_LIBS)
+ifeq ($(findstring osx,@ARCH@), osx)
+ $(SILENT_LD) $(CXX) $(LDFLAGS) $(GTEST_INCLUDES) -o $@ -Wl,-all_load,-ObjC $(CHECK_LIBS) $(DYNOBJSXBMC) $(NWAOBJSXBMC) $(OBJSXBMC) $(GTEST_LIBS) $(LIBS) -rdynamic
+else
+ $(SILENT_LD) $(CXX) $(CXXFLAGS) $(LDFLAGS) $(GTEST_INCLUDES) -o $@ -Wl,--whole-archive $(CHECK_LIBS) $(DYNOBJSXBMC) $(OBJSXBMC) -Wl,--no-whole-archive $(NWAOBJSXBMC) $(GTEST_LIBS) $(LIBS) -rdynamic
+endif
else
# Give a message that the framework is not configured, but don't fail.
check testsuite testframework:
View
4 xbmc/Makefile.in
@@ -38,10 +38,6 @@ SRCS=Application.cpp \
LIB=xbmc.a
-ifneq (@USE_LIBXBMC@,1)
-SRCS += main.cpp
-endif
-
DISTCLEAN_FILES=DllPaths_generated.h
include @abs_top_srcdir@/Makefile.include
View
7 xbmc/main/Makefile
@@ -0,0 +1,7 @@
+SRCS= \
+ main.cpp
+
+LIB=main.a
+
+include ../../Makefile.include
+-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
View
0 xbmc/main.cpp → xbmc/main/main.cpp
File renamed without changes.
View
9 xbmc/test/Makefile
@@ -0,0 +1,9 @@
+SRCS= \
+ xbmc-test.cpp
+
+LIB=xbmc-test.a
+
+INCLUDES += -I../../lib/gtest/include
+
+include ../../Makefile.include
+-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
View
7 xbmc/threads/test/TestMain.cpp → xbmc/test/xbmc-test.cpp
@@ -19,13 +19,11 @@
*
*/
-#include "TestHelpers.h"
+#include "gtest/gtest.h"
#include "threads/Thread.h"
#include "commons/ilog.h"
-using ::testing::InitGoogleTest;
-
class NullLogger : public XbmcCommons::ILogger
{
public:
@@ -34,7 +32,7 @@ class NullLogger : public XbmcCommons::ILogger
int main(int argc, char **argv)
{
- InitGoogleTest(&argc, argv);
+ testing::InitGoogleTest(&argc, argv);
// we need to configure CThread to use a dummy logger
NullLogger* nullLogger = new NullLogger();
@@ -46,4 +44,3 @@ int main(int argc, char **argv)
return ret;
}
-
View
20 xbmc/threads/test/Makefile
@@ -1,30 +1,12 @@
SRCS= \
- TestMain.cpp \
TestEvent.cpp \
TestSharedSection.cpp \
TestAtomics.cpp \
TestThreadLocal.cpp
-
LIB=threadTest.a
-CLEAN_FILES=testMain
-
-GTEST_INCLUDES = -I../../../lib/gtest/include
-GTEST_LIBS = ../../../lib/gtest/lib/.libs/libgtest.a \
- ../../../lib/gtest/lib/.libs/libgtest_main.a
-
-INCLUDES += $(GTEST_INCLUDES)
-
-check: testsuite
- ./testMain
-
-testsuite: testMain
+INCLUDES += -I../../../lib/gtest/include
include ../../../Makefile.include
-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
-
-testMain: $(LIB) ../threads.a $(GTEST_LIBS)
- $(CXX) $(CXXFLAGS) $(LDFLAGS) $(GTEST_INCLUDES) -o testMain $(OBJS) ../threads.a ../../commons/commons.a $(GTEST_LIBS) -lpthread -lrt
-
-
View
17 xbmc/utils/test/Makefile
@@ -1,24 +1,9 @@
SRCS= \
- TestMain.cpp \
TestGlobalsHandling.cpp
LIB=utilsTest.a
-CLEAN_FILES=testMain
-
-GTEST_INCLUDES = -I../../../lib/gtest/include
-GTEST_LIBS = ../../../lib/gtest/lib/.libs/libgtest.a \
- ../../../lib/gtest/lib/.libs/libgtest_main.a
-
-INCLUDES += $(GTEST_INCLUDES)
-
-check: testsuite
- ./testMain
-
-testsuite: testMain
+INCLUDES += -I../../../lib/gtest/include
include ../../../Makefile.include
-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
-
-testMain: $(LIB) $(GTEST_LIBS)
- $(CXX) $(CXXFLAGS) $(LDFLAGS) $(GTEST_INCLUDES) -o testMain -Wl,--whole-archive $(LIB) -Wl,--no-whole-archive $(GTEST_LIBS) -lpthread
View
29 xbmc/utils/test/TestMain.cpp
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2005-2011 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "gtest/gtest.h"
-
-using ::testing::InitGoogleTest;
-
-int main(int argc, char **argv) {
- InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}

0 comments on commit 314ffb3

Please sign in to comment.
Something went wrong with that request. Please try again.