Add ability to start/stop test timer at specific points
This timer is expected to be global, so this would make paralellizing tests difficult. However, because the main target of this project (the GBA) does not support parallelization, this is not a concern at the moment.
This commit is contained in:
parent
8ea2cb9d49
commit
924ea41518
@ -39,6 +39,36 @@ public:
|
|||||||
m_test_names.push_back(name);
|
m_test_names.push_back(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void reset_timer() {
|
||||||
|
#ifdef __GBA__
|
||||||
|
REG_TM2D = UINT16_MAX;
|
||||||
|
// We must enable and disable the timer to write UINT16_MAX
|
||||||
|
// to the timer register
|
||||||
|
REG_TM2CNT = TM_ENABLE;
|
||||||
|
REG_TM2CNT &= ~TM_ENABLE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void start_timer() {
|
||||||
|
#ifdef __GBA__
|
||||||
|
REG_TM2D = 0;
|
||||||
|
REG_TM2CNT = TM_ENABLE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void end_timer() {
|
||||||
|
#ifdef __GBA__
|
||||||
|
REG_TM2CNT &= ~TM_ENABLE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint16_t query_timer() {
|
||||||
|
#ifdef __GBA__
|
||||||
|
return REG_TM2D;
|
||||||
|
#endif
|
||||||
|
return UINT16_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
static bool run_tests() {
|
static bool run_tests() {
|
||||||
log::info << "=========================" << endl;
|
log::info << "=========================" << endl;
|
||||||
log::info << "Running suite \"" << instance().name() << '\"' << endl;
|
log::info << "Running suite \"" << instance().name() << '\"' << endl;
|
||||||
@ -53,19 +83,10 @@ public:
|
|||||||
|
|
||||||
log::info << "Running \"" << name << "\"..." << endl;
|
log::info << "Running \"" << name << "\"..." << endl;
|
||||||
|
|
||||||
uint16_t time = 0;
|
reset_timer();
|
||||||
|
bool result = test();
|
||||||
|
|
||||||
#ifdef __GBA__
|
log::info << (result ? "OK" : "FAILED") << ", TIME: " << query_timer() << endl;
|
||||||
REG_TM2D = 0;
|
|
||||||
REG_TM2CNT = TM_ENABLE;
|
|
||||||
#endif
|
|
||||||
bool result = (test)();
|
|
||||||
#ifdef __GBA__
|
|
||||||
time = REG_TM2D;
|
|
||||||
REG_TM2CNT = ~TM_ENABLE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
log::info << (result ? "OK" : "FAILED") << ", TIME: " << time << endl;
|
|
||||||
|
|
||||||
if (result) { ++num_ok; }
|
if (result) { ++num_ok; }
|
||||||
else { ++num_fail; }
|
else { ++num_fail; }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user