forked from OSchip/llvm-project
[Sanitizer] Allow runtime flags be separated by colon as well as space
llvm-svn: 175511
This commit is contained in:
parent
76dc3a81ea
commit
99b81b4bbe
|
@ -38,7 +38,8 @@ static bool GetFlagValue(const char *env, const char *name,
|
||||||
pos += 1;
|
pos += 1;
|
||||||
end = internal_strchr(pos, '\'');
|
end = internal_strchr(pos, '\'');
|
||||||
} else {
|
} else {
|
||||||
end = internal_strchr(pos, ' ');
|
// Read until the next space or colon.
|
||||||
|
end = pos + internal_strcspn(pos, " :");
|
||||||
}
|
}
|
||||||
if (end == 0)
|
if (end == 0)
|
||||||
end = pos + internal_strlen(pos);
|
end = pos + internal_strlen(pos);
|
||||||
|
|
|
@ -32,7 +32,7 @@ static void TestStrFlag(const char *start_value, const char *env,
|
||||||
const char *final_value) {
|
const char *final_value) {
|
||||||
const char *flag = start_value;
|
const char *flag = start_value;
|
||||||
ParseFlag(env, &flag, kFlagName);
|
ParseFlag(env, &flag, kFlagName);
|
||||||
EXPECT_EQ(internal_strcmp(final_value, flag), 0);
|
EXPECT_EQ(0, internal_strcmp(final_value, flag));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(SanitizerCommon, BooleanFlags) {
|
TEST(SanitizerCommon, BooleanFlags) {
|
||||||
|
@ -65,4 +65,21 @@ TEST(SanitizerCommon, StrFlags) {
|
||||||
TestStrFlag("", "--flag_name=\"abc qwe\" asd", "abc qwe");
|
TestStrFlag("", "--flag_name=\"abc qwe\" asd", "abc qwe");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void TestTwoFlags(const char *env, bool expected_flag1,
|
||||||
|
const char *expected_flag2) {
|
||||||
|
bool flag1 = !expected_flag1;
|
||||||
|
const char *flag2 = "";
|
||||||
|
ParseFlag(env, &flag1, "flag1");
|
||||||
|
ParseFlag(env, &flag2, "flag2");
|
||||||
|
EXPECT_EQ(expected_flag1, flag1);
|
||||||
|
EXPECT_EQ(0, internal_strcmp(flag2, expected_flag2));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SanitizerCommon, MultipleFlags) {
|
||||||
|
TestTwoFlags("flag1=1 flag2='zzz'", true, "zzz");
|
||||||
|
TestTwoFlags("flag2='qxx' flag1=0", false, "qxx");
|
||||||
|
TestTwoFlags("flag1=false:flag2='zzz'", false, "zzz");
|
||||||
|
TestTwoFlags("flag2=qxx:flag1=yes", true, "qxx");
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace __sanitizer
|
} // namespace __sanitizer
|
||||||
|
|
Loading…
Reference in New Issue