From b60f75805d89f925bac973e71b4be3ff9568e6d2 Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Thu, 20 Jun 2019 14:56:26 -0700 Subject: [PATCH] Unify log level for tests Merge from Widevine repo of http://go/wvgerrit/79463 and http://go/wvgerrit/82383 Several tests explicitly set the log level. This CL unifies that a little bit. When running the unit tests by hand, on android or for ce cdm, the log level is 0 (ERROR) and can be incremented on the command line using the "--verbose" switch. When running on the desktop, you can set the environment variable VERBOSE_LOG to "yes", and the log level is set to VERBOSE. This is done by the buildbot so you can see full logs in the build archive. When running with the test bed (i.e. Mod Mock) you can edit the options.txt file and set log_level to 0=ERROR up to 4=VERBOSE. if you are using the run_current_tests script, you can create a file in the linux directory called override_options.txt and add the line log_level 4 This CL only changes test code. bug: 124390006 Test: unit tests Change-Id: I1e042004692750e218b8c4220bce3ec1e387004e --- libwvdrmengine/cdm/core/test/test_base.cpp | 4 ++-- libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp | 1 - .../oemcrypto/test/oemcrypto_test_main.cpp | 15 ++++++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/libwvdrmengine/cdm/core/test/test_base.cpp b/libwvdrmengine/cdm/core/test/test_base.cpp index 606371c4..570bed46 100644 --- a/libwvdrmengine/cdm/core/test/test_base.cpp +++ b/libwvdrmengine/cdm/core/test/test_base.cpp @@ -38,7 +38,7 @@ void show_menu(char* prog_name) { std::cout << " e.g. adb shell '" << prog_name << " --server=\"url\"'" << std::endl; - std::cout << " --verbose" << std::endl; + std::cout << " --verbose or -v" << std::endl; std::cout << " increase logging verbosity (may be repeated)" << std::endl << std::endl; @@ -354,7 +354,7 @@ bool WvCdmTestBase::Initialize(int argc, char **argv) { // Skip the first element, which is the program name. const std::vector args(argv + 1, argv + argc); for (const std::string& arg : args) { - if (arg == "--verbose") { + if (arg == "--verbose" || arg == "-v") { ++verbosity; } else if (arg == "--no_filter") { filter_tests = false; diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp index 2b768de0..5b26a7fa 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_test.cpp @@ -130,7 +130,6 @@ class OEMCryptoClientTest : public ::testing::Test, public SessionUtil { void SetUp() override { ::testing::Test::SetUp(); - wvcdm::g_cutoff = wvcdm::LOG_INFO; 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/oemcrypto_test_main.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_test_main.cpp index baf839b9..2b5f40cb 100644 --- a/libwvdrmengine/oemcrypto/test/oemcrypto_test_main.cpp +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_test_main.cpp @@ -17,22 +17,27 @@ static void acknowledge_cast() { // Also, the test filter is updated based on the feature list. int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - wvcdm::g_cutoff = wvcdm::LOG_INFO; bool is_cast_receiver = false; bool force_load_test_keybox = false; bool filter_tests = true; - for (int i = 0; i < argc; i++) { - if (!strcmp(argv[i], "--cast")) { + int verbosity = 0; + // Skip the first element, which is the program name. + const std::vector args(argv + 1, argv + argc); + for (const std::string& arg : args) { + if (arg == "--verbose" || arg == "-v") { + ++verbosity; + } else if (arg == "--cast") { acknowledge_cast(); is_cast_receiver = true; } - if (!strcmp(argv[i], "--force_load_test_keybox")) { + if (arg == "--force_load_test_keybox") { force_load_test_keybox = true; } - if (!strcmp(argv[i], "--no_filter")) { + if (arg == "--no_filter") { filter_tests = false; } } + wvcdm::g_cutoff = static_cast(verbosity); wvoec::global_features.Initialize(is_cast_receiver, force_load_test_keybox); // If the user requests --no_filter, we don't change the filter, otherwise, we // filter out features that are not supported.