Require Features for Android OEMCrypto

Merge from Widevine repo if http://go/wvgerrit/13781

This CL adds several unit tests that are specifically designed to test
features that are required for Android CDM but not other platforms.

Once this CL has been merged, future CLs will modify the main
oemcrypto test file so that some tests are skipped if their features
are not implemented.

Change-Id: I55b8cbb9c13d2db88bd4f56bba31a4aab3306067
This commit is contained in:
Fred Gylys-Colwell
2015-03-30 11:12:31 -07:00
parent 2f86c447a4
commit 10cc0a5ddb
4 changed files with 120 additions and 12 deletions

View File

@@ -1076,7 +1076,7 @@ class Session {
void FillRefreshMessage(size_t key_count, uint32_t control_bits,
uint32_t nonce) {
for (unsigned int i = 0; i < kNumKeys; i++) {
for (unsigned int i = 0; i < key_count; i++) {
memset(encrypted_license_.keys[i].key_id, i, kTestKeyIdLength);
memcpy(encrypted_license_.keys[i].control.verification, "kctl", 4);
encrypted_license_.keys[i].control.duration = htonl(kLongDuration);
@@ -1605,8 +1605,8 @@ TEST_F(OEMCryptoClientTest, VersionNumber) {
cout << " OEMCrypto Security Level is " << level << endl;
uint32_t version = OEMCrypto_APIVersion();
cout << " OEMCrypto API version is " << version << endl;
ASSERT_LE(8, version);
ASSERT_GE(10, version);
ASSERT_LE(8u, version);
ASSERT_GE(10u, version);
}
TEST_F(OEMCryptoClientTest, NormalGetKeyData) {
@@ -1752,7 +1752,7 @@ TEST_F(OEMCryptoClientTest, MaxSessionsOpenClose) {
size_t sessions_count;
ASSERT_EQ(OEMCrypto_SUCCESS,
OEMCrypto_GetNumberOfOpenSessions(&sessions_count));
ASSERT_EQ(0, sessions_count);
ASSERT_EQ(0u, sessions_count);
size_t max_sessions;
ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_GetMaxNumberOfSessions(&max_sessions));
// We expect OEMCrypto implementations support at least 8 sessions.
@@ -1762,7 +1762,7 @@ TEST_F(OEMCryptoClientTest, MaxSessionsOpenClose) {
vector<OEMCrypto_SESSION> sessions;
// Limit the number of sessions for testing.
const size_t kMaxNumberOfSessionsForTesting = 0x100u;
for (int i = 0; i < kMaxNumberOfSessionsForTesting; i++) {
for (size_t i = 0; i < kMaxNumberOfSessionsForTesting; i++) {
OEMCrypto_SESSION session_id;
OEMCryptoResult sts = OEMCrypto_OpenSession(&session_id);
// GetMaxNumberOfSessions might be an estimate. We allow OEMCrypto to report
@@ -1780,7 +1780,7 @@ TEST_F(OEMCryptoClientTest, MaxSessionsOpenClose) {
ASSERT_EQ(i + 1, sessions_count);
sessions.push_back(session_id);
}
for (int i = 0; i < sessions.size(); i++) {
for (size_t i = 0; i < sessions.size(); i++) {
ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_CloseSession(sessions[i]));
ASSERT_EQ(OEMCrypto_SUCCESS,
OEMCrypto_GetNumberOfOpenSessions(&sessions_count));
@@ -4581,7 +4581,7 @@ TEST_F(OEMCryptoClientTest, PSTReportSizes) {
if (OEMCrypto_SupportsUsageTable()) {
OEMCrypto_PST_Report report;
uint8_t* location = reinterpret_cast<uint8_t*>(&report);
EXPECT_EQ(48, sizeof(report));
EXPECT_EQ(48u, sizeof(report));
uint8_t *field;
field = reinterpret_cast<uint8_t *>(&report.status);
EXPECT_EQ(20, field - location);
@@ -4762,7 +4762,7 @@ TEST_P(DISABLED_UsageTableTest, FiftyEntries) {
const size_t ENTRY_COUNT = 49;// API says should hold at least 50 entries.
Session sessions[ENTRY_COUNT];
for (int i=0; i<ENTRY_COUNT; i++) {
for (size_t i=0; i < ENTRY_COUNT; i++) {
sessions[i].open();
sessions[i].GenerateDerivedKeys();
std::string pst = "pst ";
@@ -4776,7 +4776,7 @@ TEST_P(DISABLED_UsageTableTest, FiftyEntries) {
sessions[i].GenerateReport(pst);
sessions[i].close();
}
for (int i=0; i<ENTRY_COUNT; i++) {
for (size_t i=0; i<ENTRY_COUNT; i++) {
Session s;
s.open();
std::string pst = "pst ";
@@ -4789,7 +4789,7 @@ TEST_P(DISABLED_UsageTableTest, FiftyEntries) {
sleep(kShortSleep);
// If I add too many entries, it can delete the older ones first, except
// it shouldn't delete the one attached to an open session. (s1)
for (int i=0; i<ENTRY_COUNT; i++) {
for (size_t i=0; i < ENTRY_COUNT; i++) {
sessions[i].open();
sessions[i].GenerateDerivedKeys();
std::string pst = "newer pst ";