Use different time call in TimeRollbackPrevention test
Merge from widevine of http://go/wvgerrit/48885 iOS prohibits using clock_settime. In order to make the test consistent, we set time using settimeofday instead. Test: tested as part of http://go/ag/4674759 Change-Id: I8812b9b099fa8160591fafece070c34afeed82fa
This commit is contained in:
@@ -5811,9 +5811,10 @@ TEST_F(UsageTableTest, TimeRollbackPrevention) {
|
||||
|
||||
ASSERT_EQ(0, clock_gettime(CLOCK_REALTIME, ¤t_time));
|
||||
// Rollback the wall clock time.
|
||||
current_time.tv_sec -= kLongDuration * 10;
|
||||
cout << "Rolling the system time back..." << endl;
|
||||
ASSERT_EQ(0, clock_settime(CLOCK_REALTIME, ¤t_time));
|
||||
timeval current_time_of_day = {};
|
||||
current_time_of_day.tv_sec = current_time.tv_sec - kLongDuration * 10;
|
||||
ASSERT_EQ(0, settimeofday(¤t_time_of_day, NULL));
|
||||
|
||||
// Try to playback again.
|
||||
ASSERT_NO_FATAL_FAILURE(s1.open());
|
||||
@@ -5830,14 +5831,13 @@ TEST_F(UsageTableTest, TimeRollbackPrevention) {
|
||||
// Restore wall clock to its original position to verify that OEMCrypto does
|
||||
// not report negative times.
|
||||
ASSERT_EQ(0, clock_gettime(CLOCK_MONOTONIC, ¤t_time));
|
||||
current_time.tv_sec =
|
||||
current_time_of_day.tv_sec =
|
||||
first_decrypt + current_time.tv_sec - first_decrypt_monotonic;
|
||||
cout << "Rolling the system time forward to the absolute time..." << endl;
|
||||
ASSERT_EQ(0, clock_settime(CLOCK_REALTIME, ¤t_time));
|
||||
|
||||
ASSERT_EQ(0, settimeofday(¤t_time_of_day, NULL));
|
||||
// Need to update time created since the verification checks the time of PST
|
||||
// report creation.
|
||||
expected.time_created = current_time.tv_sec;
|
||||
expected.time_created = current_time_of_day.tv_sec;
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
s1.VerifyReport(expected, loaded, first_decrypt,
|
||||
|
||||
Reference in New Issue
Block a user