summaryrefslogtreecommitdiffstats
path: root/src/test/test-dns-domain.c
diff options
context:
space:
mode:
authorDmitry Rozhkov <dmitry.rozhkov@linux.intel.com>2017-10-10 14:58:45 +0200
committerDmitry Rozhkov <dmitry.rozhkov@linux.intel.com>2017-12-08 13:29:27 +0100
commit154ae08781aaba9ea30c2ec8f396c7898332ffca (patch)
treeb8a7b5bfa5b84974c5bcfff688e51bbf279cad34 /src/test/test-dns-domain.c
parentresolved: answer all mDNS questions found in packet (diff)
downloadsystemd-154ae08781aaba9ea30c2ec8f396c7898332ffca.tar.xz
systemd-154ae08781aaba9ea30c2ec8f396c7898332ffca.zip
shared: introduce dnssd_srv_type_is_valid() function
Diffstat (limited to 'src/test/test-dns-domain.c')
-rw-r--r--src/test/test-dns-domain.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/test-dns-domain.c b/src/test/test-dns-domain.c
index 5f669df051..3105c14ee6 100644
--- a/src/test/test-dns-domain.c
+++ b/src/test/test-dns-domain.c
@@ -427,6 +427,30 @@ static void test_dns_srv_type_is_valid(void) {
assert_se(!dns_srv_type_is_valid("_piep._foo._udp"));
}
+static void test_dnssd_srv_type_is_valid(void) {
+
+ assert_se(dnssd_srv_type_is_valid("_http._tcp"));
+ assert_se(dnssd_srv_type_is_valid("_foo-bar._tcp"));
+ assert_se(dnssd_srv_type_is_valid("_w._udp"));
+ assert_se(dnssd_srv_type_is_valid("_a800._tcp"));
+ assert_se(dnssd_srv_type_is_valid("_a-800._tcp"));
+
+ assert_se(!dnssd_srv_type_is_valid(NULL));
+ assert_se(!dnssd_srv_type_is_valid(""));
+ assert_se(!dnssd_srv_type_is_valid("x"));
+ assert_se(!dnssd_srv_type_is_valid("_foo"));
+ assert_se(!dnssd_srv_type_is_valid("_tcp"));
+ assert_se(!dnssd_srv_type_is_valid("_"));
+ assert_se(!dnssd_srv_type_is_valid("_foo."));
+ assert_se(!dnssd_srv_type_is_valid("_föo._tcp"));
+ assert_se(!dnssd_srv_type_is_valid("_f\no._tcp"));
+ assert_se(!dnssd_srv_type_is_valid("_800._tcp"));
+ assert_se(!dnssd_srv_type_is_valid("_-800._tcp"));
+ assert_se(!dnssd_srv_type_is_valid("_-foo._tcp"));
+ assert_se(!dnssd_srv_type_is_valid("_piep._foo._udp"));
+ assert_se(!dnssd_srv_type_is_valid("_foo._unknown"));
+}
+
static void test_dns_service_join_one(const char *a, const char *b, const char *c, int r, const char *d) {
_cleanup_free_ char *x = NULL, *y = NULL, *z = NULL, *t = NULL;
@@ -699,6 +723,7 @@ int main(int argc, char *argv[]) {
test_dns_name_to_wire_format();
test_dns_service_name_is_valid();
test_dns_srv_type_is_valid();
+ test_dnssd_srv_type_is_valid();
test_dns_service_join();
test_dns_service_split();
test_dns_name_change_suffix();