summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Calin Juravle <calin@google.com> 2021-06-07 09:05:08 -0700
committer Calin Juravle <calin@google.com> 2021-06-07 17:17:50 +0000
commitb390ba9fad86d8fe431c037708fe9bd8a3d44960 (patch)
tree43c15ea60c1f26003dbf5a4342a58e4988a55d6d
parentf75b8e9947763ab59ee655054f878e44844518e2 (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 Change-Id: Ibdaf80b45c0a3a6529bfd2714c17df2dc83478b2
-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");