changeset 804:59316ed46006

tests: add xhostname test It only prints the hostname, but even that is useful enough. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Fri, 10 Apr 2020 11:57:07 -0400
parents 32d261e8b47f
children 6e72f4b462c8
files tests/.hgignore tests/CMakeLists.txt tests/test_hostname.c
diffstat 3 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/.hgignore	Fri Mar 15 11:42:40 2019 -0400
+++ b/tests/.hgignore	Fri Apr 10 11:57:07 2020 -0400
@@ -14,6 +14,7 @@
 test_endian
 test_errno
 test_hexdump
+test_hostname
 test_is_p2
 test_list
 test_mutex-destroy-held
--- a/tests/CMakeLists.txt	Fri Mar 15 11:42:40 2019 -0400
+++ b/tests/CMakeLists.txt	Fri Apr 10 11:57:07 2020 -0400
@@ -40,6 +40,7 @@
 build_test_bin_and_run(endian)
 build_test_bin_and_run(errno)
 build_test_bin_and_run(hexdump)
+build_test_bin_and_run(hostname)
 build_test_bin_and_run(is_p2)
 build_test_bin_and_run(list)
 build_test_bin_and_run(mutex-destroy-memcpy)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_hostname.c	Fri Apr 10 11:57:07 2020 -0400
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/sock.h>
+
+#include "test.c"
+
+void test(void)
+{
+	fprintf(stderr, "hostname = %s\n", xgethostname());
+}