Use real system id in GetProvisioningTokenValidMetrics
Merge from Widevine repo of http://go/wvgerrit/42102 The unit test should use the real system id if it is using a real oemcrypto. test: ran unit tests on sailfish. bug: 72718962 Change-Id: Ib58a47976f85b840c6f34d379b1c020e7e85d59a
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <string>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
@@ -290,6 +291,17 @@ class CryptoSessionMetricsTest : public testing::Test {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t FindKeyboxSystemID() {
|
||||
OEMCryptoResult sts;
|
||||
uint8_t key_data[256];
|
||||
size_t key_data_len = sizeof(key_data);
|
||||
sts = OEMCrypto_GetKeyData(key_data, &key_data_len, kLevelDefault);
|
||||
if (sts != OEMCrypto_SUCCESS) return 0;
|
||||
uint32_t* data = reinterpret_cast<uint32_t*>(key_data);
|
||||
uint32_t system_id = htonl(data[1]);
|
||||
return system_id;
|
||||
}
|
||||
|
||||
private:
|
||||
static std::pair<std::string, drm_metrics::MetricsGroup::Metric>
|
||||
MakeMetricPair(const drm_metrics::MetricsGroup::Metric& metric) {
|
||||
@@ -337,9 +349,10 @@ TEST_F(CryptoSessionMetricsTest, OpenSessionValidMetrics) {
|
||||
CdmClientTokenType token_type = session.GetPreProvisionTokenType();
|
||||
|
||||
if (token_type == kClientTokenKeybox) {
|
||||
uint32_t system_id = FindKeyboxSystemID();
|
||||
EXPECT_TRUE(FindMetric(
|
||||
metric_map, "/drm/widevine/crypto_session/system_id", &metric));
|
||||
EXPECT_EQ(metric.value().int_value(), 4121);
|
||||
EXPECT_EQ(metric.value().int_value(), system_id);
|
||||
|
||||
EXPECT_TRUE(FindMetric(
|
||||
metric_map,
|
||||
@@ -363,7 +376,11 @@ TEST_F(CryptoSessionMetricsTest, OpenSessionValidMetrics) {
|
||||
} else if (token_type == kClientTokenOemCert) {
|
||||
EXPECT_TRUE(FindMetric(
|
||||
metric_map, "/drm/widevine/crypto_session/system_id", &metric));
|
||||
EXPECT_EQ(metric.value().int_value(), 7346);
|
||||
// Recent devices all have a system id between 1k and 6 or 7k. Errors we
|
||||
// are trying to catch are 0, byte swapped 32 bit numbers, or garbage. These
|
||||
// errors will most likely be outside the range of 1000 to 2^16.
|
||||
EXPECT_LE(1000, metric.value().int_value());
|
||||
EXPECT_GT(0x10000, metric.value().int_value());
|
||||
|
||||
EXPECT_TRUE(FindMetric(
|
||||
metric_map,
|
||||
@@ -417,7 +434,8 @@ TEST_F(CryptoSessionMetricsTest, GetProvisioningTokenValidMetrics) {
|
||||
EXPECT_TRUE(FindMetric(
|
||||
metric_map, "/drm/widevine/crypto_session/system_id",
|
||||
&metric));
|
||||
EXPECT_EQ(metric.value().int_value(), 4121);
|
||||
uint32_t system_id = FindKeyboxSystemID();
|
||||
EXPECT_EQ(metric.value().int_value(), system_id);
|
||||
EXPECT_TRUE(FindMetric(
|
||||
metric_map,
|
||||
"/drm/widevine/oemcrypto/get_key_data/time/count"
|
||||
@@ -433,7 +451,11 @@ TEST_F(CryptoSessionMetricsTest, GetProvisioningTokenValidMetrics) {
|
||||
EXPECT_TRUE(FindMetric(
|
||||
metric_map, "/drm/widevine/crypto_session/system_id",
|
||||
&metric));
|
||||
EXPECT_EQ(metric.value().int_value(), 7346);
|
||||
// Recent devices all have a system id between 1k and 6 or 7k. Errors we
|
||||
// are trying to catch are 0, byte swapped 32 bit numbers, or garbage. These
|
||||
// errors will most likely be outside the range of 1000 to 2^16.
|
||||
EXPECT_LE(1000, metric.value().int_value());
|
||||
EXPECT_GT(0x10000, metric.value().int_value());
|
||||
EXPECT_TRUE(FindMetric(
|
||||
metric_map,
|
||||
"/drm/widevine/oemcrypto/get_oem_public_certificate/count"
|
||||
|
||||
Reference in New Issue
Block a user