Version 17 plus test updates and OPK v17

This is the first public release of OPK v17.
See the file CHANGELOG.md for details.
This commit is contained in:
Fred Gylys-Colwell
2022-04-13 19:36:27 -07:00
parent 044a89ef55
commit 0a16cb2594
308 changed files with 58159 additions and 857 deletions

View File

@@ -13,7 +13,7 @@ namespace wvutil {
namespace {
// A fake clock that only advances when TestSleep::Sleep is called.
class FakeClock : public wvcdm::TestSleep::CallBack {
class FakeClock : public TestSleep::CallBack {
public:
FakeClock() {
auto now = std::chrono::system_clock().now();
@@ -34,7 +34,7 @@ FakeClock* g_fake_clock = nullptr;
// On devices running a fake OEMCrypto, we can use a fake sleep and fake time.
int64_t Clock::GetCurrentTime() {
wvcdm::TestSleep::SyncFakeClock();
TestSleep::SyncFakeClock();
if (g_fake_clock == nullptr) g_fake_clock = new FakeClock();
return g_fake_clock->now() / 1000;
}

View File

@@ -58,6 +58,21 @@ void TestSleep::SyncFakeClock() {
Sleep(0);
}
void TestSleep::SetFakeClock(int64_t time_seconds) {
if (real_sleep_) {
LOGE("SetFakeClock when using a real clock. Expect other failures.");
}
// Delta could be positive or negative. If the fake clock had been initialized
// by the current time on a real clock, and then the command line
// re-initializes it to 0, then delta is negative.
int64_t delta = time_seconds - Clock().GetCurrentTime();
if (callback_ != nullptr) {
callback_->ElapseTime(delta * 1000);
} else {
LOGE("Setting fake clock with no callback. This won't work.");
}
}
bool TestSleep::RollbackSystemTime(int seconds) {
if (real_sleep_) {
#ifdef _WIN32

View File

@@ -41,6 +41,10 @@ class TestSleep {
// verify this function does not roll back the clock used by OEMCrypto.
static bool RollbackSystemTime(int seconds);
// Set the system clock to the specified time. This is only expected to work
// when real_sleep is false.
static void SetFakeClock(int64_t time_seconds);
// Roll the system clock forward to undo all previous calls to
// RollBackSystemTime. Returns true on success.
static bool ResetRollback() {