From d7ee89bab0ce0fdeb3ad5fba0ea724651cd6de40 Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Mon, 27 Mar 2023 19:41:38 -0700 Subject: [PATCH] Filter Cast Reciver tests Merge from Widevine repo of http://go/wvgerrit/169070 This turns on the cast receiver tests for any device that claims to support this feature. Previously, we had to explicitly request these tests on the command line. But since they do not pass for Prov 4.0, we fitler them out in this case and reference a bug tracking that work. We also switch to using GTEST_SKIP to skip the tests instead of modifying the GTEST_FILTER. Bug: 251240681 Bug: 269310676 Bug: 259455058 Bug: 259454969 Merged from https://widevine-internal-review.googlesource.com/166497 Change-Id: I1bcd749243a474b3f638547aa43c2805e86731af --- libwvdrmengine/cdm/core/test/test_base.cpp | 8 +++++++- libwvdrmengine/oemcrypto/test/oec_device_features.cpp | 2 -- libwvdrmengine/oemcrypto/test/oemcrypto_security_test.cpp | 2 ++ libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp | 7 +++++++ libwvdrmengine/oemcrypto/test/oemcrypto_test_main.cpp | 8 +++++++- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/libwvdrmengine/cdm/core/test/test_base.cpp b/libwvdrmengine/cdm/core/test/test_base.cpp index 192d87ff..4d3365e6 100644 --- a/libwvdrmengine/cdm/core/test/test_base.cpp +++ b/libwvdrmengine/cdm/core/test/test_base.cpp @@ -677,7 +677,13 @@ bool WvCdmTestBase::Initialize(int argc, const char* const argv[], // Figure out which tests are appropriate for OEMCrypto, based on features // supported. wvoec::global_features.Initialize(); - wvoec::global_features.set_cast_receiver(is_cast_receiver); + if (is_cast_receiver) { + // Turn it on if passed in on the command line. Do not turn these tests off + // automtically -- instead, we'll let the caller filter them out if they + // need to. These tests will normally only run if the device claims to + // support being a cast receiver. + wvoec::global_features.set_cast_receiver(is_cast_receiver); + } // If the user requests --no_filter, we don't change the filter, otherwise, we // filter out features that are not supported. if (filter_tests) { diff --git a/libwvdrmengine/oemcrypto/test/oec_device_features.cpp b/libwvdrmengine/oemcrypto/test/oec_device_features.cpp index ca471a85..5084cc30 100644 --- a/libwvdrmengine/oemcrypto/test/oec_device_features.cpp +++ b/libwvdrmengine/oemcrypto/test/oec_device_features.cpp @@ -122,7 +122,6 @@ void DeviceFeatures::Initialize() { switch (derive_key_method) { case NO_METHOD: printf("NO_METHOD: Cannot derive known session keys.\n"); - // Note: cast_receiver left unchanged because set by user on command line. uses_keybox = false; loads_certificate = false; generic_crypto = false; @@ -161,7 +160,6 @@ std::string DeviceFeatures::RestrictFilter(const std::string& initial_filter) { provisioning_method == OEMCrypto_BootCertificateChain) FilterOut(&filter, "OEMCryptoLoadsCert*"); if (!generic_crypto) FilterOut(&filter, "*GenericCrypto*"); - if (!cast_receiver) FilterOut(&filter, "*CastReceiver*"); if (!supports_cas) FilterOut(&filter, "*CasOnly*"); if (derive_key_method == NO_METHOD) FilterOut(&filter, "*SessionTest*"); if (provisioning_method != OEMCrypto_BootCertificateChain) diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_security_test.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_security_test.cpp index 15be27f7..dc39198a 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_security_test.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_security_test.cpp @@ -772,6 +772,7 @@ TEST_F(OEMCryptoLoadsCertificateAlternates, ASSERT_TRUE(key_loaded_); } if (key_loaded_) { + // If the key did load, then it should be processed correctly. Session s; ASSERT_NO_FATAL_FAILURE(s.open()); ASSERT_NO_FATAL_FAILURE(s.LoadWrappedRsaDrmKey(wrapped_rsa_key_)); @@ -804,6 +805,7 @@ TEST_F(OEMCryptoLoadsCertificateAlternates, ASSERT_TRUE(key_loaded_); } if (key_loaded_) { + // If the key did load, then it should be processed correctly. Session s; ASSERT_NO_FATAL_FAILURE(s.open()); ASSERT_NO_FATAL_FAILURE(s.LoadWrappedRsaDrmKey(wrapped_rsa_key_)); diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp index c2a7a9f7..c8604f14 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp @@ -2310,6 +2310,13 @@ TEST_F(OEMCryptoLoadsCertificateAlternates, TestSignaturePKCS1) { // those devices. class OEMCryptoCastReceiverTest : public OEMCryptoLoadsCertificateAlternates { protected: + void SetUp() override { + OEMCryptoLoadsCertificateAlternates::SetUp(); + if (!global_features.cast_receiver) { + GTEST_SKIP() << "OEMCrypto does not support CAST Receiver functionality"; + } + } + vector encode(uint8_t type, const vector& substring) { vector result; result.push_back(type); diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_test_main.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_test_main.cpp index 8a702cf4..0779b11c 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_test_main.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_test_main.cpp @@ -46,7 +46,13 @@ int main(int argc, char** argv) { } wvutil::g_cutoff = static_cast(verbosity); wvoec::global_features.Initialize(); - wvoec::global_features.set_cast_receiver(is_cast_receiver); + if (is_cast_receiver) { + // Turn it on if passed in on the command line. Do not turn these tests off + // automtically -- instead, we'll let the caller filter them out if they + // need to. These tests will normally only run if the device claims to + // support being a cast receiver. + wvoec::global_features.set_cast_receiver(is_cast_receiver); + } // Init GTest after device properties has been initialized. ::testing::InitGoogleTest(&argc, argv); // If the user requests --no_filter, we don't change the filter, otherwise, we