From fe0ddc8098b29c1e0436af828e5126e00eeac06d Mon Sep 17 00:00:00 2001 From: Vicky Min Date: Mon, 28 Aug 2023 18:05:47 +0000 Subject: [PATCH] Filter keybox tests with GTEST_SKIP (merged from go/wvgerrit/183630) Bug: 288404945, 251240681 Test: keybox tests Change-Id: I38ed2ba54c9f756693902fd7d0044d4e42bbc2fd --- libwvdrmengine/cdm/core/test/keybox_ota_test.cpp | 5 +++++ libwvdrmengine/oemcrypto/test/oec_device_features.cpp | 1 - .../oemcrypto/test/oemcrypto_license_test.cpp | 5 ++++- .../oemcrypto/test/oemcrypto_provisioning_test.cpp | 8 +++++++- .../oemcrypto/test/oemcrypto_provisioning_test.h | 5 ++++- .../oemcrypto/test/oemcrypto_test_android.cpp | 11 +++++++++++ 6 files changed, 31 insertions(+), 4 deletions(-) diff --git a/libwvdrmengine/cdm/core/test/keybox_ota_test.cpp b/libwvdrmengine/cdm/core/test/keybox_ota_test.cpp index fc5a2df9..910d9c94 100644 --- a/libwvdrmengine/cdm/core/test/keybox_ota_test.cpp +++ b/libwvdrmengine/cdm/core/test/keybox_ota_test.cpp @@ -3,12 +3,14 @@ // License Agreement. #include + #include #include #include #include "create_test_file_system.h" #include "crypto_session.h" +#include "oec_device_features.h" #include "properties.h" #include "provisioning_holder.h" #include "test_base.h" @@ -24,6 +26,9 @@ class CdmOtaKeyboxTest : public ::testing::Test { void SetUp() override { ::testing::Test::SetUp(); Properties::Init(); + if (wvoec::global_features.provisioning_method != OEMCrypto_Keybox) { + GTEST_SKIP() << "Test for Prov 2.0 devices only."; + } const ::testing::TestInfo* const test_info = ::testing::UnitTest::GetInstance()->current_test_info(); LOGD("Running test %s.%s", test_info->test_case_name(), test_info->name()); diff --git a/libwvdrmengine/oemcrypto/test/oec_device_features.cpp b/libwvdrmengine/oemcrypto/test/oec_device_features.cpp index 22640539..2ad9c4f6 100644 --- a/libwvdrmengine/oemcrypto/test/oec_device_features.cpp +++ b/libwvdrmengine/oemcrypto/test/oec_device_features.cpp @@ -148,7 +148,6 @@ void DeviceFeatures::Initialize() { std::string DeviceFeatures::RestrictFilter(const std::string& initial_filter) { std::string filter = initial_filter; // clang-format off - if (!uses_keybox) FilterOut(&filter, "*KeyboxTest*"); // TODO(b/197141970): Need to revisit OEMCryptoLoadsCert* tests for // provisioning 4. Disabled here temporarily. if (!loads_certificate || diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_license_test.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_license_test.cpp index fedd8f9b..1a3d2ee6 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_license_test.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_license_test.cpp @@ -85,6 +85,9 @@ void TestMaxKeys(SessionUtil* util, size_t num_keys_per_session) { } TEST_F(OEMCryptoSessionTestKeyboxTest, TestKeyboxIsValid) { + if (global_features.provisioning_method != OEMCrypto_Keybox) { + GTEST_SKIP() << "Test for Prov 2.0 devices only."; + } ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_IsKeyboxValid()); } @@ -967,4 +970,4 @@ INSTANTIATE_TEST_SUITE_P(TestAPI16, OEMCryptoRefreshTestAPI16, Range(kCoreMessagesAPI, kCurrentAPI + 1)); /// @} -} // namespace wvoec \ No newline at end of file +} // namespace wvoec diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_provisioning_test.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_provisioning_test.cpp index 5504e768..965b2b38 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_provisioning_test.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_provisioning_test.cpp @@ -825,6 +825,9 @@ TEST_F(OEMCryptoLoadsCertificate, CertificateProvisionBadRange5Prov30_API16) { // TODO(b/144186970): This test should also run on Prov 3.0 devices. TEST_F(OEMCryptoLoadsCertificate, CertificateProvisionBadSignatureKeyboxTestAPI16) { + if (global_features.provisioning_method != OEMCrypto_Keybox) { + GTEST_SKIP() << "Test for Prov 2.0 devices only."; + } Session s; ProvisioningRoundTrip provisioning_messages(&s, encoded_rsa_key_); provisioning_messages.PrepareSession(keybox_); @@ -868,6 +871,9 @@ TEST_F(OEMCryptoLoadsCertificate, CertificateProvisionBadRSAKey) { // TODO(b/144186970): This test should also run on Prov 3.0 devices. TEST_F(OEMCryptoLoadsCertificate, CertificateProvisionBadRSAKeyKeyboxTestAPI16) { + if (global_features.provisioning_method != OEMCrypto_Keybox) { + GTEST_SKIP() << "Test for Prov 2.0 devices only."; + } Session s; ProvisioningRoundTrip provisioning_messages(&s, encoded_rsa_key_); provisioning_messages.PrepareSession(keybox_); @@ -1225,4 +1231,4 @@ TEST_F(OEMCryptoUsesCertificate, GenerateDerivedKeysLargeBuffer) { enc_context.data(), enc_context.size())); } -} // namespace wvoec \ No newline at end of file +} // namespace wvoec diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_provisioning_test.h b/libwvdrmengine/oemcrypto/test/oemcrypto_provisioning_test.h index b44369c5..dccfb572 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_provisioning_test.h +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_provisioning_test.h @@ -23,6 +23,9 @@ class OEMCryptoKeyboxTest : public OEMCryptoClientTest { void SetUp() override { OEMCryptoClientTest::SetUp(); OEMCryptoResult sts = OEMCrypto_IsKeyboxValid(); + if (global_features.provisioning_method != OEMCrypto_Keybox) { + GTEST_SKIP() << "Test for Prov 2.0 devices only."; + } // If the production keybox is valid, use it for these tests. Most of the // other tests will use a test keybox anyway, but it's nice to check the // device ID for the real keybox if we can. @@ -166,4 +169,4 @@ class OEMCryptoUsesCertificate : public OEMCryptoLoadsCertificate { } // namespace wvoec -#endif // CDM_OEMCRYPTO_PROVISIONING_TEST_ \ No newline at end of file +#endif // CDM_OEMCRYPTO_PROVISIONING_TEST_ diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_test_android.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_test_android.cpp index f0597ac2..1b58771a 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_test_android.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_test_android.cpp @@ -39,6 +39,10 @@ class OEMCryptoAndroidLMPTest : public ::testing::Test { // Android devices must have a keybox, or use provisioning 3.0. TEST_F(OEMCryptoAndroidLMPTest, GetKeyDataImplemented) { + if (global_features.provisioning_method != OEMCrypto_Keybox && + global_features.provisioning_method != OEMCrypto_OEMCertificate) { + GTEST_SKIP() << "Test for Prov 2.0 and 3.0 devices only."; + } uint8_t key_data[256]; size_t key_data_len = sizeof(key_data); if (OEMCrypto_Keybox == OEMCrypto_GetProvisioningMethod()) { @@ -62,6 +66,9 @@ TEST_F(OEMCryptoAndroidLMPTest, MinVersionNumber9) { } TEST_F(OEMCryptoAndroidLMPTest, ValidKeyboxTest) { + if (global_features.provisioning_method != OEMCrypto_Keybox) { + GTEST_SKIP() << "Test for Prov 2.0 devices only."; + } ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_IsKeyboxValid()); } @@ -115,6 +122,10 @@ TEST_F(OEMCryptoAndroidMNCTest, MinVersionNumber10) { // Android devices using Provisioning 2.0 must be able to load a test keybox. // If they are not using Provisioning 2.0, then they must use Provisioning 3.0. TEST_F(OEMCryptoAndroidMNCTest, LoadsTestKeyboxImplemented) { + if (global_features.provisioning_method != OEMCrypto_Keybox && + global_features.provisioning_method != OEMCrypto_OEMCertificate) { + GTEST_SKIP() << "Test for Prov 2.0 and 3.0 devices only."; + } if (OEMCrypto_Keybox == OEMCrypto_GetProvisioningMethod()) { ASSERT_EQ( OEMCrypto_SUCCESS,