Reduce clock skew in flaky duration tests
There are three changes here that should help reduce the amount of duration test failures caused by clock skew. First, we reported some skew when the test expected playback to start immediately after loading the license. However, with round-off, this could easily be more than 1 second. So this does not warrent even a warning. Second, the fake and real clocks were only synced after computing how long to sleep. This is fixed by moving SleepUntil to the TestSleep class and having it sync before computing the delta and after doing the sleep. Third, I am guessing that some failures due to unexpected lenience were caused by the rental or playback clock being started at the end of signing the license or the end of the first decrypt instead of the beginning. We work around this by recording how long these operations take, and then adding this extra time at the end of the check for FailDecrypt. Bug: 275003529 Bug: 279249646 Bug: 207500749 Merged from https://widevine-internal-review.googlesource.com/176070 Change-Id: I6a973565edfbebca53ee7f239b4b93f8f73d1e0a
This commit is contained in:
committed by
Robert Shih
parent
0cd3d185c7
commit
b7b423aca3
@@ -13,7 +13,9 @@ namespace wvutil {
|
||||
|
||||
class TestSleep {
|
||||
public:
|
||||
// The callback is called when the clock should be advanced.
|
||||
// The callback is called when the test clock should be advanced. If the
|
||||
// system uses a real clock, it is used to sync the real and test
|
||||
// clock. Otherwise it is used to simulate sleep in the test clock.
|
||||
class CallBack {
|
||||
public:
|
||||
virtual void ElapseTime(int64_t milliseconds) = 0;
|
||||
@@ -27,6 +29,9 @@ class TestSleep {
|
||||
// callback exists, this calls the callback.
|
||||
static void Sleep(unsigned int seconds);
|
||||
|
||||
// Like sleep, above, except it sleeps until the specified time.
|
||||
static void SleepUntil(int64_t desired_time);
|
||||
|
||||
// If we are using a real clock and a fake clock, then the real clock advances
|
||||
// a little while we are doing work, but the fake one only advances when we
|
||||
// sleep. This function advances the fake clock to be in sync with the real
|
||||
|
||||
Reference in New Issue
Block a user