Run libbase_test as root and skip properties.too_long when not root
This test requires root to set the properties appropriately.
Bug: 159332135
Test: properties.too_long is passed/skipped appropriately.
Change-Id: I543146ad1c7674aafc5622bfec10439607757625
diff --git a/properties_test.cpp b/properties_test.cpp
index 94ae690..1655528 100644
--- a/properties_test.cpp
+++ b/properties_test.cpp
@@ -16,6 +16,8 @@
#include "android-base/properties.h"
+#include <unistd.h>
+
#include <gtest/gtest.h>
#include <atomic>
@@ -45,6 +47,11 @@
}
TEST(properties, too_long) {
+#if !defined(_WIN32)
+ if (getuid() != 0) {
+ GTEST_SKIP() << "Skipping test, must be run as root.";
+ }
+#endif
// Properties have a fixed limit on the size of their value.
std::string key("debug.libbase.property_too_long");
std::string value(92, 'a');