diff --git a/gtk2_ardour/artest b/gtk2_ardour/artest index 0e88049427..0763c2ff46 100755 --- a/gtk2_ardour/artest +++ b/gtk2_ardour/artest @@ -35,6 +35,7 @@ run_tests midi++2 run_tests evoral run_tests pbd run_tests ardour +run_tests temporal if test "$ALLGOOD" != "yes"; then echo "" diff --git a/libs/temporal/test/BeatTest.h b/libs/temporal/test/BeatTest.h new file mode 100644 index 0000000000..0db3831b49 --- /dev/null +++ b/libs/temporal/test/BeatTest.h @@ -0,0 +1,22 @@ +#include +#include + +class BeatsTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(BeatsTest); + CPPUNIT_TEST(createTest); + CPPUNIT_TEST(addTest); + CPPUNIT_TEST(subtractTest); + CPPUNIT_TEST(multiplyTest); + CPPUNIT_TEST(convertTest); + CPPUNIT_TEST(roundTest); + CPPUNIT_TEST_SUITE_END(); + +public: + void createTest(); + void addTest(); + void subtractTest(); + void multiplyTest(); + void convertTest(); + void roundTest(); +}; diff --git a/libs/temporal/test/testrunner.cc b/libs/temporal/test/testrunner.cc new file mode 100644 index 0000000000..664bdf5774 --- /dev/null +++ b/libs/temporal/test/testrunner.cc @@ -0,0 +1,70 @@ +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "pbd/debug.h" +#include "pbd/pbd.h" +#include "temporal/types.h" + +int +main(int argc, char* argv[]) +{ + if (!Glib::thread_supported()) { + Glib::thread_init(); + } + + const struct option longopts[] = { + { "debug", 1, 0, 'D' }, + { 0, 0, 0, 0 } + }; + const char *optstring = "D:"; + int option_index = 0; + int c = 0; + + while (1) { + c = getopt_long (argc, argv, optstring, longopts, &option_index); + + if (c == -1) { + break; + } + + switch (c) { + case 0: + break; + + case 'D': + if (PBD::parse_debug_options (optarg)) { + exit (0); + } + break; + } + } + + if (!PBD::init ()) return 1; + Temporal::init (); + + CppUnit::TestResult testresult; + + CppUnit::TestResultCollector collectedresults; + testresult.addListener (&collectedresults); + + CppUnit::BriefTestProgressListener progress; + testresult.addListener (&progress); + + CppUnit::TestRunner testrunner; + testrunner.addTest (CppUnit::TestFactoryRegistry::getRegistry ().makeTest ()); + testrunner.run (testresult); + + CppUnit::CompilerOutputter compileroutputter (&collectedresults, std::cerr); + compileroutputter.write (); + + return collectedresults.wasSuccessful () ? 0 : 1; +} diff --git a/libs/temporal/wscript b/libs/temporal/wscript index 46c374ed80..351e42ea0b 100644 --- a/libs/temporal/wscript +++ b/libs/temporal/wscript @@ -63,5 +63,48 @@ def build(bld): obj.uselib = [ 'GLIBMM', 'XML', 'OSX' ] obj.use = [ 'libpbd' ] + if bld.env['BUILD_TESTS'] and bld.is_defined('HAVE_CPPUNIT'): + # Static library (for unit test code coverage) + obj = bld(features = 'cxx cstlib') + obj.source = temporal_sources + obj.export_includes = ['.'] + obj.includes = ['.'] + obj.name = 'libtemporal_static' + obj.target = 'temporal_static' + obj.uselib = 'GLIBMM GTHREAD XML LIBPBD' + obj.use = 'libpbd' + obj.vnum = TEMPORAL_VERSION + obj.install_path = '' + if bld.env['TEST_COVERAGE']: + obj.linkflags = ['--coverage'] + obj.cflags = ['--coverage'] + obj.cxxflags = ['--coverage'] + obj.defines = ['PACKAGE="libevoral"'] + + # Unit tests + obj = bld(features = 'cxx cxxprogram') + obj.source = ''' + test/beats.cc + test/testrunner.cc + ''' + obj.includes = ['.'] + obj.use = 'libtemporal_static' + obj.uselib = 'GLIBMM GTHREAD XML LIBPBD CPPUNIT' + obj.target = 'run-tests' + obj.name = 'libtemporal-tests' + obj.install_path = '' + obj.defines = ['PACKAGE="libtemporaltest"'] + if bld.env['TEST_COVERAGE']: + obj.linkflags = ['--coverage'] + obj.cflags = ['--coverage'] + obj.cxxflags = ['--coverage'] + +def test(ctx): + autowaf.pre_test(ctx, APPNAME) + print(os.getcwd()) + os.environ['EVORAL_TEST_PATH'] = os.path.abspath('../test/testdata/') + autowaf.run_tests(ctx, APPNAME, ['./run-tests']) + autowaf.post_test(ctx, APPNAME) + def shutdown(): autowaf.shutdown()