If the first option is found, then any unknown options are simply
ignored, but do not produce an error. Fixed this so that each
option found is actually verified to exist.
Bug:
27620263
(cherry picked from commit
a4b14252752d14454afb48feb3272e8689e3a66d)
Change-Id: I709774456283879e2a8aa5ce375899eaa79f6bc3
size_t value;
bool value_set;
PropertyParser parser(property_str);
- bool found = false;
bool valid = true;
while (valid && parser.Get(&property, &value, &value_set)) {
+ bool found = false;
for (size_t i = 0; i < sizeof(features)/sizeof(Feature); i++) {
if (property == features[i].name) {
if (features[i].option == 0 && features[i].combo_option) {
ASSERT_STREQ((log_msg + usage_string).c_str(), getFakeLogPrint().c_str());
}
+TEST_F(MallocDebugConfigTest, good_option_and_bad_option) {
+ ASSERT_FALSE(InitConfig("backtrace unknown_option"));
+
+ ASSERT_STREQ("", getFakeLogBuf().c_str());
+ std::string log_msg("6 malloc_debug malloc_testing: unknown option unknown_option\n");
+ ASSERT_STREQ((log_msg + usage_string).c_str(), getFakeLogPrint().c_str());
+}
+
TEST_F(MallocDebugConfigTest, unparseable_number) {
ASSERT_FALSE(InitConfig("backtrace=XXX"));