// Note that this test affects global state of the system // this tests tries to mitigate this by using utime+pid // prefix for the property name. It is still results in // pollution of property service since properties cannot // be removed. // // Note that there is also possibility to run into "out-of-memory" // if this test if it is executed often enough without reboot.
TEST(properties, smoke) { #ifdefined(__BIONIC__) char propvalue[PROP_VALUE_MAX];
// Set brand new property
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);
std::string long_value = "property-"; for (size_t i = 0; i < PROP_VALUE_MAX; i++) {
long_value += "y";
}
// Make sure that attempts to set invalid property value fails and preserves // previous value.
propvalue[0] = '\0';
ASSERT_EQ(-1, __system_property_set(property_name.c_str(), long_value.c_str()));
ASSERT_EQ(6, __system_property_get(property_name.c_str(), propvalue));
ASSERT_STREQ("value1", propvalue);
// Check that read() for long names still works but returns truncated version of the name
pi = __system_property_find(property_name.c_str());
ASSERT_TRUE(pi != nullptr); char legacy_name[PROP_NAME_MAX];
expected_name = std::string(property_name.c_str(), PROP_NAME_MAX-1);
ASSERT_EQ(8, __system_property_read(pi, &legacy_name[0], propvalue));
ASSERT_EQ(expected_name, legacy_name);
ASSERT_STREQ("value1-1", propvalue);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.