Permalink
Browse files

[GSOC] Have the testsuite built when the 'check' target is invoked.

Support a separate target named 'testsuite' which builds the test suite
without running it.

Also note that a configure option (--enable-gtest) must explicitely
be set in order to configure the Google Test Framework. If it is
not set, running the 'check,' 'testsuite,' or 'testframework,'
make targets will simply display a message saying the framework
has not been configured.
  • Loading branch information...
amejia1 committed Jun 19, 2012
1 parent cda15bb commit ec9ed53fc1c67ae26133490704e39a3f7f7e3cee
Showing with 65 additions and 7 deletions.
  1. +20 −2 Makefile.in
  2. +3 −3 Makefile.include.in
  3. +36 −0 configure.in
  4. +3 −1 xbmc/threads/test/Makefile
  5. +3 −1 xbmc/utils/test/Makefile
View
@@ -241,6 +241,7 @@ FINAL_TARGETS=xbmc.bin skins xbmc-xrandr
endif
FINAL_TARGETS+=Makefile externals
+GTEST_DIR = lib/gtest
CHECK_DIRS = xbmc/utils/test \
xbmc/threads/test
@@ -252,7 +253,8 @@ all : $(FINAL_TARGETS)
include Makefile.include
.PHONY : dllloader exports visualizations screensavers eventclients papcodecs \
- dvdpcodecs imagelib codecs externals force skins libaddon
+ dvdpcodecs imagelib codecs externals force skins libaddon check \
+ testframework testsuite
# hack targets to keep build system up to date
Makefile : config.status $(addsuffix .in, $(AUTOGENERATED_MAKEFILES))
@@ -573,5 +575,21 @@ clean-codecs: clean-dvdpcodecs clean-papcodecs
clean-externals: clean-codecs clean-eventclients clean-xbmctex clean-libs \
clean-screensavers clean-visualisations clean-libaddons
-check:
+ifeq (1,@GTEST_CONFIGURED@)
+check: testsuite
for d in $(CHECK_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d $@; fi; done
+
+testsuite: testframework
+ for d in $(CHECK_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d $@; fi; done
+
+testframework: $(GTEST_DIR)/lib/.libs/libgtest.a $(GTEST_DIR)/lib/.libs/libgtest_main.a
+
+$(GTEST_DIR)/lib/.libs/libgtest.a $(GTEST_DIR)/lib/.libs/libgtest_main.a: $(GTEST_DIR)/Makefile
+
+$(GTEST_DIR)/Makefile: force
+ $(MAKE) -C $(GTEST_DIR)
+else
+# Give a message that the framework is not configured, but don't fail.
+check testsuite testframework:
+ @echo "Google Test Framework not configured, skipping testsuite check."
+endif
View
@@ -125,7 +125,7 @@ GEN_DEPS=\
&& $(GEN_DEPS)
-.PHONY : lib pch clean distclean distclean_evil
+.PHONY : lib pch clean distclean distclean_evil check testsuite
$(LIB): $(OBJS)
$(SILENT_AR) $(AR) $(ARFLAGS) $(LIB) $(OBJS)
@@ -136,11 +136,11 @@ pch: $(PCH:.h=.h.gch)
clean:
$(RM) $(OBJS) *.o $(LIB) $(SLIB) $(CLEAN_FILES) $(PCH:.h=.h.gch) $(DEPS)
for d in $(DIRS); do (if test -f "$$d/Makefile"; then ($(MAKE) -C "$$d" clean); fi ); done
- for d in $(CHECK_DIRS); do if test -f $$d/Makefile; then $(MAKE) -C $$d $@; fi; done
+ for d in $(CHECK_DIRS) $(GTEST_DIR); do if test -f $$d/Makefile; then $(MAKE) -C $$d $@; fi; done
distclean:
$(RM) $(OBJS) *.o $(LIB) $(SLIB) $(STATICLIB) $(CLEAN_FILES) $(DISTCLEAN_FILES) $(PCH:.h=.h.gch) $(DEPS)
for d in $(DIRS); do (if test -f "$$d/Makefile"; then ($(MAKE) -C "$$d" distclean || $(MAKE) -C "$$d" clean); fi ); done
- for d in $(CHECK_DIRS); do (if test -f "$$d/Makefile"; then ($(MAKE) -C "$$d" $@ || $(MAKE) -C "$$d" clean); fi ); done
+ for d in $(CHECK_DIRS) $(GTEST_DIR); do (if test -f "$$d/Makefile"; then ($(MAKE) -C "$$d" $@ || $(MAKE) -C "$$d" clean); fi ); done
if [ "$(shell pwd -P)" = "$(abs_top_srcdir)" ] || \
[ "$(shell pwd)" = "$(abs_top_srcdir)" ]; then rm -f $(AUTOGENERATED_MAKEFILES) Makefile.include Makefile; fi
View
@@ -146,6 +146,8 @@ alsa_not_found="== Could not find ALSA. ALSA support disabled. =="
dbus_not_found="== Could not find DBUS. DBUS support disabled. =="
libcap_disabled="== Capabilities detection support disabled. =="
libcap_not_found="== Could not find libcap. Capabilities detection support disabled. =="
+gtest_enabled="== Google Test Framework will be configured. =="
+gtest_disabled="== Google Test Framework will not be configured. =="
libudev_not_found="== Could not find libudev. Will use polling to check for device changes. =="
libudev_disabled="== udev support disabled. Will use polling to check for device changes. =="
@@ -486,6 +488,12 @@ AC_ARG_ENABLE([player],
[add_players=$enableval],
[add_players=no])
+AC_ARG_ENABLE([gtest],
+ [AS_HELP_STRING([--enable-gtest],
+ [configure Google Test Framework (default is no)])],
+ [configure_gtest=$enableval],
+ [configure_gtest=no])
+
### External libraries options
AC_ARG_ENABLE([external-libraries],
[AS_HELP_STRING([--enable-external-libraries],
@@ -2018,6 +2026,19 @@ if test "$host_vendor" = "apple"; then
DVDREAD_CFLAGS="$DVDREAD_CFLAGS -D__DARWIN__"
fi
+# Google Test Framework
+if test "$configure_gtest" = "yes"; then
+ AC_MSG_NOTICE($gtest_enabled)
+ final_message="$final_message\n Google Test Framework Configured:\tYes"
+ GTEST_CONFIGURED=1
+ SKIP_CONFIG_GTEST=0
+else
+ AC_MSG_NOTICE($gtest_disabled)
+ final_message="$final_message\n Google Test Framework Configured:\tNo"
+ GTEST_CONFIGURED=0
+ SKIP_CONFIG_GTEST=1
+fi
+
if test "$use_avahi" = "yes"; then
final_message="$final_message\n Avahi:\tYes"
else
@@ -2321,6 +2342,7 @@ AC_SUBST(USE_CEC_RPI_API)
AC_SUBST(USE_MYSQL)
AC_SUBST(USE_WEB_SERVER)
AC_SUBST(USE_ANDROID)
+AC_SUBST(GTEST_CONFIGURED)
# pushd and popd are not available in other shells besides bash, so implement
@@ -2636,6 +2658,20 @@ XB_CONFIG_MODULE([lib/cpluff], [
#LDFLAGS="$LDFLAGS -Wl,-read_only_relocs,suppress"
], [0])
+XB_CONFIG_MODULE([lib/gtest], [
+ ./configure \
+ CC="$CC" \
+ CXX="$CXX" \
+ CFLAGS="$CFLAGS" \
+ --prefix="${prefix}" --includedir="${includedir}" --libdir="${libdir}" --datadir="${datadir}" \
+ --host=$host_alias \
+ --build=$build_alias \
+ --target=$target_alias \
+ --disable-shared \
+ --enable-static \
+ --with-pthreads
+], [$SKIP_CONFIG_GTEST])
+
AC_OUTPUT
final_message="$final_message\n prefix:\t$prefix\n$dashes"
@@ -10,9 +10,11 @@ LIB=threadTest.a
CLEAN_FILES=testMain
-check: testMain
+check: testsuite
./testMain
+testsuite: testMain
+
include ../../../Makefile.include
-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
View
@@ -6,9 +6,11 @@ LIB=utilsTest.a
CLEAN_FILES=testMain
-check: testMain
+check: testsuite
./testMain
+testsuite: testMain
+
include ../../../Makefile.include
-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))

0 comments on commit ec9ed53

Please sign in to comment.