summaryrefslogtreecommitdiffstats
path: root/testsuites
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2023-04-18 16:08:04 +1000
committerChris Johns <chrisj@rtems.org>2023-04-20 15:27:18 +1000
commit6b9c8b4e8d9d1fa603c54b146e8a6f51fe5ff79f (patch)
tree27ddb73ab5d5b13b7c6a27d1cf64a748da42769b /testsuites
parentrtems: Fix incorect header guard and white spaces (diff)
downloadrtems-net-legacy-6b9c8b4e8d9d1fa603c54b146e8a6f51fe5ff79f.tar.bz2
bsd: Add getaddrinfom, gai_strerror, ipv6_addr, if_nametoindex and BSD programs
- These additions let the net services repo build with the legacy stack
Diffstat (limited to 'testsuites')
-rw-r--r--testsuites/resolve/getaddrinfo_test.c573
-rw-r--r--testsuites/resolve/init.c176
-rw-r--r--testsuites/resolve/resolve.doc11
-rw-r--r--testsuites/resolve/resolve.scn166
-rw-r--r--testsuites/resolve/wscript49
-rw-r--r--testsuites/wscript2
6 files changed, 976 insertions, 1 deletions
diff --git a/testsuites/resolve/getaddrinfo_test.c b/testsuites/resolve/getaddrinfo_test.c
new file mode 100644
index 0000000..6674c3c
--- /dev/null
+++ b/testsuites/resolve/getaddrinfo_test.c
@@ -0,0 +1,573 @@
+/*-
+ * Copyright (c) 2006 Michael Bushkov <bushman@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <errno.h>
+#include <netdb.h>
+#include <resolv.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifndef __rtems__
+#include <stringlist.h>
+#endif /* __rtems__ */
+#include <unistd.h>
+
+#ifndef __rtems__
+#include <atf-c.h>
+
+#include "freebsd_test_suite/macros.h"
+#include "testutil.h"
+#endif /* __rtems__ */
+
+enum test_methods {
+ TEST_GETADDRINFO,
+ TEST_BUILD_SNAPSHOT
+};
+
+static struct addrinfo hints;
+static enum test_methods method = TEST_GETADDRINFO;
+
+#ifndef __rtems__
+DECLARE_TEST_DATA(addrinfo)
+DECLARE_TEST_FILE_SNAPSHOT(addrinfo)
+DECLARE_2PASS_TEST(addrinfo)
+#endif /* __rtems__ */
+
+static void clone_addrinfo(struct addrinfo *, struct addrinfo const *);
+static int compare_addrinfo(struct addrinfo *, struct addrinfo *, void *);
+static void dump_addrinfo(struct addrinfo *);
+
+static void sdump_addrinfo(struct addrinfo *, char *, size_t);
+
+#ifndef __rtems__
+IMPLEMENT_TEST_DATA(addrinfo)
+IMPLEMENT_TEST_FILE_SNAPSHOT(addrinfo)
+IMPLEMENT_2PASS_TEST(addrinfo)
+#else
+#include <assert.h>
+#define ATF_REQUIRE(e) assert(e)
+#define ATF_REQUIRE_MSG(e, f, ...) assert(e)
+#endif /* __rtems__ */
+
+static void
+clone_addrinfo(struct addrinfo *dest, struct addrinfo const *src)
+{
+
+ ATF_REQUIRE(dest != NULL);
+ ATF_REQUIRE(src != NULL);
+
+ memcpy(dest, src, sizeof(struct addrinfo));
+ if (src->ai_canonname != NULL)
+ dest->ai_canonname = strdup(src->ai_canonname);
+
+ if (src->ai_addr != NULL) {
+ dest->ai_addr = malloc(src->ai_addrlen);
+ ATF_REQUIRE(dest->ai_addr != NULL);
+ memcpy(dest->ai_addr, src->ai_addr, src->ai_addrlen);
+ }
+
+ if (src->ai_next != NULL) {
+ dest->ai_next = malloc(sizeof(struct addrinfo));
+ ATF_REQUIRE(dest->ai_next != NULL);
+ clone_addrinfo(dest->ai_next, src->ai_next);
+ }
+}
+
+static int
+compare_addrinfo_(struct addrinfo *ai1, struct addrinfo *ai2)
+{
+
+ if ((ai1 == NULL) || (ai2 == NULL))
+ return (-1);
+
+ if (ai1->ai_flags != ai2->ai_flags ||
+ ai1->ai_family != ai2->ai_family ||
+ ai1->ai_socktype != ai2->ai_socktype ||
+ ai1->ai_protocol != ai2->ai_protocol ||
+ ai1->ai_addrlen != ai2->ai_addrlen ||
+ ((ai1->ai_addr == NULL || ai2->ai_addr == NULL) &&
+ ai1->ai_addr != ai2->ai_addr) ||
+ ((ai1->ai_canonname == NULL || ai2->ai_canonname == NULL) &&
+ ai1->ai_canonname != ai2->ai_canonname))
+ return (-1);
+
+ if (ai1->ai_canonname != NULL &&
+ strcmp(ai1->ai_canonname, ai2->ai_canonname) != 0)
+ return (-1);
+
+ if (ai1->ai_addr != NULL &&
+ memcmp(ai1->ai_addr, ai2->ai_addr, ai1->ai_addrlen) != 0)
+ return (-1);
+
+ if (ai1->ai_next == NULL && ai2->ai_next == NULL)
+ return (0);
+ else
+ return (compare_addrinfo_(ai1->ai_next, ai2->ai_next));
+}
+
+static int
+compare_addrinfo(struct addrinfo *ai1, struct addrinfo *ai2,
+ void *mdata __unused)
+{
+ int rv;
+
+ printf("testing equality of 2 addrinfo structures\n");
+
+ rv = compare_addrinfo_(ai1, ai2);
+
+ if (rv == 0)
+ printf("equal\n");
+ else {
+ dump_addrinfo(ai1);
+ dump_addrinfo(ai2);
+ printf("not equal\n");
+ }
+
+ return (rv);
+}
+
+static void
+free_addrinfo(struct addrinfo *ai)
+{
+ if (ai == NULL)
+ return;
+
+ free(ai->ai_addr);
+ free(ai->ai_canonname);
+ free_addrinfo(ai->ai_next);
+}
+
+void
+sdump_addrinfo(struct addrinfo *ai, char *buffer, size_t buflen)
+{
+ int written, i;
+
+ written = snprintf(buffer, buflen, "%d %d %d %d %d ",
+ ai->ai_flags, ai->ai_family, ai->ai_socktype, ai->ai_protocol,
+ ai->ai_addrlen);
+ buffer += written;
+ if (written > (int)buflen)
+ return;
+ buflen -= written;
+
+ written = snprintf(buffer, buflen, "%s ",
+ ai->ai_canonname == NULL ? "(null)" : ai->ai_canonname);
+ buffer += written;
+ if (written > (int)buflen)
+ return;
+ buflen -= written;
+
+ if (ai->ai_addr == NULL) {
+ written = snprintf(buffer, buflen, "(null)");
+ buffer += written;
+ if (written > (int)buflen)
+ return;
+ buflen -= written;
+ } else {
+ for (i = 0; i < (int)ai->ai_addrlen; i++) {
+ written = snprintf(buffer, buflen,
+ i + 1 != (int)ai->ai_addrlen ? "%d." : "%d",
+ ((unsigned char *)ai->ai_addr)[i]);
+ buffer += written;
+ if (written > (int)buflen)
+ return;
+ buflen -= written;
+
+ if (buflen == 0)
+ return;
+ }
+ }
+
+ if (ai->ai_next != NULL) {
+ written = snprintf(buffer, buflen, ":");
+ buffer += written;
+ if (written > (int)buflen)
+ return;
+ buflen -= written;
+
+ sdump_addrinfo(ai->ai_next, buffer, buflen);
+ }
+}
+
+void
+dump_addrinfo(struct addrinfo *result)
+{
+ if (result != NULL) {
+ char buffer[2048];
+ sdump_addrinfo(result, buffer, sizeof(buffer));
+ printf("%s\n", buffer);
+ } else
+ printf("(null)\n");
+}
+
+static int
+addrinfo_read_snapshot_addr(char *addr, unsigned char *result, size_t len)
+{
+ char *s, *ps, *ts;
+
+ ps = addr;
+ while ((s = strsep(&ps, ".")) != NULL) {
+ if (len == 0)
+ return (-1);
+
+ *result = (unsigned char)strtol(s, &ts, 10);
+ ++result;
+ if (*ts != '\0')
+ return (-1);
+
+ --len;
+ }
+ if (len != 0)
+ return (-1);
+ else
+ return (0);
+}
+
+static int
+addrinfo_read_snapshot_ai(struct addrinfo *ai, char *line)
+{
+ char *s, *ps, *ts;
+ int i, rv, *pi;
+
+ rv = 0;
+ i = 0;
+ ps = line;
+ memset(ai, 0, sizeof(struct addrinfo));
+ while ((s = strsep(&ps, " ")) != NULL) {
+ switch (i) {
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ pi = &ai->ai_flags + i;
+ *pi = (int)strtol(s, &ts, 10);
+ if (*ts != '\0')
+ goto fin;
+ break;
+ case 4:
+ ai->ai_addrlen = (socklen_t)strtol(s, &ts, 10);
+ if (*ts != '\0')
+ goto fin;
+ break;
+ case 5:
+ if (strcmp(s, "(null)") != 0) {
+ ai->ai_canonname = strdup(s);
+ ATF_REQUIRE(ai->ai_canonname != NULL);
+ }
+ break;
+ case 6:
+ if (strcmp(s, "(null)") != 0) {
+ ai->ai_addr = calloc(1, ai->ai_addrlen);
+ ATF_REQUIRE(ai->ai_addr != NULL);
+ rv = addrinfo_read_snapshot_addr(s,
+ (unsigned char *)ai->ai_addr,
+ ai->ai_addrlen);
+
+ if (rv != 0)
+ goto fin;
+ }
+ break;
+ default:
+ /* NOTE: should not be reachable */
+ rv = -1;
+ goto fin;
+ }
+
+ ++i;
+ }
+
+fin:
+ if (i != 7 || rv != 0) {
+ free_addrinfo(ai);
+ ai = NULL;
+ return (-1);
+ }
+
+ return (0);
+}
+
+static int
+addrinfo_read_snapshot_func(struct addrinfo *ai, char *line)
+{
+ struct addrinfo *ai2;
+ char *s, *ps;
+ int rv;
+
+ printf("1 line read from snapshot:\n%s\n", line);
+
+ rv = 0;
+ ps = line;
+
+ s = strsep(&ps, ":");
+ if (s == NULL)
+ return (-1);
+
+ rv = addrinfo_read_snapshot_ai(ai, s);
+ if (rv != 0)
+ return (-1);
+
+ ai2 = ai;
+ while ((s = strsep(&ps, ":")) != NULL) {
+ ai2->ai_next = calloc(1, sizeof(struct addrinfo));
+ ATF_REQUIRE(ai2->ai_next != NULL);
+
+ rv = addrinfo_read_snapshot_ai(ai2->ai_next, s);
+ if (rv != 0) {
+ free_addrinfo(ai);
+ ai = NULL;
+ return (-1);
+ }
+
+ ai2 = ai2->ai_next;
+ }
+
+ return (0);
+}
+
+static int
+addrinfo_test_correctness(struct addrinfo *ai, void *mdata __unused)
+{
+
+ printf("testing correctness with the following data:\n");
+ dump_addrinfo(ai);
+
+ if (ai == NULL)
+ goto errfin;
+
+ if (!(ai->ai_family >= 0 && ai->ai_family < AF_MAX))
+ goto errfin;
+
+ if (ai->ai_socktype != 0 && ai->ai_socktype != SOCK_STREAM &&
+ ai->ai_socktype != SOCK_DGRAM && ai->ai_socktype != SOCK_RAW)
+ goto errfin;
+
+ if (ai->ai_protocol != 0 && ai->ai_protocol != IPPROTO_UDP &&
+ ai->ai_protocol != IPPROTO_TCP)
+ goto errfin;
+
+#ifndef __rtems__
+ if ((ai->ai_flags & ~(AI_CANONNAME | AI_NUMERICHOST | AI_PASSIVE)) != 0)
+ goto errfin;
+#endif /* __rtems__ */
+
+ if (ai->ai_addrlen != ai->ai_addr->sa_len ||
+ ai->ai_family != ai->ai_addr->sa_family)
+ goto errfin;
+
+ printf("correct\n");
+
+ return (0);
+errfin:
+ printf("incorrect\n");
+
+ return (-1);
+}
+
+int
+addrinfo_read_hostlist_func(struct addrinfo *ai, char *line)
+{
+ struct addrinfo *result;
+ int rv;
+
+ printf("resolving %s: ", line);
+ rv = getaddrinfo(line, NULL, &hints, &result);
+ if (rv == 0) {
+ printf("found\n");
+
+ rv = addrinfo_test_correctness(result, NULL);
+ if (rv != 0) {
+ freeaddrinfo(result);
+ result = NULL;
+ return (rv);
+ }
+
+ clone_addrinfo(ai, result);
+ freeaddrinfo(result);
+ result = NULL;
+ } else {
+ printf("not found\n");
+
+ memset(ai, 0, sizeof(struct addrinfo));
+ }
+ return (0);
+}
+
+#ifndef __rtems__
+void
+run_tests(char *hostlist_file, const char *snapshot_file, int ai_family)
+{
+ struct addrinfo_test_data td, td_snap;
+ char *snapshot_file_copy;
+ int rv;
+
+ if (snapshot_file == NULL)
+ snapshot_file_copy = NULL;
+ else {
+ snapshot_file_copy = strdup(snapshot_file);
+ ATF_REQUIRE(snapshot_file_copy != NULL);
+ }
+
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = ai_family;
+ hints.ai_flags = AI_CANONNAME;
+
+ if (snapshot_file != NULL)
+ method = TEST_BUILD_SNAPSHOT;
+
+ TEST_DATA_INIT(addrinfo, &td, clone_addrinfo, free_addrinfo);
+ TEST_DATA_INIT(addrinfo, &td_snap, clone_addrinfo, free_addrinfo);
+
+ ATF_REQUIRE_MSG(access(hostlist_file, R_OK) == 0,
+ "can't access the hostlist file %s\n", hostlist_file);
+
+ printf("building host lists from %s\n", hostlist_file);
+
+ rv = TEST_SNAPSHOT_FILE_READ(addrinfo, hostlist_file, &td,
+ addrinfo_read_hostlist_func);
+ if (rv != 0)
+ goto fin;
+
+ if (snapshot_file != NULL) {
+ if (access(snapshot_file, W_OK | R_OK) != 0) {
+ if (errno == ENOENT)
+ method = TEST_BUILD_SNAPSHOT;
+ else {
+ printf("can't access the snapshot "
+ "file %s\n", snapshot_file);
+
+ rv = -1;
+ goto fin;
+ }
+ } else {
+ rv = TEST_SNAPSHOT_FILE_READ(addrinfo, snapshot_file,
+ &td_snap, addrinfo_read_snapshot_func);
+ if (rv != 0) {
+ printf("error reading snapshot file: %s\n",
+ strerror(errno));
+ goto fin;
+ }
+ }
+ }
+
+ switch (method) {
+ case TEST_GETADDRINFO:
+ if (snapshot_file != NULL)
+ ATF_CHECK(DO_2PASS_TEST(addrinfo, &td, &td_snap,
+ compare_addrinfo, NULL) == 0);
+ break;
+ case TEST_BUILD_SNAPSHOT:
+ if (snapshot_file != NULL) {
+ ATF_CHECK(TEST_SNAPSHOT_FILE_WRITE(addrinfo,
+ snapshot_file, &td, sdump_addrinfo) == 0);
+ }
+ break;
+ default:
+ break;
+ }
+
+fin:
+ TEST_DATA_DESTROY(addrinfo, &td_snap);
+ TEST_DATA_DESTROY(addrinfo, &td);
+
+ free(snapshot_file_copy);
+}
+
+#define HOSTLIST_FILE "mach"
+#define RUN_TESTS(tc, snapshot_file, ai_family) do { \
+ char *_hostlist_file; \
+ ATF_REQUIRE(0 < asprintf(&_hostlist_file, "%s/%s", \
+ atf_tc_get_config_var(tc, "srcdir"), HOSTLIST_FILE)); \
+ run_tests(_hostlist_file, snapshot_file, ai_family); \
+ free(_hostlist_file); \
+} while (0)
+
+ATF_TC_WITHOUT_HEAD(pf_unspec);
+ATF_TC_BODY(pf_unspec, tc)
+{
+
+ RUN_TESTS(tc, NULL, AF_UNSPEC);
+}
+
+ATF_TC_WITHOUT_HEAD(pf_unspec_with_snapshot);
+ATF_TC_BODY(pf_unspec_with_snapshot, tc)
+{
+
+ RUN_TESTS(tc, "snapshot_ai", AF_UNSPEC);
+}
+
+ATF_TC_WITHOUT_HEAD(pf_inet);
+ATF_TC_BODY(pf_inet, tc)
+{
+
+ ATF_REQUIRE_FEATURE("inet");
+ RUN_TESTS(tc, NULL, AF_INET);
+}
+
+ATF_TC_WITHOUT_HEAD(pf_inet_with_snapshot);
+ATF_TC_BODY(pf_inet_with_snapshot, tc)
+{
+
+ ATF_REQUIRE_FEATURE("inet");
+ RUN_TESTS(tc, "snapshot_ai4", AF_INET);
+}
+
+ATF_TC_WITHOUT_HEAD(pf_inet6);
+ATF_TC_BODY(pf_inet6, tc)
+{
+
+ ATF_REQUIRE_FEATURE("inet6");
+ RUN_TESTS(tc, NULL, AF_INET6);
+}
+
+ATF_TC_WITHOUT_HEAD(pf_inet6_with_snapshot);
+ATF_TC_BODY(pf_inet6_with_snapshot, tc)
+{
+
+ ATF_REQUIRE_FEATURE("inet6");
+ RUN_TESTS(tc, "snapshot_ai6", AF_INET6);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, pf_unspec);
+ ATF_TP_ADD_TC(tp, pf_unspec_with_snapshot);
+ ATF_TP_ADD_TC(tp, pf_inet);
+ ATF_TP_ADD_TC(tp, pf_inet_with_snapshot);
+ ATF_TP_ADD_TC(tp, pf_inet6);
+ ATF_TP_ADD_TC(tp, pf_inet6_with_snapshot);
+
+ return (atf_no_error());
+}
+#endif /* __rtems__ */
diff --git a/testsuites/resolve/init.c b/testsuites/resolve/init.c
new file mode 100644
index 0000000..beb0e9a
--- /dev/null
+++ b/testsuites/resolve/init.c
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2023 Chris Johns <chris@contemporay.software>. All rights reserved.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <rtems.h>
+#include <rtems/dhcp.h>
+#include <rtems/rtems_bsdnet.h>
+#include <rtems/telnetd.h>
+
+#include <tmacros.h>
+#include <net-legacy-config.h>
+#include <network-config.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <resolv.h>
+
+#define START_SHELL 0
+
+const char rtems_test_name[] = "RESOLVE";
+
+#define MACH_SIZE 45
+static const char* mach[MACH_SIZE] = {
+ "localhost",
+ "anoncvs.cirr.com",
+ "anoncvs.netbsd.se",
+ "antioche.antioche.eu.org",
+ "centaurus.4web.cz",
+ "chur.math.ntnu.no",
+ "console.netbsd.org",
+ "cvs.netbsd.org",
+ "cvsup.netbsd.se",
+ "ftp.chg.ru",
+ "ftp.estpak.ee",
+ "ftp.fsn.hu",
+ "ftp.funet.fi",
+ "ftp.netbsd.org",
+ "ftp.nluug.nl",
+ "ftp.plig.org",
+ "ftp.uni-erlangen.de",
+ "ftp.xgate.co.kr",
+ "gd.tuwien.ac.at",
+ "gort.ludd.luth.se",
+ "irc.warped.net",
+ "knug.youn.co.kr",
+ "mail.jp.netbsd.org",
+ "mail.netbsd.org",
+ "melanoma.cs.rmit.edu.au",
+ "mirror.aarnet.edu.au",
+ "moon.vub.ac.be",
+ "net.bsd.cz",
+ "netbsd.3miasto.net",
+ "netbsd.4ka.mipt.ru",
+ "netbsd.csie.nctu.edu.tw",
+ "netbsd.enderunix.org",
+ "netbsd.ftp.fu-berlin.de",
+ "netbsd.pair.com",
+ "netbsdiso.interoute.net.uk",
+ "netbsdwww.cs.rmit.edu.au",
+ "netbsdwww.interoute.net.uk",
+ "ns.netbsd.org",
+ "skeleton.phys.spbu.ru",
+ "www.en.netbsd.de",
+ "www.netbsd.cl",
+ "www.netbsd.nl",
+ "www.netbsd.org",
+ "www.netbsd.ro",
+ "zeppo.rediris.es"
+};
+
+extern int addrinfo_read_hostlist_func(struct addrinfo *ai, const char *line);
+
+static int resolve_test(void) {
+ struct addrinfo addr;
+ size_t l;
+ int r = 0;
+ printf("getaddrinfo test start\n");
+ for (l = 0; l < MACH_SIZE - 1; ++l) {
+ r = addrinfo_read_hostlist_func(&addr, mach[l]);
+ if (r != 0) {
+ break;
+ }
+ }
+ fflush(stdout);
+ printf("getaddrinfo test finish\n\n\n");
+ sleep(2);
+ return r;
+}
+
+struct rtems_bsdnet_config rtems_bsdnet_config;
+
+static rtems_task Init(rtems_task_argument argument)
+{
+ rtems_status_code sc;
+ int rv;
+
+ TEST_BEGIN();
+
+ rtems_test_assert(rtems_net_legacy_config(&rtems_bsdnet_config));
+
+ rtems_bsdnet_config.domainname = "gemini.edu";
+ rtems_bsdnet_config.name_server[0] = "10.1.5.8";
+
+ rv = rtems_bsdnet_initialize_network();
+ rtems_test_assert(rv == 0);
+
+ rv = resolve_test();
+ rtems_test_assert(rv == 0);
+
+#if START_SHELL
+ sc = rtems_shell_init(
+ "SHLL", /* task name */
+ RTEMS_MINIMUM_STACK_SIZE * 4, /* task stack size */
+ 1, /* task priority */
+ "/dev/console", /* device name */
+ false, /* run forever */
+ true, /* wait for shell to terminate */
+ NULL /* login check function,
+ use NULL to disable a login check */
+ );
+ rtems_test_assert( sc == RTEMS_SUCCESSFUL );
+#endif
+
+ TEST_END();
+ sleep(2);
+ rtems_test_exit(0);
+}
+
+#define CONFIGURE_INIT
+
+#define CONFIGURE_MICROSECONDS_PER_TICK 10000
+
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
+
+#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 32
+
+#define CONFIGURE_MAXIMUM_TASKS 12
+
+#define CONFIGURE_MAXIMUM_POSIX_KEYS 10
+#define CONFIGURE_MAXIMUM_SEMAPHORES 20
+#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 10
+
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
+
+#define CONFIGURE_UNLIMITED_OBJECTS
+#define CONFIGURE_UNIFIED_WORK_AREAS
+
+#define RTEMS_NETWORKING 1
+#define CONFIGURE_SHELL_COMMANDS_INIT
+#define CONFIGURE_SHELL_COMMANDS_ALL
+#define CONFIGURE_SHELL_COMMANDS_ALL_NETWORKING
+
+#include <rtems/shellconfig.h>
+
+#include <rtems/confdefs.h>
diff --git a/testsuites/resolve/resolve.doc b/testsuites/resolve/resolve.doc
new file mode 100644
index 0000000..d58ef5b
--- /dev/null
+++ b/testsuites/resolve/resolve.doc
@@ -0,0 +1,11 @@
+This file describes the directives and concepts tested by this test set.
+
+test set name: resolve
+
+directives:
+
+ - getaddrinfo
+
+concepts:
+
++ Runs a tests from FreeBSD for getaddrinfo the mach file
diff --git a/testsuites/resolve/resolve.scn b/testsuites/resolve/resolve.scn
new file mode 100644
index 0000000..2014d06
--- /dev/null
+++ b/testsuites/resolve/resolve.scn
@@ -0,0 +1,166 @@
+*** BEGIN OF TEST RESOLVE ***
+*** TEST VERSION: 6.0.0.7e119562ae48d170604d3c82dcf2425a0a1ae3cd
+*** TEST STATE: EXPECTED_PASS
+*** TEST BUILD: RTEMS_POSIX_API
+*** TEST TOOLS: 12.2.1 20230224 (RTEMS 6, RSB 77dc54ce841a04598c64073c217aa9e66df31d8f, Newlib 17ac400)
+dec21140 : found device 'dc1', bus 0x00, dev 0x0e, func 0x00
+dec2114x : unit 1 base address 0xc1042100.
+dec2114x : driver attached
+dec2114x : driver tasks created
+dec2114x : 00:01:af:03:6d:d0 name 'dc1', io 11100, mem c1042100, int 10
+dec2114x: Installing IRQ 10
+getaddrinfo test start
+resolving localhost: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.127.0.0.1.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.127.0.0.1.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.127.0.0.1.0.0.0.0.0.0.0.0
+correct
+resolving anoncvs.cirr.com: not found
+resolving anoncvs.netbsd.se: not found
+resolving antioche.antioche.eu.org: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.132.227.74.11.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.132.227.74.11.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.132.227.74.11.0.0.0.0.0.0.0.0
+correct
+resolving centaurus.4web.cz: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.146.112.61.106.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.146.112.61.106.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.146.112.61.106.0.0.0.0.0.0.0.0
+correct
+resolving chur.math.ntnu.no: not found
+resolving console.netbsd.org: not found
+resolving cvs.netbsd.org: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.199.233.217.197.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.199.233.217.197.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.199.233.217.197.0.0.0.0.0.0.0.0
+correct
+resolving cvsup.netbsd.se: not found
+resolving ftp.chg.ru: not found
+resolving ftp.estpak.ee: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.62.65.42.236.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.62.65.42.236.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.62.65.42.236.0.0.0.0.0.0.0.0
+correct
+resolving ftp.fsn.hu: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.195.228.252.133.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.195.228.252.133.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.195.228.252.133.0.0.0.0.0.0.0.0
+correct
+resolving ftp.funet.fi: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.193.166.3.2.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.193.166.3.2.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.193.166.3.2.0.0.0.0.0.0.0.0
+correct
+resolving ftp.netbsd.org: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.199.233.217.201.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.199.233.217.201.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.199.233.217.201.0.0.0.0.0.0.0.0
+correct
+resolving ftp.nluug.nl: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.145.220.21.40.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.145.220.21.40.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.145.220.21.40.0.0.0.0.0.0.0.0
+correct
+resolving ftp.plig.org: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.188.226.162.120.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.188.226.162.120.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.188.226.162.120.0.0.0.0.0.0.0.0
+correct
+resolving ftp.uni-erlangen.de: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.131.188.12.211.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.131.188.12.211.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.131.188.12.211.0.0.0.0.0.0.0.0
+correct
+resolving ftp.xgate.co.kr: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.203.254.197.172.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.203.254.197.172.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.203.254.197.172.0.0.0.0.0.0.0.0
+correct
+resolving gd.tuwien.ac.at: not found
+resolving gort.ludd.luth.se: not found
+resolving irc.warped.net: not found
+resolving knug.youn.co.kr: not found
+resolving mail.jp.netbsd.org: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.210.148.108.146.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.210.148.108.146.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.210.148.108.146.0.0.0.0.0.0.0.0
+correct
+resolving mail.netbsd.org: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.199.233.217.200.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.199.233.217.200.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.199.233.217.200.0.0.0.0.0.0.0.0
+correct
+resolving melanoma.cs.rmit.edu.au: not found
+resolving mirror.aarnet.edu.au: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.202.158.214.106.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.202.158.214.106.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.202.158.214.106.0.0.0.0.0.0.0.0
+correct
+resolving moon.vub.ac.be: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.134.184.49.5.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.134.184.49.5.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.134.184.49.5.0.0.0.0.0.0.0.0
+correct
+resolving net.bsd.cz: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.94.124.105.4.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.94.124.105.4.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.94.124.105.4.0.0.0.0.0.0.0.0
+correct
+resolving netbsd.3miasto.net: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.104.247.81.52.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.104.247.81.52.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.104.247.81.52.0.0.0.0.0.0.0.0
+correct
+resolving netbsd.4ka.mipt.ru: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.93.175.29.188.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.93.175.29.188.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.93.175.29.188.0.0.0.0.0.0.0.0
+correct
+resolving netbsd.csie.nctu.edu.tw: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.140.113.17.207.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.140.113.17.207.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.140.113.17.207.0.0.0.0.0.0.0.0
+correct
+resolving netbsd.enderunix.org: not found
+resolving netbsd.ftp.fu-berlin.de: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.130.133.3.143.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.130.133.3.143.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.130.133.3.143.0.0.0.0.0.0.0.0
+correct
+resolving netbsd.pair.com: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.216.92.73.137.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.216.92.73.137.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.216.92.73.137.0.0.0.0.0.0.0.0
+correct
+resolving netbsdiso.interoute.net.uk: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.212.23.56.19.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.212.23.56.19.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.212.23.56.19.0.0.0.0.0.0.0.0
+correct
+resolving netbsdwww.cs.rmit.edu.au: not found
+resolving netbsdwww.interoute.net.uk: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.212.23.56.18.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.212.23.56.18.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.212.23.56.18.0.0.0.0.0.0.0.0
+correct
+resolving ns.netbsd.org: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.199.233.217.200.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.199.233.217.200.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.199.233.217.200.0.0.0.0.0.0.0.0
+correct
+resolving skeleton.phys.spbu.ru: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.185.148.210.80.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.185.148.210.80.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.185.148.210.80.0.0.0.0.0.0.0.0
+correct
+resolving www.en.netbsd.de: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.195.22.142.107.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.195.22.142.107.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.195.22.142.107.0.0.0.0.0.0.0.0
+correct
+resolving www.netbsd.cl: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.172.67.129.38.0.0.0.0.0.0.0.0:3162112 2 2 17 16 (null) 16.2.0.0.104.21.1.106.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.172.67.129.38.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.104.21.1.106.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.172.67.129.38.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.104.21.1.106.0.0.0.0.0.0.0.0
+correct
+resolving www.netbsd.nl: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.91.195.241.232.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.91.195.241.232.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.91.195.241.232.0.0.0.0.0.0.0.0
+correct
+resolving www.netbsd.org: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.151.101.65.6.0.0.0.0.0.0.0.0:3162112 2 2 17 16 (null) 16.2.0.0.151.101.1.6.0.0.0.0.0.0.0.0:3162112 2 2 17 16 (null) 16.2.0.0.151.101.193.6.0.0.0.0.0.0.0.0:3162112 2 2 17 16 (null) 16.2.0.0.151.101.129.6.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.151.101.65.6.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.151.101.1.6.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.151.101.193.6.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.151.101.129.6.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.151.101.65.6.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.1
+51.101.1.6.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.151.101.193.6.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.151.101.129.6.0.0.0.0.0.0.0.0
+correct
+resolving www.netbsd.ro: found
+testing correctness with the following data:
+3162112 2 2 17 16 (null) 16.2.0.0.172.67.142.193.0.0.0.0.0.0.0.0:3162112 2 2 17 16 (null) 16.2.0.0.104.21.95.36.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.172.67.142.193.0.0.0.0.0.0.0.0:3162112 2 1 6 16 (null) 16.2.0.0.104.21.95.36.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.172.67.142.193.0.0.0.0.0.0.0.0:3162112 2 5 132 16 (null) 16.2.0.0.104.21.95.36.0.0.0.0.0.0.0.0
+correct
+getaddrinfo test finish
+
+
+
+*** END OF TEST RESOLVE ***
+
+
+
+
+
+*** BEGIN OF TEST RESOLVE ***
+*** TEST VERSION: 6.0.0.d15640249372de3106a66304569a44f6f32cca23
+*** TEST STATE: EXPECTED_PASS
+*** TEST BUILD: RTEMS_POSIX_API
+*** TEST TOOLS: 12.2.1 20230224 (RTEMS 6, RSB 77dc54ce841a04598c64073c217aa9e66df31d8f, Newlib 17ac400)
+syslog: telnetd: started successfully on port 23
diff --git a/testsuites/resolve/wscript b/testsuites/resolve/wscript
new file mode 100644
index 0000000..18ce5ea
--- /dev/null
+++ b/testsuites/resolve/wscript
@@ -0,0 +1,49 @@
+#
+# RTEMS Project (https://www.rtems.org/)
+#
+# Copyright (c) 2023 Chris Johns <chris@contemporary.software>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+from rtems_waf import rtems
+
+
+def init(ctx):
+ pass
+
+
+def configure(conf):
+ pass
+
+
+def build(bld):
+ legacy_config = bld.path.parent.find_node('support/net-legacy-config.c')
+ source = ['init.c', 'getaddrinfo_test.c', legacy_config]
+ bld.program(target='resolve.exe',
+ features='c cprogram',
+ cflags=bld.env.OPTIMIZATION + ['-g'],
+ includes=bld.env.IFLAGS,
+ lib=['networking'],
+ libpath=['.'],
+ source=source,
+ install_path=False)
diff --git a/testsuites/wscript b/testsuites/wscript
index 6bfc1eb..c0fd37d 100644
--- a/testsuites/wscript
+++ b/testsuites/wscript
@@ -29,7 +29,7 @@
from rtems_waf import rtems
subdirs = [
- 'ftp01', 'loopback', 'networking01', 'pppd', 'syscall01', 'telnetd01', 'telnetd02'
+ 'ftp01', 'loopback', 'networking01', 'pppd', 'resolve', 'syscall01', 'telnetd01', 'telnetd02'
]