13
0
livetrax/libs/temporal/test/testrunner.cc
Mads Kiilerich 91314b68a5 temporal: always use Temporal::reset() for superclock and TempoMap default values
Make sure all code paths that use Temporal will initialize and reset it
properly. Some code paths (in tet runners) doesn't use Sessions, so
Temporal::reset() has to be invoked directly.

Just set the static superclock variable to 0 as initial value.
TempoMap will still be initialized early as a singleton, but we
introduce a new constructor so it is created empty (and thus not really
usable until Temporal::reset() or similar has populated it).

We can thus drop the static initialization of superclock. The default
superclock rate of 282240000 will now only live in Temporal::reset().

With this change there should no longer be any uninitialized use of
superclock_ticks_per_second(), and there should not be any problems for
DEBUG_EARLY_SCTS_USE to catch. (It is however broken in other ways -
that will be fixed next.)
2023-09-20 12:30:53 -06:00

73 lines
1.5 KiB
C++

#include <getopt.h>
#include <glibmm/thread.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <cppunit/BriefTestProgressListener.h>
#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 ();
Temporal::reset();
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;
}