From: Tim Kourt <tim.a.kourt@linux.intel.com>
To: iwd@lists.01.org
Subject: [PATCH 3/4] unit: Add tests for net
Date: Wed, 11 Dec 2019 15:08:56 -0800 [thread overview]
Message-ID: <20191211230857.20606-3-tim.a.kourt@linux.intel.com> (raw)
In-Reply-To: <20191211230857.20606-1-tim.a.kourt@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 3237 bytes --]
---
Makefile.am | 5 ++++-
unit/test-net.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+), 1 deletion(-)
create mode 100644 unit/test-net.c
diff --git a/Makefile.am b/Makefile.am
index ead9fd5..3ead678 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -178,7 +178,8 @@ unit_tests = unit/test-unit \
unit/test-ecc \
unit/test-ecdh \
unit/test-time \
- unit/test-path
+ unit/test-path \
+ unit/test-net
dbus_tests = unit/test-hwdb \
unit/test-dbus \
@@ -304,6 +305,8 @@ unit_test_time_LDADD = ell/libell-private.la
unit_test_path_LDADD = ell/libell-private.la
+unit_test_net_LDADD = ell/libell-private.la
+
if MAINTAINER_MODE
noinst_LTLIBRARIES += unit/example-plugin.la
endif
diff --git a/unit/test-net.c b/unit/test-net.c
new file mode 100644
index 0000000..2f7bf48
--- /dev/null
+++ b/unit/test-net.c
@@ -0,0 +1,66 @@
+/*
+ *
+ * Embedded Linux library
+ *
+ * Copyright (C) 2019 Intel Corporation. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it 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.
+ *
+ * This library 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 this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <assert.h>
+
+#include <ell/ell.h>
+
+static void test_net_hostname_is_localhost(const void *data)
+{
+ assert(l_net_hostname_is_localhost("localhost"));
+ assert(l_net_hostname_is_localhost("localhost."));
+ assert(l_net_hostname_is_localhost("localhost.localdomain"));
+ assert(l_net_hostname_is_localhost("localhost.localdomain."));
+ assert(l_net_hostname_is_localhost("other.localhost"));
+ assert(l_net_hostname_is_localhost("other.localhost."));
+ assert(l_net_hostname_is_localhost("other.localhost.localdomain"));
+ assert(l_net_hostname_is_localhost("other.localhost.localdomain."));
+
+ assert(l_net_hostname_is_localhost("LOCALHOST"));
+
+ assert(!l_net_hostname_is_localhost("notsolocalhost"));
+ assert(!l_net_hostname_is_localhost("localhost.com"));
+ assert(!l_net_hostname_is_localhost(""));
+}
+
+static void test_net_hostname_is_root(const void *data)
+{
+ assert(l_net_hostname_is_root(""));
+ assert(l_net_hostname_is_root("."));
+ assert(!l_net_hostname_is_root("notsoroot"));
+}
+
+int main(int argc, char *argv[])
+{
+ l_test_init(&argc, &argv);
+
+ l_test_add("net/hostname_is_localhost", test_net_hostname_is_localhost,
+ NULL);
+ l_test_add("net/hostname_is_root", test_net_hostname_is_root,
+ NULL);
+
+ return l_test_run();
+}
--
2.13.6
next prev parent reply other threads:[~2019-12-11 23:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-11 23:08 [PATCH 1/4] net: Add l_net_hostname_is_root Tim Kourt
2019-12-11 23:08 ` [PATCH 2/4] net: Add l_net_hostname_is_localhost Tim Kourt
2019-12-11 23:08 ` Tim Kourt [this message]
2019-12-11 23:08 ` [PATCH 4/4] dhcp-lease: Add domain name option handler Tim Kourt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191211230857.20606-3-tim.a.kourt@linux.intel.com \
--to=tim.a.kourt@linux.intel.com \
--cc=iwd@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox