test-dns-domain.c revision 54adabf727fbcf1a4f49b59362e92b79da1082f1
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering This file is part of systemd.
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering Copyright 2014 Lennart Poettering
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering systemd is free software; you can redistribute it and/or modify it
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering under the terms of the GNU Lesser General Public License as published by
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering (at your option) any later version.
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering systemd is distributed in the hope that it will be useful, but
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering Lesser General Public License for more details.
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering You should have received a copy of the GNU Lesser General Public License
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_label_unescape_one(const char *what, const char *expect, size_t buffer_sz, int ret) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering r = dns_label_unescape(&what, buffer, buffer_sz);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_label_unescape(void) {
0171da06ef8bb19c175c5aa8aff8cf95f3de7dc1Lennart Poettering test_dns_label_unescape_one("hallo", "hallo", 6, 5);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_one("hallo", "hallo", 4, -ENOSPC);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_one("", "", 10, 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_one("hallo\\.foobar", "hallo.foobar", 20, 12);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_one("hallo.foobar", "hallo", 10, 5);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_one("hallo\n.foobar", "hallo", 20, -EINVAL);
0171da06ef8bb19c175c5aa8aff8cf95f3de7dc1Lennart Poettering test_dns_label_unescape_one("hallo\\", "hallo", 20, -EINVAL);
0171da06ef8bb19c175c5aa8aff8cf95f3de7dc1Lennart Poettering test_dns_label_unescape_one("hallo\\032 ", "hallo ", 20, 7);
0171da06ef8bb19c175c5aa8aff8cf95f3de7dc1Lennart Poettering test_dns_label_unescape_one(".", "", 20, 0);
0171da06ef8bb19c175c5aa8aff8cf95f3de7dc1Lennart Poettering test_dns_label_unescape_one("..", "", 20, -EINVAL);
0171da06ef8bb19c175c5aa8aff8cf95f3de7dc1Lennart Poettering test_dns_label_unescape_one(".foobar", "", 20, -EINVAL);
0171da06ef8bb19c175c5aa8aff8cf95f3de7dc1Lennart Poettering test_dns_label_unescape_one("foobar.", "foobar", 20, 6);
0171da06ef8bb19c175c5aa8aff8cf95f3de7dc1Lennart Poetteringstatic void test_dns_name_to_wire_format_one(const char *what, const char *expect, size_t buffer_sz, int ret) {
0171da06ef8bb19c175c5aa8aff8cf95f3de7dc1Lennart Poettering r = dns_name_to_wire_format(what, buffer, buffer_sz);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_name_to_wire_format(void) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering const char out1[] = { 3, 'f', 'o', 'o', 0 };
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering const char out2[] = { 5, 'h', 'a', 'l', 'l', 'o', 3, 'f', 'o', 'o', 3, 'b', 'a', 'r', 0 };
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering const char out3[] = { 4, ' ', 'f', 'o', 'o', 3, 'b', 'a', 'r', 0 };
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_to_wire_format_one("", NULL, 0, -EINVAL);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_to_wire_format_one("foo", out1, sizeof(out1), sizeof(out1));
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_to_wire_format_one("foo", out1, sizeof(out1) + 1, sizeof(out1));
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_to_wire_format_one("foo", out1, sizeof(out1) - 1, -ENOBUFS);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_to_wire_format_one("hallo.foo.bar", out2, sizeof(out2), sizeof(out2));
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_to_wire_format_one("hallo.foo..bar", NULL, 32, -EINVAL);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_to_wire_format_one("\\032foo.bar", out3, sizeof(out3), sizeof(out3));
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_label_unescape_suffix_one(const char *what, const char *expect1, const char *expect2, size_t buffer_sz, int ret1, int ret2) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering r = dns_label_unescape_suffix(what, &label, buffer, buffer_sz);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering r = dns_label_unescape_suffix(what, &label, buffer, buffer_sz);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_label_unescape_suffix(void) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one("hallo", "hallo", "", 6, 5, 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one("hallo", "hallo", "", 4, -ENOSPC, -ENOSPC);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one("", "", "", 10, 0, 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one("hallo\\.foobar", "hallo.foobar", "", 20, 12, 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one("hallo.foobar", "foobar", "hallo", 10, 6, 5);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one("hallo.foobar\n", "foobar", "foobar", 20, -EINVAL, -EINVAL);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one("hallo\\", "hallo", "hallo", 20, -EINVAL, -EINVAL);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one("hallo\\032 ", "hallo ", "", 20, 7, 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one(".", "", "", 20, 0, 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one("..", "", "", 20, 0, 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one(".foobar", "foobar", "", 20, 6, -EINVAL);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one("foobar.", "", "foobar", 20, 0, 6);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one("foo\\\\bar", "foo\\bar", "", 20, 7, 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one("foo.bar", "bar", "foo", 20, 3, 3);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one("foo..bar", "bar", "", 20, 3, -EINVAL);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one("foo...bar", "bar", "", 20, 3, -EINVAL);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one("foo\\.bar", "foo.bar", "", 20, 7, 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one("foo\\\\.bar", "bar", "foo\\", 20, 3, 4);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_unescape_suffix_one("foo\\\\\\.bar", "foo\\.bar", "", 20, 8, 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_label_escape_one(const char *what, size_t l, const char *expect, int ret) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_label_escape(void) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_escape_one("hallo", 5, "hallo", 5);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_escape_one("hallo", 6, NULL, -EINVAL);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_label_escape_one("hallo hallo.foobar,waldi", 24, "hallo\\032hallo\\.foobar\\044waldi", 31);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_name_normalize_one(const char *what, const char *expect, int ret) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_name_normalize(void) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_normalize_one("f", "f", 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_normalize_one("f.waldi", "f.waldi", 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_normalize_one("f \\032.waldi", "f\\032\\032.waldi", 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_normalize_one("\\000", NULL, -EINVAL);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_normalize_one("..", NULL, -EINVAL);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_normalize_one(".foobar", NULL, -EINVAL);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_normalize_one("foobar.", "foobar", 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_name_equal_one(const char *a, const char *b, int ret) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_name_equal(void) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_equal_one("x", "x.", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_equal_one("abc.def", "abc.def", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_equal_one("abc.def", "ABC.def", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_equal_one("abc.def", "CBA.def", false);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_equal_one("", "xxx", false);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_equal_one("ab", "a", false);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_equal_one("\\000", "xxxx", -EINVAL);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_equal_one("..", "..", -EINVAL);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_name_between_one(const char *a, const char *b, const char *c, int ret) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_name_between(void) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering /* see https://tools.ietf.org/html/rfc4034#section-6.1
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering Note that we use "\033.z.example" in stead of "\001.z.example" as we
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering consider the latter invalid */
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_between_one("example", "a.example", "yljkjljk.a.example", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_between_one("a.example", "yljkjljk.a.example", "Z.a.example", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_between_one("yljkjljk.a.example", "Z.a.example", "zABC.a.EXAMPLE", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_between_one("Z.a.example", "zABC.a.EXAMPLE", "z.example", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_between_one("zABC.a.EXAMPLE", "z.example", "\\033.z.example", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_between_one("z.example", "\\033.z.example", "*.z.example", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_between_one("\\033.z.example", "*.z.example", "\\200.z.example", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_between_one("*.z.example", "\\200.z.example", "example", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_between_one("\\200.z.example", "example", "a.example", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_between_one("example", "a.example", "example", -EINVAL);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_between_one("example", "example", "yljkjljk.a.example", false);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_between_one("example", "yljkjljk.a.example", "yljkjljk.a.example", false);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_name_endswith_one(const char *a, const char *b, int ret) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering assert_se(dns_name_endswith(a, b) == ret);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_name_endswith(void) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_endswith_one("", "", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_endswith_one("", "xxx", false);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_endswith_one("xxx", "", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_endswith_one("x", "x", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_endswith_one("x", "y", false);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_endswith_one("x.y", "y", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_endswith_one("x.y", "Y", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_endswith_one("x.y", "x", false);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_endswith_one("x.y.z", "Z", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_endswith_one("x.y.z", "y.Z", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_endswith_one("x.y.z", "x.y.Z", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_endswith_one("x.y.z", "waldo", false);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_endswith_one("x.y.z.u.v.w", "y.z", false);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_endswith_one("x.y.z.u.v.w", "u.v.w", true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_endswith_one("x.y\001.z", "waldo", -EINVAL);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_name_root(void) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering assert_se(dns_name_root("xxx") == false);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering assert_se(dns_name_root("xxx.") == false);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering assert_se(dns_name_root("..") == -EINVAL);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_name_single_label(void) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering assert_se(dns_name_single_label("") == false);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering assert_se(dns_name_single_label(".") == false);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering assert_se(dns_name_single_label("..") == -EINVAL);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering assert_se(dns_name_single_label("x") == true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering assert_se(dns_name_single_label("x.") == true);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering assert_se(dns_name_single_label("xx.yy") == false);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_name_reverse_one(const char *address, const char *name) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering union in_addr_union a, b = {};
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering assert_se(in_addr_from_string_auto(address, &familya, &a) >= 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering assert_se(dns_name_reverse(familya, &a, &p) >= 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering assert_se(dns_name_address(p, &familyb, &b) > 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering assert_se(in_addr_equal(familya, &a, &b));
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_name_reverse(void) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_reverse_one("47.11.8.15", "15.8.11.47.in-addr.arpa");
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_reverse_one("fe80::47", "7.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa");
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_reverse_one("127.0.0.1", "1.0.0.127.in-addr.arpa");
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_reverse_one("::1", "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa");
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_name_concat_one(const char *a, const char *b, int r, const char *result) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering assert_se(dns_name_concat(a, b, &p) == r);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_name_concat(void) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_concat_one("foo", "bar", 0, "foo.bar");
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_concat_one("foo.foo", "bar.bar", 0, "foo.foo.bar.bar");
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_concat_one("foo", NULL, 0, "foo");
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_concat_one("foo.", "bar.", 0, "foo.bar");
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_name_is_valid_one(const char *s, int ret) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poetteringstatic void test_dns_name_is_valid(void) {
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_is_valid_one("foo.bar", 1);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_is_valid_one("foo.bar.baz", 1);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_is_valid_one("foo..bar", 0);
a1ad376761af16da46c9ad90fd8df41c8c5c0976Lennart Poettering test_dns_name_is_valid_one(".foo.bar", 0);