test: add tests for config_parse_match_{strv,ifnames}()

This commit is contained in:
Yu Watanabe 2019-06-27 22:03:02 +09:00
parent c382025adf
commit f706340979
1 changed files with 23 additions and 0 deletions

View File

@ -215,6 +215,27 @@ static void test_config_parse_address(void) {
test_config_parse_address_one("::1/-1", AF_INET6, 0, NULL, 0);
}
static void test_config_parse_match_ifnames(void) {
_cleanup_strv_free_ char **names = NULL;
assert_se(config_parse_match_ifnames("network", "filename", 1, "section", 1, "Name", 0, "!hoge hogehoge foo", &names, NULL) == 0);
assert_se(config_parse_match_ifnames("network", "filename", 1, "section", 1, "Name", 0, "!baz", &names, NULL) == 0);
assert_se(config_parse_match_ifnames("network", "filename", 1, "section", 1, "Name", 0, "aaa bbb ccc", &names, NULL) == 0);
strv_equal(names, STRV_MAKE("!hoge", "!hogehoge", "!foo", "!baz", "aaa", "bbb", "ccc"));
}
static void test_config_parse_match_strv(void) {
_cleanup_strv_free_ char **names = NULL;
assert_se(config_parse_match_strv("network", "filename", 1, "section", 1, "Name", 0, "!hoge hogehoge foo", &names, NULL) == 0);
assert_se(config_parse_match_strv("network", "filename", 1, "section", 1, "Name", 0, "!baz", &names, NULL) == 0);
assert_se(config_parse_match_strv("network", "filename", 1, "section", 1, "Name", 0,
"KEY=val \"KEY2=val with space\" \"KEY3=val with \\\"quotation\\\"\"", &names, NULL) == 0);
strv_equal(names, STRV_MAKE("!hoge", "!hogehoge", "!foo", "!baz", "KEY=val", "KEY2=val with space", "KEY3=val with \"quotation\""));
}
int main(int argc, char **argv) {
log_parse_environment();
log_open();
@ -223,6 +244,8 @@ int main(int argc, char **argv) {
test_config_parse_duid_rawdata();
test_config_parse_hwaddr();
test_config_parse_address();
test_config_parse_match_ifnames();
test_config_parse_match_strv();
return 0;
}