Merge "Verify error code when usage entry in use" into rvc-dev am: 6bd68c9660 am: 6fd344812d am: 925db173aa am: aadd73c75a
Change-Id: I3a65fc11fe40febe8d007ee5980a5bdc5018df9b
This commit is contained in:
@@ -5724,19 +5724,29 @@ class OEMCryptoUsageTableDefragTest : public OEMCryptoUsageTableTest {
|
||||
|
||||
void ShrinkHeader(uint32_t new_size,
|
||||
OEMCryptoResult expected_result = OEMCrypto_SUCCESS) {
|
||||
// We call OEMCrypto_ShrinkUsageTableHeader once with a zero length buffer,
|
||||
// so that OEMCrypto can tell us how big the buffer should be.
|
||||
size_t header_buffer_length = 0;
|
||||
OEMCryptoResult sts = OEMCrypto_ShrinkUsageTableHeader(
|
||||
new_size, nullptr, &header_buffer_length);
|
||||
// If we are expecting success, then the first call shall return
|
||||
// SHORT_BUFFER. However, if we are not expecting success, this first call
|
||||
// may return either SHORT_BUFFER or the expect error.
|
||||
if (expected_result == OEMCrypto_SUCCESS) {
|
||||
ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, sts);
|
||||
} else {
|
||||
ASSERT_NE(OEMCrypto_SUCCESS, sts);
|
||||
if (sts != OEMCrypto_ERROR_SHORT_BUFFER) return;
|
||||
} else if (sts != OEMCrypto_ERROR_SHORT_BUFFER) {
|
||||
// If we got any thing from the first call, it should be the expected
|
||||
// error, and we don't need to call a second time.
|
||||
ASSERT_EQ(expected_result, sts);
|
||||
return;
|
||||
}
|
||||
// If the first call resulted in SHORT_BUFFER, we should resize the buffer
|
||||
// and try again.
|
||||
ASSERT_LT(0u, header_buffer_length);
|
||||
encrypted_usage_header_.resize(header_buffer_length);
|
||||
sts = OEMCrypto_ShrinkUsageTableHeader(
|
||||
new_size, encrypted_usage_header_.data(), &header_buffer_length);
|
||||
// For the second call, we always demand the expected result.
|
||||
ASSERT_EQ(expected_result, sts);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user