diff options
author | Elliott Hughes <enh@google.com> | 2017-02-10 18:13:46 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2017-02-13 13:30:10 -0800 |
commit | a0d374d587ec18d437d0dd15ba1332aceaa188af (patch) | |
tree | a9466c8841140cf70290c54d50354f245ea3a9db /tests/system_properties_test2.cpp | |
parent | 132768084e24119c337e56fd110b97a23e5593c2 (diff) | |
download | android_bionic-a0d374d587ec18d437d0dd15ba1332aceaa188af.tar.gz android_bionic-a0d374d587ec18d437d0dd15ba1332aceaa188af.tar.bz2 android_bionic-a0d374d587ec18d437d0dd15ba1332aceaa188af.zip |
Add __system_property_wait and return the serial in __system_property_read_callback.
In order to implement android::base::WaitForProperty well, we need a way to
wait not for *any* property to change (__system_property_wait_any), but to
specifically wait for the property represented by a given `prop_info` to
change.
The android::base::WaitForProperty implementation, like attempts to cache
system properties in the past, also needs a way to keep serials and values
in sync, but the existing functions don't provide a cheap way to get a
consistent snapshot. Change the __system_property_read_callback callback's
type to include the serial corresponding to the given value.
Add a test, slightly clean up some of the existing tests (and name them to
include the names of the functions they're testing, in our usual style).
Bug: http://b/35201172
Test: ran tests
Change-Id: Ibc8ebe2e88eef1e333a1bd3dd7f68135f1ba7fb5
Diffstat (limited to 'tests/system_properties_test2.cpp')
-rw-r--r-- | tests/system_properties_test2.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/tests/system_properties_test2.cpp b/tests/system_properties_test2.cpp index 056096001..e6e7ef25c 100644 --- a/tests/system_properties_test2.cpp +++ b/tests/system_properties_test2.cpp @@ -90,20 +90,22 @@ TEST(properties, smoke) { ASSERT_TRUE(pi != nullptr); std::string expected_name = property_name; - __system_property_read_callback(pi, [](void* cookie, const char *name, const char *value) { - const std::string* expected_name = static_cast<const std::string*>(cookie); - ASSERT_EQ(*expected_name, name); - ASSERT_STREQ("value1-1", value); + __system_property_read_callback(pi, + [](void* cookie, const char* name, const char* value, unsigned /*serial*/) { + const std::string* expected_name = static_cast<const std::string*>(cookie); + ASSERT_EQ(*expected_name, name); + ASSERT_STREQ("value1-1", value); }, &expected_name); pi = __system_property_find(long_property_name.c_str()); ASSERT_TRUE(pi != nullptr); expected_name = long_property_name; - __system_property_read_callback(pi, [](void* cookie, const char *name, const char *value) { - const std::string* expected_name = static_cast<const std::string*>(cookie); - ASSERT_EQ(*expected_name, name); - ASSERT_STREQ("value2", value); + __system_property_read_callback(pi, + [](void* cookie, const char* name, const char* value, unsigned /*serial*/) { + const std::string* expected_name = static_cast<const std::string*>(cookie); + ASSERT_EQ(*expected_name, name); + ASSERT_STREQ("value2", value); }, &expected_name); // Check that read() for long names still works but returns truncated version of the name |