test-dns-domain.c revision 58db254ade4fb2ef77de68f28c4f13814819f6a1
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2014 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include "alloc-util.h"
#include "dns-domain.h"
#include "macro.h"
#include "string-util.h"
static void test_dns_label_unescape_one(const char *what, const char *expect, size_t buffer_sz, int ret) {
int r;
if (r < 0)
return;
}
static void test_dns_label_unescape(void) {
}
static void test_dns_name_to_wire_format_one(const char *what, const char *expect, size_t buffer_sz, int ret) {
int r;
if (r < 0)
return;
}
static void test_dns_name_to_wire_format(void) {
}
static void test_dns_label_unescape_suffix_one(const char *what, const char *expect1, const char *expect2, size_t buffer_sz, int ret1, int ret2) {
const char *label;
int r;
if (r >= 0)
if (r >= 0)
}
static void test_dns_label_unescape_suffix(void) {
}
_cleanup_free_ char *t = NULL;
int r;
r = dns_label_escape(what, l, &t);
if (r < 0)
return;
}
static void test_dns_label_escape(void) {
test_dns_label_escape_one("hallo hallo.foobar,waldi", 24, "hallo\\032hallo\\.foobar\\044waldi", 31);
}
_cleanup_free_ char *t = NULL;
int r;
r = dns_name_normalize(what, &t);
if (r < 0)
return;
}
static void test_dns_name_normalize(void) {
}
static void test_dns_name_equal_one(const char *a, const char *b, int ret) {
int r;
r = dns_name_equal(a, b);
r = dns_name_equal(b, a);
}
static void test_dns_name_equal(void) {
}
static void test_dns_name_between_one(const char *a, const char *b, const char *c, int ret) {
int r;
r = dns_name_between(a, b, c);
r = dns_name_between(c, b, a);
if (ret >= 0)
assert_se(r == 0);
else
}
static void test_dns_name_between(void) {
/* see https://tools.ietf.org/html/rfc4034#section-6.1
Note that we use "\033.z.example" in stead of "\001.z.example" as we
consider the latter invalid */
}
static void test_dns_name_endswith_one(const char *a, const char *b, int ret) {
}
static void test_dns_name_endswith(void) {
}
static void test_dns_name_root(void) {
}
static void test_dns_name_single_label(void) {
}
_cleanup_free_ char *p = NULL;
union in_addr_union a, b = {};
}
static void test_dns_name_reverse(void) {
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");
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");
}
static void test_dns_name_concat_one(const char *a, const char *b, int r, const char *result) {
_cleanup_free_ char *p = NULL;
assert_se(dns_name_concat(a, b, &p) == r);
}
static void test_dns_name_concat(void) {
}
static void test_dns_name_is_valid_one(const char *s, int ret) {
}
static void test_dns_name_is_valid(void) {
test_dns_name_is_valid_one("foo..bar", 0);
test_dns_name_is_valid_one(".foo.bar", 0);
test_dns_name_is_valid_one("\\zbar", 0);
test_dns_name_is_valid_one("\n", 0);
}
static void test_dns_service_name_is_valid(void) {
assert_se(!dns_service_name_is_valid("this is an overly long string that is certainly longer than 63 characters"));
}
static void test_dns_srv_type_verify(void) {
}
static void test_dns_service_join_one(const char *a, const char *b, const char *c, int r, const char *d) {
assert_se(dns_service_join(a, b, c, &t) == r);
if (r < 0)
return;
assert_se(dns_service_split(t, &x, &y, &z) >= 0);
}
static void test_dns_service_join(void) {
test_dns_service_join_one("Lennart's PC", "_pc._tcp", "foo.bar.com", 0, "Lennart\\039s\\032PC._pc._tcp.foo.bar.com");
}
static void test_dns_service_split_one(const char *joined, const char *a, const char *b, const char *c, int r) {
if (r < 0)
return;
if (y) {
assert_se(dns_service_join(x, y, z, &t) == 0);
} else
}
static void test_dns_service_split(void) {
test_dns_service_split_one("Wuff\\032Wuff._foo._bar.waldo.com", "Wuff Wuff", "_foo._bar", "waldo.com", 0);
}
static void test_dns_name_change_suffix_one(const char *name, const char *old_suffix, const char *new_suffix, int r, const char *result) {
_cleanup_free_ char *s = NULL;
}
static void test_dns_name_change_suffix(void) {
test_dns_name_change_suffix_one("foo.bar.waldi.quux", "foo.bar.waldi.quux", "piff.paff", 1, "piff.paff");
test_dns_name_change_suffix_one("foo.bar.waldi.quux", "bar.waldi.quux", "piff.paff", 1, "foo.piff.paff");
test_dns_name_change_suffix_one("foo.bar.waldi.quux", "waldi.quux", "piff.paff", 1, "foo.bar.piff.paff");
test_dns_name_change_suffix_one("foo.bar.waldi.quux", "quux", "piff.paff", 1, "foo.bar.waldi.piff.paff");
test_dns_name_change_suffix_one("foo.bar.waldi.quux", "", "piff.paff", 1, "foo.bar.waldi.quux.piff.paff");
}
return 0;
}