diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-06-27 22:03:02 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-07-01 01:24:42 +0900 |
commit | f706340979a7046136714e7321242c2858f3fcd4 (patch) | |
tree | eb406da338100072e1495f5da3b02d1055fbc87a | |
parent | c382025adf1e5ee15455f1b2b2f0b961c48f13d7 (diff) | |
download | systemd-f706340979a7046136714e7321242c2858f3fcd4.tar.gz |
test: add tests for config_parse_match_{strv,ifnames}()
-rw-r--r-- | src/network/test-networkd-conf.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/network/test-networkd-conf.c b/src/network/test-networkd-conf.c index 4b599c430b..07ca127654 100644 --- a/src/network/test-networkd-conf.c +++ b/src/network/test-networkd-conf.c @@ -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; } |