Created a unified Android test for coverage.

[ Merge of http://go/wvgerrit/143889 ]

New test binary for generating code coverage information.  Run several
reliable, short runnning unit tests.  Actual test failures do not
affect the result of this test.

Bug: 138941105
Bug: 191681397
Test: Android cdm_coverage_test
Change-Id: I6b74d361a8a0e2896e0489acaa64d264158ecaa4
This commit is contained in:
Alex Dale
2022-01-20 13:57:40 -08:00
parent e5822def1d
commit 4c6e10f7d6
6 changed files with 143 additions and 18 deletions

View File

@@ -50,6 +50,9 @@ test_src_dir := ../core/test
test_main := ../core/test/test_main.cpp
include $(LOCAL_PATH)/integration-test.mk
# coverage-test.mk will define test name.
include $(LOCAL_PATH)/coverage-test.mk
test_name := counter_metric_unittest
test_src_dir := ../metrics/test
include $(LOCAL_PATH)/unit-test.mk

View File

@@ -0,0 +1,49 @@
// Copyright 2022 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
#include <stdlib.h>
#include <string>
#include "gtest/gtest.h"
#include "log.h"
namespace wvcdm {
namespace {
void UpdateGtestFilter() {
const std::string initial_filter = ::testing::GTEST_FLAG(filter);
if (!initial_filter.empty()) {
LOGW("Ignoring provided GTEST filter: %s", initial_filter.c_str());
}
std::string final_filter("-");
// Sleepy tests.
final_filter.append("*VerifyUsageTimes*:*Refresh*:*TimingTest*");
final_filter.append(":*KeyDuration*:*CdmUseCase*");
final_filter.append(":*ExtendedDurationTest*");
// Slow tests.
final_filter.append(":*OEMCryptoMemory*:*Huge*:*NonceFlood*");
final_filter.append(
":*TwoHundredEntries*:*ManyUsageEntries*:*UsageTableDefrag*");
final_filter.append(
":*DecryptMax*:*MaxTotalKeys*:*OEMCryptoSessionTestsDecryptTests*");
final_filter.append(":*SharedMutex*:*Parallel*");
// Flacky tests.
final_filter.append(":*Repeated/ParallelCdmTest*");
// L1 only tests.
final_filter.append(":*Level1Required");
::testing::GTEST_FLAG(filter) = final_filter;
}
} // namespace
} // namespace wvcdm
int main(int argc, char** argv) {
LOGI("Running Android CDM tests");
testing::InitGoogleTest(&argc, argv);
wvcdm::UpdateGtestFilter();
const int status = RUN_ALL_TESTS();
LOGD("CDM coverage test complete with status %d", status);
// Test is for coverage information only, actual test failure
// should not change the final result of the test executable.
return EXIT_SUCCESS;
}

View File

@@ -1,17 +0,0 @@
// 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 <stdlib.h>
#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;
}

View File

@@ -0,0 +1,89 @@
# ----------------------------------------------------------------
# Builds CDM Coverage Test.
#
include $(CLEAR_VARS)
LOCAL_LICENSE_CONDITIONS := by_exception_only
LOCAL_LICENSE_KINDS := legacy_by_exception_only
LOCAL_MODULE := cdm_coverage_test
LOCAL_MODULE_TAGS := tests
LOCAL_SRC_FILES := \
./cdm_coverage_main.cpp \
../core/test/buffer_reader_test.cpp \
../core/test/config_test_env.cpp \
../core/test/device_files_unittest.cpp \
../core/test/fake_provisioning_server.cpp \
../core/test/http_socket.cpp \
../core/test/initialization_data_unittest.cpp \
../core/test/license_keys_unittest.cpp \
../core/test/license_request.cpp \
../core/test/service_certificate_unittest.cpp \
../core/test/test_base.cpp \
../core/test/test_printers.cpp \
../core/test/url_request.cpp \
../metrics/test/counter_metric_unittest.cpp \
../metrics/test/distribution_unittest.cpp \
../metrics/test/event_metric_unittest.cpp \
../metrics/test/metrics_collections_unittest.cpp \
../metrics/test/value_metric_unittest.cpp \
../util/test/base64_test.cpp \
../util/test/cdm_random_unittest.cpp \
../util/test/file_store_unittest.cpp \
../util/test/file_utils_unittest.cpp \
../util/test/test_sleep.cpp \
../../oemcrypto/test/oec_device_features.cpp \
../../oemcrypto/test/oec_key_deriver.cpp \
../../oemcrypto/test/oec_session_util.cpp \
LOCAL_C_INCLUDES := \
vendor/widevine/libwvdrmengine/android/cdm/test \
vendor/widevine/libwvdrmengine/cdm/core/include \
vendor/widevine/libwvdrmengine/cdm/core/test \
vendor/widevine/libwvdrmengine/cdm/include \
vendor/widevine/libwvdrmengine/cdm/metrics/include \
vendor/widevine/libwvdrmengine/cdm/util/include \
vendor/widevine/libwvdrmengine/cdm/util/test \
vendor/widevine/libwvdrmengine/oemcrypto/include \
vendor/widevine/libwvdrmengine/oemcrypto/test \
vendor/widevine/libwvdrmengine/oemcrypto/test/fuzz_tests \
vendor/widevine/libwvdrmengine/oemcrypto/odk/include \
vendor/widevine/libwvdrmengine/oemcrypto/odk/kdo/include \
LOCAL_C_INCLUDES += external/protobuf/src
LOCAL_STATIC_LIBRARIES := \
libcdm \
libcdm_protos \
libcdm_utils \
libjsmn \
libgmock \
libgtest \
libwvlevel3 \
libwv_kdo \
libwv_odk \
LOCAL_SHARED_LIBRARIES := \
libbase \
libcrypto \
libdl \
libhidlbase \
liblog \
libmedia_omx \
libprotobuf-cpp-lite \
libssl \
libstagefright_foundation \
libutils \
LOCAL_CFLAGS += -DUNIT_TEST
LOCAL_MODULE_OWNER := widevine
LOCAL_PROPRIETARY_MODULE := true
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
ifneq ($(TARGET_ENABLE_MEDIADRM_64), true)
LOCAL_MODULE_TARGET_ARCH := arm x86 mips
endif
include $(BUILD_EXECUTABLE)

View File

@@ -22,7 +22,6 @@ 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 \
@@ -47,6 +46,7 @@ LOCAL_STATIC_LIBRARIES := \
libjsmn \
libgmock \
libgtest \
libgtest_main \
libwvlevel3 \
LOCAL_SHARED_LIBRARIES := \