|
|
|
@ -6,6 +6,7 @@
|
|
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
|
#include <bitset>
|
|
|
|
|
#include <chrono>
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <string>
|
|
|
|
@ -17,7 +18,6 @@
|
|
|
|
|
namespace {
|
|
|
|
|
// Numbers are chosen randomly to make sure the correct one is given.
|
|
|
|
|
constexpr std::array<u64, 5> CB_IDS{{42, 144, 93, 1026, UINT64_C(0xFFFF7FFFF7FFFF)}};
|
|
|
|
|
constexpr int MAX_SLICE_LENGTH = 10000; // Copied from CoreTiming internals
|
|
|
|
|
constexpr std::array<u64, 5> calls_order{{2, 0, 1, 4, 3}};
|
|
|
|
|
std::array<s64, 5> delays{};
|
|
|
|
|
|
|
|
|
@ -25,12 +25,12 @@ std::bitset<CB_IDS.size()> callbacks_ran_flags;
|
|
|
|
|
u64 expected_callback = 0;
|
|
|
|
|
|
|
|
|
|
template <unsigned int IDX>
|
|
|
|
|
void HostCallbackTemplate(u64 userdata, s64 nanoseconds_late) {
|
|
|
|
|
void HostCallbackTemplate(u64 userdata, std::chrono::nanoseconds ns_late) {
|
|
|
|
|
static_assert(IDX < CB_IDS.size(), "IDX out of range");
|
|
|
|
|
callbacks_ran_flags.set(IDX);
|
|
|
|
|
REQUIRE(CB_IDS[IDX] == userdata);
|
|
|
|
|
REQUIRE(CB_IDS[IDX] == CB_IDS[calls_order[expected_callback]]);
|
|
|
|
|
delays[IDX] = nanoseconds_late;
|
|
|
|
|
delays[IDX] = ns_late.count();
|
|
|
|
|
++expected_callback;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -77,10 +77,12 @@ TEST_CASE("CoreTiming[BasicOrder]", "[core]") {
|
|
|
|
|
|
|
|
|
|
core_timing.SyncPause(true);
|
|
|
|
|
|
|
|
|
|
u64 one_micro = 1000U;
|
|
|
|
|
const u64 one_micro = 1000U;
|
|
|
|
|
for (std::size_t i = 0; i < events.size(); i++) {
|
|
|
|
|
u64 order = calls_order[i];
|
|
|
|
|
core_timing.ScheduleEvent(i * one_micro + 100U, events[order], CB_IDS[order]);
|
|
|
|
|
const u64 order = calls_order[i];
|
|
|
|
|
const auto future_ns = std::chrono::nanoseconds{static_cast<s64>(i * one_micro + 100)};
|
|
|
|
|
|
|
|
|
|
core_timing.ScheduleEvent(future_ns, events[order], CB_IDS[order]);
|
|
|
|
|
}
|
|
|
|
|
/// test pause
|
|
|
|
|
REQUIRE(callbacks_ran_flags.none());
|
|
|
|
|