Source release 16.4.0

This commit is contained in:
John W. Bruce
2020-10-09 16:08:56 -07:00
parent 160df9f57a
commit 9d17a531ee
562 changed files with 52913 additions and 37426 deletions

View File

@@ -45,6 +45,8 @@ const int kRenewalTestDelayMs = 3 * 60 * 1000;
const int kExpirationTestDelayMs = 5 * 60 * 1000;
const int kOfflineLicenseDurationMs = 604800 * 1000;
constexpr size_t kMaxFetchAttempts = 5;
const std::string kDeviceCertFileName = "cert.bin";
const Cdm::SessionType kBogusSessionType = static_cast<Cdm::SessionType>(-1);
@@ -243,19 +245,26 @@ class CdmTest : public WvCdmTestBase, public Cdm::IEventListener {
bool Fetch(const std::string& url, const std::string& message,
std::string* response, int* status_code) {
UrlRequest url_request(url);
EXPECT_TRUE(url_request.is_connected());
if (!url_request.is_connected()) {
return false;
}
url_request.PostRequest(message);
std::string http_response;
url_request.GetResponse(&http_response);
for (size_t attempt = 1; attempt <= kMaxFetchAttempts; ++attempt) {
UrlRequest url_request(url);
if (!url_request.is_connected()) {
sleep(1);
continue;
}
url_request.PostRequest(message);
if (!url_request.GetResponse(&http_response)) {
sleep(1);
continue;
}
break;
}
// Some license servers return 400 for invalid message, some
// return 500; treat anything other than 200 as an invalid message.
int http_status_code = url_request.GetStatusCode(http_response);
int http_status_code = UrlRequest::GetStatusCode(http_response);
if (status_code) {
*status_code = http_status_code;
}
@@ -310,11 +319,20 @@ class CdmTest : public WvCdmTestBase, public Cdm::IEventListener {
void FetchLicense(const std::string& license_server,
const std::string& message, std::string* response) {
int status_code;
bool ok = Fetch(license_server, message, response, &status_code);
const bool ok = Fetch(license_server, message, response, &status_code);
ASSERT_TRUE(ok);
if (ok)
if (!ok) return;
if (kHttpOk != status_code) {
std::map<std::string, std::string> fields;
if (UrlRequest::GetDebugHeaderFields(*response, &fields)) {
LOGD("Unexpected status code: code = %d", status_code);
for (auto field : fields) {
LOGD("- %s: %s", field.first.c_str(), field.second.c_str());
}
}
ASSERT_EQ(kHttpOk, status_code) << "Error response: " << *response << "\n"
<< "license_server: " << license_server;
}
}
void FetchLicenseFailure(const std::string& message,
@@ -682,7 +700,7 @@ TEST_F(CdmTest, ServiceCertificateRequestResponseUat) {
std::string response;
ASSERT_TRUE(FetchServiceCertificate(uat_config.license_server(), &response));
LOGV("response size=%d", response.size());
LOGV("Response size = %zu", response.size());
#if 0 // enable to extract the service certificate in byte form
size_t done = 0;
while (done < response.size()) {
@@ -705,7 +723,7 @@ TEST_F(CdmTest, ServiceCertificateRequestResponseStaging) {
std::string response;
ASSERT_TRUE(
FetchServiceCertificate(staging_config.license_server(), &response));
LOGV("response size=%d", response.size());
LOGV("Response: size = %zu", response.size());
#if 0 // enable to extract the service certificate in byte form
size_t done = 0;
while (done < response.size()) {
@@ -789,21 +807,21 @@ TEST_F(CdmTest, OpenSessionWithoutServiceCertificate) {
TEST_F(CdmTest, GetRobustnessLevel) {
Cdm::RobustnessLevel level;
Cdm::Status status = cdm_->getRobustnessLevel(&level);
const Cdm::Status status = cdm_->getRobustnessLevel(&level);
ASSERT_EQ(Cdm::kSuccess, status);
LOGI("Got robustness level %d", level);
LOGI("Got robustness level %d", static_cast<int>(level));
}
TEST_F(CdmTest, GetResourceRatingTier) {
uint32_t tier;
Cdm::Status status = cdm_->getResourceRatingTier(&tier);
const Cdm::Status status = cdm_->getResourceRatingTier(&tier);
ASSERT_EQ(Cdm::kSuccess, status);
LOGI("Got resource rating tier %lu", tier);
LOGI("Got resource rating tier %u", tier);
}
TEST_F(CdmTest, GetOemCryptoBuildInfo) {
std::string build_info;
Cdm::Status status = cdm_->getOemCryptoBuildInfo(&build_info);
const Cdm::Status status = cdm_->getOemCryptoBuildInfo(&build_info);
ASSERT_EQ(Cdm::kSuccess, status);
LOGI("Got OEMCrypto build info: %s", build_info.c_str());
}

View File

@@ -40,22 +40,28 @@ void TestHost::Reset() {
}
void TestHost::ElapseTime(int64_t milliseconds) {
// Note that, during the time rollback tests, milliseconds will be negative,
// so we cannot assume goal_time > now_.
int64_t goal_time = now_ + milliseconds;
while (now_ < goal_time) {
if (timers_.empty()) {
now_ = goal_time;
// Walk forward from now_ to goal_time, stepping at each timer along the way
// to fire its callback.
while (!timers_.empty() && now_ < goal_time) {
Timer t = timers_.top();
ASSERT_GE(t.expiry_time(), now_);
if (t.expiry_time() <= goal_time) {
timers_.pop();
now_ = t.expiry_time();
t.client()->onTimerExpired(t.context());
} else {
Timer t = timers_.top();
ASSERT_GE(t.expiry_time(), now_);
if (t.expiry_time() <= goal_time) {
timers_.pop();
now_ = t.expiry_time();
t.client()->onTimerExpired(t.context());
} else {
now_ = goal_time;
}
// The next timer is further in the future than goal_time, so we are done
// processing the timers.
break;
}
}
// No matter what happened with the timers, update now_ to the goal_time.
now_ = goal_time;
}
int TestHost::NumTimers() const { return timers_.size(); }