Added skip test flags to test_base
Flags are to be used in new tests when creating tests that potentially take a long time to run. Certain test suites are intended to be quick and may skip certain long running tests. New slow tests should check these flags and skip using GTEST_SKIP(). Bug: 311273599 Test: ./build.py x86-64 --debug Change-Id: I4fc5a026f23f489bf2ad8b8a11dc467f550f0c5e
This commit is contained in:
@@ -145,14 +145,60 @@ void show_menu(const char* prog_name, const std::string& extra_help_text) {
|
|||||||
|
|
||||||
std::cout << " --dump_golden_data" << std::endl;
|
std::cout << " --dump_golden_data" << std::endl;
|
||||||
std::cout << " Dump the license request and response from the server."
|
std::cout << " Dump the license request and response from the server."
|
||||||
|
<< std::endl
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
|
std::cout << " --skip-slow-tests" << std::endl;
|
||||||
|
std::cout << " Skips tests that are known to be slow." << std::endl;
|
||||||
|
std::cout << " --skip-sleepy-tests" << std::endl;
|
||||||
|
std::cout << " Skips tests that sleep a lot." << std::endl;
|
||||||
|
std::cout << " --run-sleepy-tests" << std::endl;
|
||||||
|
std::cout << " Allow tests that sleep a lot (used with --skip-slow-tests)"
|
||||||
|
<< std::endl;
|
||||||
|
std::cout << " --skip-decryption-stress-tests" << std::endl;
|
||||||
|
std::cout << " Skips decryption stress tests." << std::endl;
|
||||||
|
std::cout << " --run-decryption-stress-tests" << std::endl;
|
||||||
|
std::cout << " Allow decryption stress tests (used with "
|
||||||
|
<< "--skip-slow-tests)" << std::endl;
|
||||||
|
std::cout << " --skip-request-flood-tests" << std::endl;
|
||||||
|
std::cout << " Skips tests that generate a lot of requests." << std::endl;
|
||||||
|
std::cout << " --run-request-flood-tests" << std::endl;
|
||||||
|
std::cout << " Allow tests that generate a lot of requests (used with "
|
||||||
|
<< "--skip-slow-tests)" << std::endl;
|
||||||
|
std::cout << " --skip-multi-thread-stress-tests" << std::endl;
|
||||||
|
std::cout << " Skips tests that stress thread protections." << std::endl;
|
||||||
|
std::cout << " --run-multi-thread-stress-tests" << std::endl;
|
||||||
|
std::cout << " Allow tests that stress thread protections (used with "
|
||||||
|
<< "--skip-slow-tests)" << std::endl;
|
||||||
|
std::cout << " --skip-usage-table-stress-tests" << std::endl;
|
||||||
|
std::cout << " Skips tests that stess the usage table." << std::endl;
|
||||||
|
std::cout << " --run-usage-table-stress-tests" << std::endl;
|
||||||
|
std::cout << " Allow tests that stess the usage table (used with "
|
||||||
|
<< "--skip-slow-tests)" << std::endl
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
std::cout << extra_help_text << std::endl;
|
std::cout << extra_help_text << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum OptionalBool {
|
||||||
|
kBoolUnset,
|
||||||
|
kBoolFalse,
|
||||||
|
kBoolTrue,
|
||||||
|
};
|
||||||
|
|
||||||
|
bool UnwrapOptionalBool(OptionalBool value, bool default_value) {
|
||||||
|
return (value == kBoolUnset) ? default_value : (value == kBoolTrue);
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
// Static WvCdmTestBase variables.
|
||||||
std::unique_ptr<ConfigTestEnv> WvCdmTestBase::default_config_;
|
std::unique_ptr<ConfigTestEnv> WvCdmTestBase::default_config_;
|
||||||
bool WvCdmTestBase::use_qa_test_keybox_ = false;
|
bool WvCdmTestBase::use_qa_test_keybox_ = false;
|
||||||
|
bool WvCdmTestBase::skip_sleepy_tests_ = false;
|
||||||
|
bool WvCdmTestBase::skip_decryption_stress_tests_ = false;
|
||||||
|
bool WvCdmTestBase::skip_request_flood_tests_ = false;
|
||||||
|
bool WvCdmTestBase::skip_multi_thread_stress_tests_ = false;
|
||||||
|
bool WvCdmTestBase::skip_usage_table_stress_tests_ = false;
|
||||||
|
|
||||||
void WvCdmTestBase::StripeBuffer(std::vector<uint8_t>* buffer, size_t size,
|
void WvCdmTestBase::StripeBuffer(std::vector<uint8_t>* buffer, size_t size,
|
||||||
uint8_t init) {
|
uint8_t init) {
|
||||||
@@ -311,8 +357,7 @@ void WvCdmTestBase::InstallTestRootOfTrust() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WvCdmTestBase::WvCdmTestBase()
|
WvCdmTestBase::WvCdmTestBase() : config_(*default_config_) {
|
||||||
: config_(*default_config_), binary_provisioning_(false) {
|
|
||||||
const ::testing::TestInfo* const test_info =
|
const ::testing::TestInfo* const test_info =
|
||||||
::testing::UnitTest::GetInstance()->current_test_info();
|
::testing::UnitTest::GetInstance()->current_test_info();
|
||||||
|
|
||||||
@@ -375,12 +420,21 @@ bool WvCdmTestBase::Initialize(int argc, const char* const argv[],
|
|||||||
bool show_usage = false;
|
bool show_usage = false;
|
||||||
int verbosity = 0;
|
int verbosity = 0;
|
||||||
|
|
||||||
|
bool skip_slow_tests = false;
|
||||||
|
OptionalBool skip_sleepy_tests = kBoolUnset;
|
||||||
|
OptionalBool skip_decryption_stress_tests = kBoolUnset;
|
||||||
|
OptionalBool skip_request_flood_tests = kBoolUnset;
|
||||||
|
OptionalBool skip_multi_thread_stress_tests = kBoolUnset;
|
||||||
|
OptionalBool skip_usage_table_stress_tests = kBoolUnset;
|
||||||
|
|
||||||
default_config_.reset(new ConfigTestEnv(kContentProtectionUatServer));
|
default_config_.reset(new ConfigTestEnv(kContentProtectionUatServer));
|
||||||
|
|
||||||
// Skip the first element, which is the program name.
|
// Skip the first element, which is the program name.
|
||||||
const std::vector<std::string> args(argv + 1, argv + argc);
|
const std::vector<std::string> args(argv + 1, argv + argc);
|
||||||
for (const std::string& arg : args) {
|
for (const std::string& arg : args) {
|
||||||
if (arg == "--verbose" || arg == "-v") {
|
if (arg == "--help" || arg == "-h") {
|
||||||
|
show_usage = true;
|
||||||
|
} else if (arg == "--verbose" || arg == "-v") {
|
||||||
++verbosity;
|
++verbosity;
|
||||||
} else if (arg == "--no_filter") {
|
} else if (arg == "--no_filter") {
|
||||||
filter_tests = false;
|
filter_tests = false;
|
||||||
@@ -398,6 +452,28 @@ bool WvCdmTestBase::Initialize(int argc, const char* const argv[],
|
|||||||
} else if (arg == "--dump_golden_data") {
|
} else if (arg == "--dump_golden_data") {
|
||||||
default_config_->set_dump_golden_data(true);
|
default_config_->set_dump_golden_data(true);
|
||||||
testing::AddGlobalTestEnvironment(new MessageDumper);
|
testing::AddGlobalTestEnvironment(new MessageDumper);
|
||||||
|
} else if (arg == "--skip-slow-tests") {
|
||||||
|
skip_slow_tests = true;
|
||||||
|
} else if (arg == "--skip-sleepy-tests") {
|
||||||
|
skip_sleepy_tests = kBoolTrue;
|
||||||
|
} else if (arg == "--run-sleepy-tests") {
|
||||||
|
skip_sleepy_tests = kBoolFalse;
|
||||||
|
} else if (arg == "--skip-decryption-stress-tests") {
|
||||||
|
skip_decryption_stress_tests = kBoolTrue;
|
||||||
|
} else if (arg == "--run-decryption-stress-tests") {
|
||||||
|
skip_decryption_stress_tests = kBoolFalse;
|
||||||
|
} else if (arg == "--skip-request-flood-tests") {
|
||||||
|
skip_request_flood_tests = kBoolTrue;
|
||||||
|
} else if (arg == "--run-request-flood-tests") {
|
||||||
|
skip_request_flood_tests = kBoolFalse;
|
||||||
|
} else if (arg == "--skip-multi-thread-stress-tests") {
|
||||||
|
skip_multi_thread_stress_tests = kBoolTrue;
|
||||||
|
} else if (arg == "--run-multi-thread-stress-tests") {
|
||||||
|
skip_multi_thread_stress_tests = kBoolFalse;
|
||||||
|
} else if (arg == "--skip-usage-table-stress-tests") {
|
||||||
|
skip_usage_table_stress_tests = kBoolTrue;
|
||||||
|
} else if (arg == "--run-usage-table-stress-tests") {
|
||||||
|
skip_usage_table_stress_tests = kBoolFalse;
|
||||||
} else {
|
} else {
|
||||||
const auto index = arg.find('=');
|
const auto index = arg.find('=');
|
||||||
if (index == std::string::npos) {
|
if (index == std::string::npos) {
|
||||||
@@ -498,6 +574,16 @@ bool WvCdmTestBase::Initialize(int argc, const char* const argv[],
|
|||||||
::testing::GTEST_FLAG(filter) =
|
::testing::GTEST_FLAG(filter) =
|
||||||
wvoec::global_features.RestrictFilter(::testing::GTEST_FLAG(filter));
|
wvoec::global_features.RestrictFilter(::testing::GTEST_FLAG(filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skip_sleepy_tests_ = UnwrapOptionalBool(skip_sleepy_tests, skip_slow_tests);
|
||||||
|
skip_decryption_stress_tests_ =
|
||||||
|
UnwrapOptionalBool(skip_decryption_stress_tests, skip_slow_tests);
|
||||||
|
skip_request_flood_tests_ =
|
||||||
|
UnwrapOptionalBool(skip_request_flood_tests, skip_slow_tests);
|
||||||
|
skip_multi_thread_stress_tests_ =
|
||||||
|
UnwrapOptionalBool(skip_multi_thread_stress_tests, skip_slow_tests);
|
||||||
|
skip_usage_table_stress_tests_ =
|
||||||
|
UnwrapOptionalBool(skip_usage_table_stress_tests, skip_slow_tests);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,20 @@ class WvCdmTestBase : public ::testing::Test {
|
|||||||
// Calls Provision() if not already provisioned.
|
// Calls Provision() if not already provisioned.
|
||||||
virtual void EnsureProvisioned();
|
virtual void EnsureProvisioned();
|
||||||
|
|
||||||
|
virtual bool skip_sleepy_tests() const { return skip_sleepy_tests_; }
|
||||||
|
virtual bool skip_decryption_stress_tests() const {
|
||||||
|
return skip_decryption_stress_tests_;
|
||||||
|
}
|
||||||
|
virtual bool skip_request_flood_tests() const {
|
||||||
|
return skip_request_flood_tests_;
|
||||||
|
}
|
||||||
|
virtual bool skip_multi_thread_stress_tests() const {
|
||||||
|
return skip_multi_thread_stress_tests_;
|
||||||
|
}
|
||||||
|
virtual bool skip_usage_table_stress_tests() const {
|
||||||
|
return skip_usage_table_stress_tests_;
|
||||||
|
}
|
||||||
|
|
||||||
// Fill a buffer with some nonconstant data of the given size. The first byte
|
// Fill a buffer with some nonconstant data of the given size. The first byte
|
||||||
// will be set to <init> to help you find the buffer when debugging.
|
// will be set to <init> to help you find the buffer when debugging.
|
||||||
static void StripeBuffer(std::vector<uint8_t>* buffer, size_t size,
|
static void StripeBuffer(std::vector<uint8_t>* buffer, size_t size,
|
||||||
@@ -78,7 +92,15 @@ class WvCdmTestBase : public ::testing::Test {
|
|||||||
|
|
||||||
// This should be set by test subclasses BEFORE calling SetUp -- i.e. in the
|
// This should be set by test subclasses BEFORE calling SetUp -- i.e. in the
|
||||||
// tests's constructor.
|
// tests's constructor.
|
||||||
bool binary_provisioning_;
|
bool binary_provisioning_ = false;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Skip flags for long running tests.
|
||||||
|
static bool skip_sleepy_tests_;
|
||||||
|
static bool skip_decryption_stress_tests_;
|
||||||
|
static bool skip_request_flood_tests_;
|
||||||
|
static bool skip_multi_thread_stress_tests_;
|
||||||
|
static bool skip_usage_table_stress_tests_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This just makes the constructor public so that we can create one with dummy
|
// This just makes the constructor public so that we can create one with dummy
|
||||||
|
|||||||
Reference in New Issue
Block a user