From 094fabed5a5f42f60714cad05a0390d551fc9a30 Mon Sep 17 00:00:00 2001 From: Rahul Frias Date: Tue, 9 Mar 2021 13:27:22 -0800 Subject: [PATCH 1/2] Address compilation warnings [ Merge of http://go/wvgerrit/119523 ] Bug: 182299187 Test: compile vendor/widevine/libwvdrmengine Change-Id: I39d1b62a3237bfb9163a7e157b871f22e3fec394 --- .../cdm/core/test/duration_use_case_test.cpp | 4 +++- libwvdrmengine/cdm/test/request_license_test.cpp | 6 +++--- libwvdrmengine/cdm/test/wv_cdm_metrics_test.cpp | 4 ++-- libwvdrmengine/cdm/util/include/wv_attributes.h | 16 ++++++++++++++++ .../mediadrm/test/WVDrmPlugin_test.cpp | 1 + 5 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 libwvdrmengine/cdm/util/include/wv_attributes.h diff --git a/libwvdrmengine/cdm/core/test/duration_use_case_test.cpp b/libwvdrmengine/cdm/core/test/duration_use_case_test.cpp index 0fd4f519..fe7e71b6 100644 --- a/libwvdrmengine/cdm/core/test/duration_use_case_test.cpp +++ b/libwvdrmengine/cdm/core/test/duration_use_case_test.cpp @@ -28,6 +28,7 @@ #include "test_printers.h" #include "test_sleep.h" #include "url_request.h" +#include "wv_attributes.h" #include "wv_cdm_constants.h" #include "wv_cdm_event_listener.h" #include "wv_cdm_types.h" @@ -95,7 +96,8 @@ class SimpleEventListener : public wvcdm::WvCdmEventListener { } void OnSessionKeysChange(const CdmSessionId&, const CdmKeyStatusMap&, bool) override {} - void OnExpirationUpdate(const CdmSessionId&, int64_t expiry_time) override {} + void OnExpirationUpdate(const CdmSessionId&, + int64_t expiry_time UNUSED) override {} bool renewal_needed() { return renewal_needed_; } void set_renewal_needed(bool renewal_needed) { renewal_needed_ = renewal_needed; diff --git a/libwvdrmengine/cdm/test/request_license_test.cpp b/libwvdrmengine/cdm/test/request_license_test.cpp index d539bad7..e0598ea9 100644 --- a/libwvdrmengine/cdm/test/request_license_test.cpp +++ b/libwvdrmengine/cdm/test/request_license_test.cpp @@ -53,13 +53,13 @@ namespace { const int kHttpOk = 200; const wvcdm::CdmIdentifier kExampleIdentifier = { - wvcdm::EMPTY_SPOID, "com.example", "com.example", 7}; + wvcdm::EMPTY_SPOID, "com.example", "com.example", 7, 9}; const wvcdm::CdmIdentifier kAlternateCdmIdentifier1 = { - "alternate_spoid_1", "alternate_origin_1", "com.alternate1.url", 8}; + "alternate_spoid_1", "alternate_origin_1", "com.alternate1.url", 8, 10}; const wvcdm::CdmIdentifier kAlternateCdmIdentifier2 = { - "alternate_spoid_2", "" /* empty origin */, "com.alternate2.url", 8}; + "alternate_spoid_2", "" /* empty origin */, "com.alternate2.url", 9, 11}; const std::string kEmptyServiceCertificate; const std::string kComma = ","; diff --git a/libwvdrmengine/cdm/test/wv_cdm_metrics_test.cpp b/libwvdrmengine/cdm/test/wv_cdm_metrics_test.cpp index 3241ea6f..f4db8233 100644 --- a/libwvdrmengine/cdm/test/wv_cdm_metrics_test.cpp +++ b/libwvdrmengine/cdm/test/wv_cdm_metrics_test.cpp @@ -145,10 +145,10 @@ TEST_F(WvContentDecryptionModuleMetricsTest, CdmSessionId session_id; wvcdm::CdmKeySystem key_system("com.widevine"); CdmIdentifier identifiers[] = {kDefaultCdmIdentifier, - {"foo", "bar", "baz", 7}, + {"foo", "bar", "baz", 7, 10}, // Note that this has all the same parameters // as the one above except for the unique_id. - {"foo", "bar", "baz", 8}}; + {"foo", "bar", "baz", 8, 11}}; const int cdm_engine_count = 3; // Force Unprovision. diff --git a/libwvdrmengine/cdm/util/include/wv_attributes.h b/libwvdrmengine/cdm/util/include/wv_attributes.h new file mode 100644 index 00000000..c817f1c0 --- /dev/null +++ b/libwvdrmengine/cdm/util/include/wv_attributes.h @@ -0,0 +1,16 @@ +// Copyright 2021 Google LLC. All rights reserved. This file and proprietary +// source code may only be used and distributed under the Widevine +// License Agreement. + +#ifndef WVCDM_UTIL_WV_ATTRIBUTES_H_ +#define WVCDM_UTIL_WV_ATTRIBUTES_H_ + +#ifndef UNUSED +# if defined(__GNUC__) || defined(__clang__) +# define UNUSED __attribute__((__unused__)) +# else +# define UNUSED +# endif +#endif + +#endif // WVCDM_UTIL_WV_ATTRIBUTES_H_ diff --git a/libwvdrmengine/mediadrm/test/WVDrmPlugin_test.cpp b/libwvdrmengine/mediadrm/test/WVDrmPlugin_test.cpp index 11f96b76..a4be0776 100644 --- a/libwvdrmengine/mediadrm/test/WVDrmPlugin_test.cpp +++ b/libwvdrmengine/mediadrm/test/WVDrmPlugin_test.cpp @@ -913,6 +913,7 @@ TEST_F(WVDrmPluginTest, RejectsAtscProvisioningRequests) { Status status = plugin.setPropertyString(hidl_string("atscMode"), hidl_string("enable")); + ASSERT_EQ(Status::OK, status); plugin.getProvisionRequest( hidl_string(""), hidl_string(""), From 16c704fa0950498cb65bea32a167e93ce00d566e Mon Sep 17 00:00:00 2001 From: Alex Dale Date: Thu, 11 Mar 2021 19:32:34 -0800 Subject: [PATCH 2/2] Android tests call exit() when complete. [ Merge of http://go/wvgerrit/119804 ] The coverage framework used by Android requires the process to call exit() for coverage information to be dumped after the tests. Android unit tests have been adapted to use the a new main module. The core test_main.cpp used by integration tests has been updated to call exit(). Bug: 138941105 Test: Linux and Android unittests Change-Id: Ifffc7b8290c50dffe527738a36547c1d2fb90bd3 --- libwvdrmengine/cdm/core/test/test_main.cpp | 7 +++++-- libwvdrmengine/cdm/test/cdm_test_main.cpp | 17 +++++++++++++++++ libwvdrmengine/cdm/test/unit-test.mk | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 libwvdrmengine/cdm/test/cdm_test_main.cpp diff --git a/libwvdrmengine/cdm/core/test/test_main.cpp b/libwvdrmengine/cdm/core/test/test_main.cpp index edf9e306..ae305021 100644 --- a/libwvdrmengine/cdm/core/test/test_main.cpp +++ b/libwvdrmengine/cdm/core/test/test_main.cpp @@ -5,7 +5,7 @@ // Use in place of the gtest_main in order to initialize the WvCdmTestBase using // command line parameters. -#include +#include #include "log.h" #include "test_base.h" @@ -13,5 +13,8 @@ int main(int argc, char** argv) { if (!wvcdm::WvCdmTestBase::Initialize(argc, argv)) return 1; ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + const int status = RUN_ALL_TESTS(); + LOGD("CDM test complete with status %d", status); + exit(status); // Explicit call to exit() is required for code coverage. + return status; } diff --git a/libwvdrmengine/cdm/test/cdm_test_main.cpp b/libwvdrmengine/cdm/test/cdm_test_main.cpp new file mode 100644 index 00000000..8bbf6221 --- /dev/null +++ b/libwvdrmengine/cdm/test/cdm_test_main.cpp @@ -0,0 +1,17 @@ +// Copyright 2021 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. +#include + +#include "gtest/gtest.h" + +#include "log.h" + +int main(int argc, char** argv) { + LOGI("Running Android CDM tests"); + testing::InitGoogleTest(&argc, argv); + const int status = RUN_ALL_TESTS(); + LOGD("CDM test complete with status %d", status); + exit(status); // Explicit call to exit() is required for code coverage. + return status; +} diff --git a/libwvdrmengine/cdm/test/unit-test.mk b/libwvdrmengine/cdm/test/unit-test.mk index 4daa4b88..f4919842 100644 --- a/libwvdrmengine/cdm/test/unit-test.mk +++ b/libwvdrmengine/cdm/test/unit-test.mk @@ -20,6 +20,7 @@ LOCAL_SRC_FILES := \ ../core/test/url_request.cpp \ ../../oemcrypto/test/oec_device_features.cpp \ ../util/test/test_sleep.cpp \ + ./cdm_test_main.cpp \ LOCAL_C_INCLUDES := \ vendor/widevine/libwvdrmengine/android/cdm/test \ @@ -44,7 +45,6 @@ LOCAL_STATIC_LIBRARIES := \ libjsmn \ libgmock \ libgtest \ - libgtest_main \ libwvlevel3 \ LOCAL_SHARED_LIBRARIES := \