Do not depend on wvcdm::Clock in OEC tests

Merge from widevine repo of http://go/wvgerrit/14669

This fixes two timing-related test failures when running the OEMCrypto
tests in the CE test suite.  The failures were caused by the TestHost
Clock implementation, which is a fake.  Since there is no clear reason
for OEMCrypto/mock to rely on wvcdm::Clock, this replaces it with
time(NULL).  Incidentally, this also makes the time source consistent
with the tests themselves, which were already using time(NULL).

Change-Id: I0fad51f14d45f99526146da05b757d4ba7b6aba0
This commit is contained in:
Fred Gylys-Colwell
2015-06-29 18:17:15 -07:00
parent 54bb6ea3c8
commit 84efb88c28
2 changed files with 5 additions and 8 deletions

View File

@@ -5,6 +5,8 @@
#include "oemcrypto_usage_table_mock.h"
#include <string.h>
#include <time.h>
#include <string>
#include <vector>
@@ -13,7 +15,6 @@
#include <openssl/rand.h>
#include <openssl/sha.h>
#include "clock.h"
#include "file_store.h"
#include "log.h"
#include "oemcrypto_engine_mock.h"
@@ -24,12 +25,10 @@
namespace wvoec_mock {
wvcdm::Clock UsageTableEntry::clock_;
UsageTableEntry::UsageTableEntry(const std::vector<uint8_t> &pst_hash,
SessionContext *ctx)
: pst_hash_(pst_hash),
time_of_license_received_(clock_.GetCurrentTime()),
time_of_license_received_(time(NULL)),
time_of_first_decrypt_(0),
time_of_last_decrypt_(0),
status_(kUnused),
@@ -75,7 +74,7 @@ void UsageTableEntry::Deactivate() {
}
bool UsageTableEntry::UpdateTime() {
int64_t now = clock_.GetCurrentTime();
int64_t now = time(NULL);
switch (status_) {
case kUnused:
status_ = kActive;
@@ -104,7 +103,7 @@ OEMCryptoResult UsageTableEntry::ReportUsage(SessionContext *session,
LOGE("ReportUsage: buffer was null pointer.");
return OEMCrypto_ERROR_INVALID_CONTEXT;
}
int64_t now = clock_.GetCurrentTime();
int64_t now = time(NULL);
buffer->seconds_since_license_received =
wvcdm::htonll64(now - time_of_license_received_);
buffer->seconds_since_first_decrypt =

View File

@@ -10,7 +10,6 @@
#include <string>
#include <vector>
#include "clock.h"
#include "lock.h"
#include "OEMCryptoCENC.h"
#include "openssl/sha.h"
@@ -73,7 +72,6 @@ class UsageTableEntry {
std::vector<uint8_t> mac_key_client_;
SessionContext *session_;
static wvcdm::Clock clock_;
};
class UsageTable {