summaryrefslogtreecommitdiff
path: root/tests/system_properties_test2.cpp
diff options
context:
space:
mode:
authorSteven Laver <lavers@google.com>2019-11-14 08:37:29 -0800
committerSteven Laver <lavers@google.com>2019-11-14 08:37:29 -0800
commit8f54dd5edaa4ba55451f3602e5890b6f1ab807e6 (patch)
tree709208dd25e59100a8d3d9a7038a5c7ee1c8a50b /tests/system_properties_test2.cpp
parent19c0c9cd4892927004dac3252b67aac89e462c5c (diff)
parentcb88137aebba97024bee4fff130f131924556ee5 (diff)
Merge RP1A.191114.001
Change-Id: I19fb768a647d471d430af4b5c3f519d4125fdeee
Diffstat (limited to 'tests/system_properties_test2.cpp')
-rw-r--r--tests/system_properties_test2.cpp35
1 files changed, 30 insertions, 5 deletions
diff --git a/tests/system_properties_test2.cpp b/tests/system_properties_test2.cpp
index b9936dd48..0953bdeb0 100644
--- a/tests/system_properties_test2.cpp
+++ b/tests/system_properties_test2.cpp
@@ -14,8 +14,6 @@
* limitations under the License.
*/
-#include <gtest/gtest.h>
-
#include <errno.h>
#include <sys/wait.h>
#include <unistd.h>
@@ -24,6 +22,10 @@
#include <sstream>
#include <string>
+#include <gtest/gtest.h>
+
+#include "utils.h"
+
#if defined(__BIONIC__)
#include <sys/system_properties.h>
int64_t NanoTime() {
@@ -128,6 +130,29 @@ TEST(properties, smoke) {
#endif // __BIONIC__
}
+TEST(properties, no_fd_leaks) {
+#if defined(__BIONIC__)
+ FdLeakChecker leak_checker;
+ std::stringstream ss;
+ ss << "debug.test." << getpid() << "." << NanoTime() << ".";
+ const std::string property_prefix = ss.str();
+ const std::string property_name = property_prefix + "property1";
+
+ for (size_t i = 0; i < 100; ++i) {
+ char propvalue[PROP_VALUE_MAX];
+ ASSERT_EQ(0, __system_property_set(property_name.c_str(), "value1"));
+ ASSERT_EQ(6, __system_property_get(property_name.c_str(), propvalue));
+ ASSERT_STREQ("value1", propvalue);
+
+ ASSERT_EQ(0, __system_property_set(property_name.c_str(), "value2"));
+ ASSERT_EQ(6, __system_property_get(property_name.c_str(), propvalue));
+ ASSERT_STREQ("value2", propvalue);
+ }
+#else // __BIONIC__
+ GTEST_SKIP() << "bionic-only test";
+#endif // __BIONIC__
+}
+
TEST(properties, empty_value) {
#if defined(__BIONIC__)
char propvalue[PROP_VALUE_MAX];
@@ -136,13 +161,13 @@ TEST(properties, empty_value) {
ss << "debug.test." << getpid() << "." << NanoTime() << "." << "property_empty";
const std::string property_name = ss.str();
- for (size_t i=0; i<1000; ++i) {
+ for (size_t i = 0; i < 1000; ++i) {
ASSERT_EQ(0, __system_property_set(property_name.c_str(), ""));
ASSERT_EQ(0, __system_property_get(property_name.c_str(), propvalue));
ASSERT_STREQ("", propvalue);
}
-#else // __BIONIC__
- GTEST_SKIP() << "bionic-only test";
+#else // __BIONIC__
+ GTEST_SKIP() << "bionic-only test";
#endif // __BIONIC__
}