From 18f9284d88adfaf74dc979c02f74e4d68d578cf2 Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Wed, 4 Aug 2021 21:58:08 +0000 Subject: [PATCH] Remove asserts from GenerateSimpleSampleDescription() GenerateSimpleSampleDescription() only had asserts to check parameters that only came from other test code, so they weren't testing anything of use. With the asserts removed, it's no longer necessary to wrap calls to GenerateSimpleSampleDescription() with ASSERT_NO_FATAL_FAILURE(), which a lot of callers were already forgetting to do anyway. This also simplifies a future patch that will generalize the decryption test code to work with entitlement licenses. Bug: 186782279 --- oemcrypto/test/oec_session_util.cpp | 8 ++------ oemcrypto/test/oemcrypto_test.cpp | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/oemcrypto/test/oec_session_util.cpp b/oemcrypto/test/oec_session_util.cpp index 243c798..88c6787 100644 --- a/oemcrypto/test/oec_session_util.cpp +++ b/oemcrypto/test/oec_session_util.cpp @@ -70,9 +70,6 @@ void GenerateSimpleSampleDescription( const std::vector& in, std::vector& out, OEMCrypto_SampleDescription* sample, OEMCrypto_SubSampleDescription* subsample) { - ASSERT_NE(sample, nullptr); - ASSERT_NE(subsample, nullptr); - // Generate test data EXPECT_EQ(GetRandBytes(&sample->iv[0], KEY_IV_SIZE), 1); @@ -1338,9 +1335,8 @@ void Session::TestDecryptCTR(bool select_key_first, OEMCrypto_SampleDescription sample_description; OEMCrypto_SubSampleDescription subsample_description; - ASSERT_NO_FATAL_FAILURE(GenerateSimpleSampleDescription( - encrypted_data, output_buffer, &sample_description, - &subsample_description)); + GenerateSimpleSampleDescription(encrypted_data, output_buffer, + &sample_description, &subsample_description); // Generate test data EXPECT_EQ(GetRandBytes(unencrypted_data.data(), unencrypted_data.size()), 1); diff --git a/oemcrypto/test/oemcrypto_test.cpp b/oemcrypto/test/oemcrypto_test.cpp index aea69c9..7a2b5af 100644 --- a/oemcrypto/test/oemcrypto_test.cpp +++ b/oemcrypto/test/oemcrypto_test.cpp @@ -2513,8 +2513,8 @@ TEST_P(OEMCryptoLicenseTest, SelectKeyNotThereAPI16) { OEMCrypto_SampleDescription sample_description; OEMCrypto_SubSampleDescription subsample_description; - ASSERT_NO_FATAL_FAILURE(GenerateSimpleSampleDescription( - in_buffer, out_buffer, &sample_description, &subsample_description)); + GenerateSimpleSampleDescription(in_buffer, out_buffer, &sample_description, + &subsample_description); // Generate test data for (size_t i = 0; i < in_buffer.size(); i++) in_buffer[i] = i % 256; @@ -2548,8 +2548,8 @@ TEST_P(OEMCryptoLicenseTest, RejectCensAPI16) { OEMCrypto_SampleDescription sample_description; OEMCrypto_SubSampleDescription subsample_description; - ASSERT_NO_FATAL_FAILURE(GenerateSimpleSampleDescription( - in_buffer, out_buffer, &sample_description, &subsample_description)); + GenerateSimpleSampleDescription(in_buffer, out_buffer, &sample_description, + &subsample_description); // Create a non-zero pattern to indicate this is 'cens' OEMCrypto_CENCEncryptPatternDesc pattern = {1, 9}; @@ -2579,8 +2579,8 @@ TEST_P(OEMCryptoLicenseTest, RejectCbc1API16) { OEMCrypto_SampleDescription sample_description; OEMCrypto_SubSampleDescription subsample_description; - ASSERT_NO_FATAL_FAILURE(GenerateSimpleSampleDescription( - in_buffer, out_buffer, &sample_description, &subsample_description)); + GenerateSimpleSampleDescription(in_buffer, out_buffer, &sample_description, + &subsample_description); // Create a zero pattern to indicate this is 'cbc1' OEMCrypto_CENCEncryptPatternDesc pattern = {0, 0}; @@ -2609,8 +2609,8 @@ TEST_P(OEMCryptoLicenseTest, RejectCbcsWithBlockOffset) { OEMCrypto_SampleDescription sample_description; OEMCrypto_SubSampleDescription subsample_description; - ASSERT_NO_FATAL_FAILURE(GenerateSimpleSampleDescription( - in_buffer, out_buffer, &sample_description, &subsample_description)); + GenerateSimpleSampleDescription(in_buffer, out_buffer, &sample_description, + &subsample_description); subsample_description.block_offset = 5; // Any value 1-15 will do. // Create a non-zero pattern to indicate this is 'cbcs'. @@ -2640,8 +2640,8 @@ TEST_P(OEMCryptoLicenseTest, RejectOversizedBlockOffset) { OEMCrypto_SampleDescription sample_description; OEMCrypto_SubSampleDescription subsample_description; - ASSERT_NO_FATAL_FAILURE(GenerateSimpleSampleDescription( - in_buffer, out_buffer, &sample_description, &subsample_description)); + GenerateSimpleSampleDescription(in_buffer, out_buffer, &sample_description, + &subsample_description); subsample_description.block_offset = 0xFF; // Anything 16+ // Create a zero pattern to indicate this is 'cenc'.