diff --git a/Makefile.in b/Makefile.in index e4fcd4367..bf848e469 100644 --- a/Makefile.in +++ b/Makefile.in @@ -449,7 +449,9 @@ gui/QT/uv-qt: $(wildcard $(srcdir)/gui/QT/*.cpp $(srcdir)/gui/QT/*.hpp) $(srcdir cd gui/QT && $(QMAKE) $(srcdir)/../../gui/QT && make -j 4 $(MAKE_GUI_TARGET) # ------------------------------------------------------------------------------------------------- -TEST_OBJS = test/test_bitstream.o \ +TEST_OBJS = test/get_framerate_test.o \ + test/video_desc_test.o \ + test/test_bitstream.o \ test/test_aes.o \ test/test_des.o \ test/test_md5.o \ @@ -463,7 +465,7 @@ TEST_OBJS = test/test_bitstream.o \ test/run_tests: $(TEST_OBJS) $(OBJS) $(MKDIR_P) $(dir $@) - $(LINKER) $(CFLAGS) $(TEST_OBJS) $(OBJS) $(LIBS) -o test/run_tests + $(LINKER) $(CFLAGS) $(TEST_OBJS) $(OBJS) $(LIBS) @CPPUNIT_LIBS@ -o test/run_tests suggest-tests: @echo "" @@ -477,25 +479,8 @@ configure-messages: tests: test/run_tests @test/run_tests -UNITTEST_OBJS = unittest/run_tests.o \ - unittest/get_framerate_test.o \ - unittest/video_desc_test.o -UNITTEST_DEPS = src/compat/platform_time.o \ - src/debug.o \ - src/utils/misc.o \ - src/video.o \ - src/video_frame.o \ - src/video_codec.o - -unittest/run_tests: $(UNITTEST_OBJS) $(UNITTESTS_DEPS) - $(MKDIR_P) $(dir $@) - $(LINKER) $(LDFLAGS) $(UNITTEST_OBJS) $(UNITTEST_DEPS) $(LIBS) -lcppunit -o $@ - -unittests: unittest/run_tests - @unittest/run_tests - -check: @UNITTESTS_TARGET@ tests +check: tests distcheck: all $(TARGET) >/dev/null 2>&1 @@ -539,16 +524,16 @@ distclean: clean -rm -f Makefile config.status config.cache config.log src/config.h cscope.out tags etags: - etags $$(find $(srcdir)/src \( -name '*.c' -o -name '*.cpp' -o -name '*.cu' -o -name '*.h' -o -name '*.hpp' -o -name '*.m' -o -name '*.mm' \)) + etags $$(find $(srcdir)/src $(srcdir)/test \( -name '*.c' -o -name '*.cpp' -o -name '*.cu' -o -name '*.h' -o -name '*.hpp' -o -name '*.m' -o -name '*.mm' \)) ctags: - ctags $$(find $(srcdir)/src \( -name '*.c' -o -name '*.cpp' -o -name '*.cu' -o -name '*.h' -o -name '*.hpp' -o -name '*.m' -o -name '*.mm' \)) + ctags $$(find $(srcdir)/src $(srcdir)/test \( -name '*.c' -o -name '*.cpp' -o -name '*.cu' -o -name '*.h' -o -name '*.hpp' -o -name '*.m' -o -name '*.mm' \)) ctags-universal: - ctags-universal -bv $$(find $(srcdir)/src \( -name '*.c' -o -name '*.cpp' -o -name '*.cu' -o -name '*.h' -o -name '*.hpp' -o -name '*.m' -o -name '*.mm' \)) + ctags-universal -bv $$(find $(srcdir)/src $(srcdir)/test \( -name '*.c' -o -name '*.cpp' -o -name '*.cu' -o -name '*.h' -o -name '*.hpp' -o -name '*.m' -o -name '*.mm' \)) cscope: - cscope -bv $$(find $(srcdir)/src \( -name '*.c' -o -name '*.cpp' -o -name '*.cu' -o -name '*.h' -o -name '*.hpp' -o -name '*.m' -o -name '*.mm' \)) + cscope -bv $$(find $(srcdir)/src $(srcdir)/test \( -name '*.c' -o -name '*.cpp' -o -name '*.cu' -o -name '*.h' -o -name '*.hpp' -o -name '*.m' -o -name '*.mm' \)) doc: cd $(srcdir) && doxygen Doxyfile diff --git a/configure.ac b/configure.ac index 75fd66e03..68e7a57fb 100644 --- a/configure.ac +++ b/configure.ac @@ -3009,11 +3009,11 @@ fi # --------------------------------------------------------------------- PKG_CHECK_MODULES([CPPUNIT], [cppunit], [cppunit=yes], [cppunit=no]) if test "$cppunit" = yes; then - UNITTESTS_TARGET=unittests + AC_DEFINE([HAVE_CPPUNIT], [1], [Build with CppUnit tests]) else - UNITTESTS_TARGET= + CPPUNIT_LIBS= fi -AC_SUBST(UNITTESTS_TARGET) +AC_SUBST(CPPUNIT_LIBS) # ------------------------------------------------------------------------------------------------- # We need to add libraries then diff --git a/unittest/get_framerate_test.cpp b/test/get_framerate_test.cpp similarity index 98% rename from unittest/get_framerate_test.cpp rename to test/get_framerate_test.cpp index a1407e538..09e60af02 100644 --- a/unittest/get_framerate_test.cpp +++ b/test/get_framerate_test.cpp @@ -4,6 +4,8 @@ #include "config_win32.h" #endif +#ifdef HAVE_CPPUNIT + #include #include #include @@ -100,3 +102,4 @@ get_framerate_test::test_free() } } +#endif // defined HAVE_CPPUNIT diff --git a/unittest/get_framerate_test.h b/test/get_framerate_test.h similarity index 100% rename from unittest/get_framerate_test.h rename to test/get_framerate_test.h diff --git a/test/run_tests.c b/test/run_tests.cpp similarity index 73% rename from test/run_tests.c rename to test/run_tests.cpp index 920b87565..84eb0f18f 100644 --- a/test/run_tests.c +++ b/test/run_tests.cpp @@ -1,5 +1,5 @@ /* - * FILE: run_tests.c + * FILE: run_tests.cpp * AUTHORS: Colin Perkins * * Copyright (c) 2004 University of Glasgow @@ -36,10 +36,20 @@ * $Date: 2008/01/10 11:07:42 $ */ +#ifdef HAVE_CONFIG_H #include "config.h" #include "config_unix.h" #include "config_win32.h" +#endif + +#ifdef HAVE_CPPUNIT +#include +#include +#include +#endif + #include "debug.h" +extern "C" { #include "test_host.h" #include "test_aes.h" #include "test_bitstream.h" @@ -51,11 +61,10 @@ #include "test_rtp.h" #include "test_video_capture.h" #include "test_video_display.h" +} #define TEST_AV_HW 1 -uint32_t RTT; /* FIXME: will be removed once the global in main.c is removed */ - /* These globals should be fixed in the future as well */ uint32_t hd_size_x = 1920; uint32_t hd_size_y = 1080; @@ -66,10 +75,11 @@ uint32_t hd_video_mode; long packet_rate = 13600; -void exit_uv(int ret); -void exit_uv(int ret) +extern "C" void exit_uv(int status); + +void exit_uv(int status) { - exit(ret); + exit(status); } int main() @@ -88,7 +98,7 @@ int main() return 1; if (test_tv() != 0) return 1; - if (test_net_udp() != 0) + if (!getenv("UG_SKIP_NET_TESTS") && test_net_udp() != 0) return 1; if (test_rtp() != 0) return 1; @@ -100,5 +110,25 @@ int main() return 1; #endif +#ifdef HAVE_CPPUNIT + printf("Running CppUnit tests:\n"); + // Get the top level suite from the registry + CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest(); + + // Adds the test to the list of test to run + CPPUNIT_NS::TextUi::TestRunner runner; + runner.addTest( suite ); + + // Change the default outputter to a compiler error format outputter + runner.setOutputter( new CPPUNIT_NS::CompilerOutputter( &runner.result(), + CPPUNIT_NS::stdCOut() ) ); + // Run the test. + bool wasSucessful = runner.run(); + + // Return error code 1 if the one of test failed. + return wasSucessful ? 0 : 1; +#else return 0; +#endif } + diff --git a/unittest/video_desc_test.cpp b/test/video_desc_test.cpp similarity index 96% rename from unittest/video_desc_test.cpp rename to test/video_desc_test.cpp index 844f4e63c..b78645f8e 100644 --- a/unittest/video_desc_test.cpp +++ b/test/video_desc_test.cpp @@ -4,6 +4,8 @@ #include "config_win32.h" #endif +#ifdef HAVE_CPPUNIT + #ifdef HAVE_CONFIG_H #include "config.h" #include "config_unix.h" @@ -62,3 +64,4 @@ video_desc_test::testIOOperatorSymetry() } } +#endif // defined HAVE_CPPUNIT diff --git a/unittest/video_desc_test.h b/test/video_desc_test.h similarity index 100% rename from unittest/video_desc_test.h rename to test/video_desc_test.h diff --git a/unittest/run_tests.cpp b/unittest/run_tests.cpp deleted file mode 100644 index 6559e5f30..000000000 --- a/unittest/run_tests.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#include "config_unix.h" -#include "config_win32.h" -#endif - -#include -#include -#include - -extern "C" void exit_uv(int status); - -void exit_uv(int status) -{ - exit(status); -} - -int main(int, char *[]) -{ - // Get the top level suite from the registry - CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest(); - - // Adds the test to the list of test to run - CPPUNIT_NS::TextUi::TestRunner runner; - runner.addTest( suite ); - - // Change the default outputter to a compiler error format outputter - runner.setOutputter( new CPPUNIT_NS::CompilerOutputter( &runner.result(), - CPPUNIT_NS::stdCOut() ) ); - // Run the test. - bool wasSucessful = runner.run(); - - // Return error code 1 if the one of test failed. - return wasSucessful ? 0 : 1; -} -