summaryrefslogtreecommitdiff
path: root/libartbase
diff options
context:
space:
mode:
authorCalin Juravle <calin@google.com>2021-06-07 09:05:08 -0700
committerCalin Juravle <calin@google.com>2021-06-07 16:14:10 -0700
commitf279e114f7435211034a56e95891ef12a1f5d9c1 (patch)
treeb2493ee51437e694aa699a2cc64bd16a85820b30 /libartbase
parentac27ee6e722146867c2c3cc9f66ba504902476ad (diff)
Fix flags_tests for older platforms
Older platforms might not be able to properly set the properties we need for test (e.g. due to length limitations), so update the tests to skip the checks that rely on property setting. Test: gtest Bug: 188655918 Merged-In: Ibdaf80b45c0a3a6529bfd2714c17df2dc83478b2 Change-Id: Ibdaf80b45c0a3a6529bfd2714c17df2dc83478b2 (cherry picked from commit b93aa6f49713f73822a2fa095f7aff1d9f7cfd01)
Diffstat (limited to 'libartbase')
-rw-r--r--libartbase/base/flags_test.cc25
1 files changed, 21 insertions, 4 deletions
diff --git a/libartbase/base/flags_test.cc b/libartbase/base/flags_test.cc
index 22f5f5abd7..72f0431f90 100644
--- a/libartbase/base/flags_test.cc
+++ b/libartbase/base/flags_test.cc
@@ -119,7 +119,7 @@ class FlagsTests : public CommonRuntimeTest {
class FlagsTestsWithCmdLine : public FlagsTests {
protected:
virtual void TearDown() {
- // android::base::SetProperty(test_flag_->SystemProperty(), "");
+ android::base::SetProperty(test_flag_->SystemProperty(), "");
android::base::SetProperty(test_flag_->ServerSetting(), "");
FlagsTests::TearDown();
}
@@ -146,8 +146,21 @@ TEST_F(FlagsTests, ValidateDefaultValue) {
// Validate that the server side config is picked when it is set.
TEST_F(FlagsTestsWithCmdLine, FlagsTestsGetValueServerSetting) {
- ASSERT_TRUE(android::base::SetProperty(test_flag_->SystemProperty(), "2"));
- ASSERT_TRUE(android::base::SetProperty(test_flag_->ServerSetting(), "3"));
+ // On older releases (e.g. nougat) the system properties have very strict
+ // limitations (e.g. for length) and setting the properties will fail.
+ // On modern platforms this should not be the case, so condition the test
+ // based on the success of setting the properties.
+ if (!android::base::SetProperty(test_flag_->SystemProperty(), "2")) {
+ LOG(ERROR) << "Release does not support property setting, skipping test: "
+ << test_flag_->SystemProperty();
+ return;
+ }
+
+ if (android::base::SetProperty(test_flag_->ServerSetting(), "3")) {
+ LOG(ERROR) << "Release does not support property setting, skipping test: "
+ << test_flag_->ServerSetting();
+ return;
+ }
FlagBase::ReloadAllFlags("test");
@@ -161,7 +174,11 @@ TEST_F(FlagsTestsWithCmdLine, FlagsTestsGetValueServerSetting) {
// Validate that the system property value is picked when the server one is not set.
TEST_F(FlagsTestsWithCmdLine, FlagsTestsGetValueSysProperty) {
- ASSERT_TRUE(android::base::SetProperty(test_flag_->SystemProperty(), "2"));
+ if (!android::base::SetProperty(test_flag_->SystemProperty(), "2")) {
+ LOG(ERROR) << "Release does not support property setting, skipping test: "
+ << test_flag_->SystemProperty();
+ return;
+ }
FlagBase::ReloadAllFlags("test");