Turn on ODK tests in CE CDM test and fix test helper
Merge from Widevine repo of http://go/wvgerrit/122223 This adds the ODK unit tests to the CE CDM tests so that they run as part of the presubmit tests. The test helper had some pointer problems converting a bool to a uint32, so it has been updated to handle this correctly. Some other tests failed comparing signed to unsigned, to these have also been fixed. test: ran odk_test bug: 118657876 Change-Id: I744a1e89f4e4729c31d3f53e729984ffac1d96fd
This commit is contained in:
@@ -86,10 +86,10 @@ void ODK_SetDefaultLicenseResponseParams(ODK_LicenseResponseParams* params) {
|
||||
".srm_restriction_data"},
|
||||
{ODK_UINT32, &(params->parsed_license.license_type), ".license_type"},
|
||||
{ODK_UINT32, &(params->parsed_license.nonce_required), ".nonce_required"},
|
||||
{ODK_UINT32,
|
||||
{ODK_BOOL,
|
||||
&(params->parsed_license.timer_limits.soft_enforce_rental_duration),
|
||||
".soft_enforce_rental_duration"},
|
||||
{ODK_UINT32,
|
||||
{ODK_BOOL,
|
||||
&(params->parsed_license.timer_limits.soft_enforce_playback_duration),
|
||||
".soft_enforce_playback_duration"},
|
||||
{ODK_UINT64,
|
||||
@@ -201,6 +201,8 @@ size_t ODK_FieldLength(ODK_FieldType type) {
|
||||
return sizeof(uint32_t);
|
||||
case ODK_UINT64:
|
||||
return sizeof(uint64_t);
|
||||
case ODK_BOOL: // Booleans are stored in the message as 32 bit ints.
|
||||
return sizeof(uint32_t);
|
||||
case ODK_SUBSTRING:
|
||||
return sizeof(uint32_t) + sizeof(uint32_t);
|
||||
case ODK_DEVICEID:
|
||||
@@ -242,6 +244,12 @@ OEMCryptoResult ODK_WriteSingleField(uint8_t* buf, const ODK_Field* field) {
|
||||
memcpy(buf, &u64, sizeof(u64));
|
||||
break;
|
||||
}
|
||||
case ODK_BOOL: {
|
||||
const bool value = *static_cast<bool*>(field->value);
|
||||
const uint32_t u32 = oemcrypto_htobe32(value ? 1 : 0);
|
||||
memcpy(buf, &u32, sizeof(u32));
|
||||
break;
|
||||
}
|
||||
case ODK_SUBSTRING: {
|
||||
OEMCrypto_Substring* s = static_cast<OEMCrypto_Substring*>(field->value);
|
||||
const uint32_t off = oemcrypto_htobe32(s->offset);
|
||||
@@ -288,6 +296,13 @@ OEMCryptoResult ODK_ReadSingleField(const uint8_t* buf,
|
||||
*u64p = oemcrypto_be64toh(*u64p);
|
||||
break;
|
||||
}
|
||||
case ODK_BOOL: {
|
||||
uint32_t value;
|
||||
memcpy(&value, buf, sizeof(uint32_t));
|
||||
value = oemcrypto_be32toh(value);
|
||||
*static_cast<bool*>(field->value) = (value != 0);
|
||||
break;
|
||||
}
|
||||
case ODK_SUBSTRING: {
|
||||
OEMCrypto_Substring* s = static_cast<OEMCrypto_Substring*>(field->value);
|
||||
uint32_t off = 0;
|
||||
@@ -325,6 +340,7 @@ OEMCryptoResult ODK_DumpSingleField(const uint8_t* buf,
|
||||
<< "\n";
|
||||
break;
|
||||
}
|
||||
case ODK_BOOL:
|
||||
case ODK_UINT32: {
|
||||
uint32_t val;
|
||||
memcpy(&val, buf, sizeof(uint32_t));
|
||||
|
||||
Reference in New Issue
Block a user