mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 23:53:33 +08:00
Superrefactoring - all time values were replaced with new safer classes from uavcan/time.hpp; generated types were moved away from anonymous namespaces because this makes it impossible to use a type from different compilation units. Some less vital fixes are to follow - see the next few commits
This commit is contained in:
@@ -47,35 +47,35 @@ TEST(Scheduler, Timers)
|
||||
|
||||
ASSERT_EQ(0, sch.getMonotonicDeadlineScheduler().getNumHandlers());
|
||||
|
||||
const uint64_t start_ts = clock_driver.getMonotonicMicroseconds();
|
||||
const uavcan::MonotonicTime start_ts = clock_driver.getMonotonic();
|
||||
|
||||
a.startOneShotWithDeadline(start_ts + 100000);
|
||||
b.startPeriodic(1000);
|
||||
a.startOneShotWithDeadline(start_ts + durMono(100000));
|
||||
b.startPeriodic(durMono(1000));
|
||||
|
||||
ASSERT_EQ(2, sch.getMonotonicDeadlineScheduler().getNumHandlers());
|
||||
|
||||
/*
|
||||
* Spinning
|
||||
*/
|
||||
ASSERT_EQ(0, sch.spin(start_ts + 1000000));
|
||||
ASSERT_EQ(0, sch.spin(start_ts + durMono(1000000)));
|
||||
|
||||
ASSERT_EQ(1, tcc.events_a.size());
|
||||
ASSERT_TRUE(areTimestampsClose(tcc.events_a[0].scheduled_monotonic_deadline, start_ts + 100000));
|
||||
ASSERT_TRUE(areTimestampsClose(tcc.events_a[0].monotonic_timestamp,
|
||||
tcc.events_a[0].scheduled_monotonic_deadline));
|
||||
ASSERT_TRUE(areTimestampsClose(tcc.events_a[0].scheduled_deadline, start_ts + durMono(100000)));
|
||||
ASSERT_TRUE(areTimestampsClose(tcc.events_a[0].current_timestamp,
|
||||
tcc.events_a[0].scheduled_deadline));
|
||||
ASSERT_EQ(&a, tcc.events_a[0].timer);
|
||||
|
||||
ASSERT_LT(900, tcc.events_b.size());
|
||||
ASSERT_GT(1100, tcc.events_b.size());
|
||||
{
|
||||
uint64_t next_expected_deadline = start_ts + 1000;
|
||||
uavcan::MonotonicTime next_expected_deadline = start_ts + durMono(1000);
|
||||
for (unsigned int i = 0; i < tcc.events_b.size(); i++)
|
||||
{
|
||||
ASSERT_TRUE(areTimestampsClose(tcc.events_b[i].scheduled_monotonic_deadline, next_expected_deadline));
|
||||
ASSERT_TRUE(areTimestampsClose(tcc.events_b[i].monotonic_timestamp,
|
||||
tcc.events_b[i].scheduled_monotonic_deadline));
|
||||
ASSERT_TRUE(areTimestampsClose(tcc.events_b[i].scheduled_deadline, next_expected_deadline));
|
||||
ASSERT_TRUE(areTimestampsClose(tcc.events_b[i].current_timestamp,
|
||||
tcc.events_b[i].scheduled_deadline));
|
||||
ASSERT_EQ(&b, tcc.events_b[i].timer);
|
||||
next_expected_deadline += 1000;
|
||||
next_expected_deadline += durMono(1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,12 +85,12 @@ TEST(Scheduler, Timers)
|
||||
ASSERT_EQ(1, sch.getMonotonicDeadlineScheduler().getNumHandlers());
|
||||
|
||||
ASSERT_FALSE(a.isRunning());
|
||||
ASSERT_EQ(uavcan::Timer::InfinitePeriod, a.getPeriod());
|
||||
ASSERT_EQ(uavcan::MonotonicDuration::getInfinite(), a.getPeriod());
|
||||
|
||||
ASSERT_TRUE(b.isRunning());
|
||||
ASSERT_EQ(1000, b.getPeriod());
|
||||
ASSERT_EQ(1000, b.getPeriod().toUSec());
|
||||
}
|
||||
|
||||
ASSERT_EQ(0, sch.getMonotonicDeadlineScheduler().getNumHandlers()); // Both timers were destroyed now
|
||||
ASSERT_EQ(0, sch.spin(clock_driver.getMonotonicMicroseconds() + 1000)); // Spin some more without timers
|
||||
ASSERT_EQ(0, sch.getMonotonicDeadlineScheduler().getNumHandlers()); // Both timers were destroyed now
|
||||
ASSERT_EQ(0, sch.spin(clock_driver.getMonotonic() + durMono(1000))); // Spin some more without timers
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user