diff options
Diffstat (limited to 'lwip/test')
-rw-r--r-- | lwip/test/init.c | 120 | ||||
-rw-r--r-- | lwip/test/networking01/sample_app.c | 159 | ||||
-rw-r--r-- | lwip/test/telnetd01/init.c | 132 | ||||
-rw-r--r-- | lwip/test/telnetd01/telnetd01.doc | 24 | ||||
-rw-r--r-- | lwip/test/telnetd01/telnetd01.scn | 11 | ||||
-rw-r--r-- | lwip/test/telnetd01/wscript | 52 |
6 files changed, 498 insertions, 0 deletions
diff --git a/lwip/test/init.c b/lwip/test/init.c new file mode 100644 index 0000000..a17126b --- /dev/null +++ b/lwip/test/init.c @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2018 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * 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 <string.h> + +#include <rtems.h> +#include <rtems/rtems_bsdnet.h> +#include <rtems/telnetd.h> + +#include <tmacros.h> + +const char rtems_test_name[] = "TELNETD 1"; + +struct rtems_bsdnet_config rtems_bsdnet_config; + +static void command(char *device_name, void *arg) +{ +} + +static void test_command_null(void) +{ + static const rtems_telnetd_config_table config = { + .command = NULL + }; + rtems_status_code sc; + + sc = rtems_telnetd_start(&config); + rtems_test_assert(sc == RTEMS_INVALID_ADDRESS); +} + +static void test_cannot_start_server_task(void) +{ + static const rtems_telnetd_config_table config = { + .command = command, + .priority = UINT32_MAX + }; + rtems_status_code sc; + + sc = rtems_telnetd_start(&config); + rtems_test_assert(sc == RTEMS_UNSATISFIED); +} + +static void test_successful_start(void) +{ + static const rtems_telnetd_config_table config = { + .command = command, + .stack_size = RTEMS_MINIMUM_STACK_SIZE + }; + rtems_status_code sc; + + sc = rtems_telnetd_start(&config); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); +} + +static void test_already_started(void) +{ + static const rtems_telnetd_config_table config = { + .command = command + }; + rtems_status_code sc; + + sc = rtems_telnetd_start(&config); + rtems_test_assert(sc == RTEMS_RESOURCE_IN_USE); +} + +static rtems_task Init(rtems_task_argument argument) +{ + int rv; + + TEST_BEGIN(); + + rv = rtems_bsdnet_initialize_network(); + rtems_test_assert(rv == 0); + + test_command_null(); + test_cannot_start_server_task(); + test_successful_start(); + test_already_started(); + + TEST_END(); + rtems_test_exit(0); +} + +#define CONFIGURE_INIT + +#define CONFIGURE_MICROSECONDS_PER_TICK 10000 + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER + +#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS (3 + 1 + 5 * 4) + +#define CONFIGURE_MAXIMUM_TASKS 8 + +#define CONFIGURE_MAXIMUM_POSIX_KEYS 1 + +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT + +#include <rtems/confdefs.h> diff --git a/lwip/test/networking01/sample_app.c b/lwip/test/networking01/sample_app.c new file mode 100644 index 0000000..1a7018f --- /dev/null +++ b/lwip/test/networking01/sample_app.c @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * 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 <compat/posix/sys/socket.h> +#include "lwip/netdb.h" +#include <string.h> +#include <rtems.h> +#include <tmacros.h> + +const char rtems_test_name[] = "NETWORKING 1"; + +/* forward declarations to avoid warnings */ +static rtems_task Init(rtems_task_argument argument); + +static void fill_sa(struct sockaddr *sa, sa_family_t family) +{ + memset(sa, 0, sizeof(*sa)); + sa->sa_len = sizeof(*sa); + sa->sa_family = family; +} + +static void fill_sa_in(struct sockaddr_in *sa_in, + in_addr_t addr, in_port_t port) +{ + fill_sa((struct sockaddr *)sa_in, AF_INET); + sa_in->sin_port = htons(port); + sa_in->sin_addr.s_addr = htonl(addr); +} + +static void test_getnameinfo( + const struct sockaddr *sa, + int flags, + bool ask_node, + bool ask_service, + int expected_returnvalue, + const char *expected_node, + const char *expected_service +) +{ + char node[] = "255.255.255.255"; + char service[] = "65535"; + socklen_t salen = sa->sa_len; + int rv; + + char *node_p = node; + char *service_p = service; + size_t node_l = sizeof(node); + size_t service_l = sizeof(service); + + if(ask_node == false) { + node_p = NULL; + node_l = 0; + } + + if(ask_service == false) { + service_p = NULL; + service_l = 0; + } + + rv = getnameinfo(sa, salen, node_p, node_l, service_p, service_l, flags); + rtems_test_assert(rv == expected_returnvalue); + + if(expected_node != NULL) { + rtems_test_assert(strcmp(expected_node, node) == 0); + } + + if(expected_service != NULL) { + rtems_test_assert(strcmp(expected_service, service) == 0); + } +} + +static void test(void) +{ + struct sockaddr sa; + struct sockaddr_in sa_in; + struct sockaddr *sa_in_p = (struct sockaddr *) &sa_in; + + const in_addr_t ip1_num = 0x7F000001u; + const char ip1_string[] = "127.0.0.1"; + + const in_addr_t ip2_num = 0xC0A86464u; + const char ip2_string[] = "192.168.100.100"; + + const in_port_t port1_num = 7u; + const char port1_string[] = "7"; + + const in_port_t port2_num = 65534u; + const char port2_string[] = "65534"; + + + puts("Try AF_INET6"); + fill_sa(&sa, AF_INET6); + test_getnameinfo(&sa, 0, true, true, EAI_FAMILY, NULL, NULL); + + puts("force node name"); + fill_sa_in(&sa_in, ip1_num, port1_num); + test_getnameinfo(sa_in_p, NI_NAMEREQD, true, true, EAI_NONAME, NULL, NULL); + + puts("force service name"); + fill_sa_in(&sa_in, ip1_num, port1_num); + test_getnameinfo(sa_in_p, NI_NAMEREQD, true, true, EAI_NONAME, NULL, NULL); + + puts("get node only"); + fill_sa_in(&sa_in, ip1_num, port1_num); + test_getnameinfo(sa_in_p, 0, true, false, 0, ip1_string, NULL); + + puts("get service only"); + fill_sa_in(&sa_in, ip1_num, port1_num); + test_getnameinfo(sa_in_p, 0, false, true, 0, NULL, port1_string); + + puts("get node and service"); + fill_sa_in(&sa_in, ip1_num, port1_num); + test_getnameinfo(sa_in_p, 0, true, true, 0, ip1_string, port1_string); + + puts("get node and service with maximum number of characters for IP"); + fill_sa_in(&sa_in, ip2_num, port2_num); + test_getnameinfo(sa_in_p, 0, true, true, 0, ip2_string, port2_string); +} + +static rtems_task Init(rtems_task_argument argument) +{ + TEST_BEGIN(); + test(); + TEST_END(); + + rtems_test_exit(0); +} + +#define CONFIGURE_INIT + +#define CONFIGURE_MICROSECONDS_PER_TICK 10000 + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER + +#define CONFIGURE_MAXIMUM_TASKS (1) + +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT + +#include <rtems/confdefs.h> diff --git a/lwip/test/telnetd01/init.c b/lwip/test/telnetd01/init.c new file mode 100644 index 0000000..e9c312a --- /dev/null +++ b/lwip/test/telnetd01/init.c @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2018 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * <rtems@embedded-brains.de> + * + * 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 <string.h> + +#include <rtems.h> +//#include <rtems/rtems_bsdnet.h> +#include <rtems/telnetd.h> +#include <lwip/init.h> +#include <lwip/sockets.h> + +#include "lwiplib.h" +#include "lwipopts.h" +#include "soc_AM335x.h" +#include "beaglebone.h" +#include "lwip/ports/drivers/eth_lwip.h" + +#include <tmacros.h> + +const char rtems_test_name[] = "TELNETD 1"; + +//struct rtems_bsdnet_config rtems_bsdnet_config; + +static void command(char *device_name, void *arg) +{ +} + +static void test_command_null(void) +{ + static const rtems_telnetd_config_table config = { + .command = NULL + }; + rtems_status_code sc; + + sc = rtems_telnetd_start(&config); + rtems_test_assert(sc == RTEMS_INVALID_ADDRESS); +} + +static void test_cannot_start_server_task(void) +{ + static const rtems_telnetd_config_table config = { + .command = command, + .priority = UINT32_MAX + }; + rtems_status_code sc; + + sc = rtems_telnetd_start(&config); + rtems_test_assert(sc == RTEMS_UNSATISFIED); +} + +static void test_successful_start(void) +{ + static const rtems_telnetd_config_table config = { + .command = command, + .stack_size = RTEMS_MINIMUM_STACK_SIZE + }; + rtems_status_code sc; + + sc = rtems_telnetd_start(&config); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); +} + +static void test_already_started(void) +{ + static const rtems_telnetd_config_table config = { + .command = command + }; + rtems_status_code sc; + + sc = rtems_telnetd_start(&config); + rtems_test_assert(sc == RTEMS_RESOURCE_IN_USE); +} + +static rtems_task Init(rtems_task_argument argument) +{ + TEST_BEGIN(); + + //rv = rtems_bsdnet_initialize_network(); + /* + LWIP_IF lwipIfPort1; + + lwipIfPort1.ipMode = IPADDR_USE_DHCP; + LwipInit(&lwipIfPort1); + */ + lwip_init(); + + test_command_null(); + test_cannot_start_server_task(); + test_successful_start(); + test_already_started(); + + TEST_END(); + rtems_test_exit(0); +} + +#define CONFIGURE_INIT + +#define CONFIGURE_MICROSECONDS_PER_TICK 10000 + +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER + +#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS (3 + 1 + 5 * 4) + +#define CONFIGURE_MAXIMUM_TASKS 8 + +#define CONFIGURE_MAXIMUM_POSIX_KEYS 1 + +#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION + +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE + +#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT + +#include <rtems/confdefs.h> diff --git a/lwip/test/telnetd01/telnetd01.doc b/lwip/test/telnetd01/telnetd01.doc new file mode 100644 index 0000000..fe1a4d3 --- /dev/null +++ b/lwip/test/telnetd01/telnetd01.doc @@ -0,0 +1,24 @@ +# +# Copyright (c) 2018 embedded brains GmbH. All rights reserved. +# +# embedded brains GmbH +# Dornierstr. 4 +# 82178 Puchheim +# Germany +# <rtems@embedded-brains.de> +# +# 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. + +This file describes the directives and concepts tested by this test set. + +test set name: telnetd01 + +directives: + + - rtems_telnetd_start() + +concepts: + ++ Check if Telnet server works. diff --git a/lwip/test/telnetd01/telnetd01.scn b/lwip/test/telnetd01/telnetd01.scn new file mode 100644 index 0000000..3e9cc00 --- /dev/null +++ b/lwip/test/telnetd01/telnetd01.scn @@ -0,0 +1,11 @@ +*** BEGIN OF TEST TELNETD 1 *** +*** TEST VERSION: 5.0.0.dc32b6aa0807fb70f9b26bc0bc6e164ddb49bd3a +*** TEST STATE: EXPECTED_PASS +*** TEST BUILD: RTEMS_NETWORKING +*** TEST TOOLS: 7.3.0 20180125 (RTEMS 5, RSB 9670d7541e0621915e521fe76e7bb33de8cee661, Newlib d13c84eb07e35984bf7a974cd786a6cdac29e6b9) +syslog: telnetd: configuration with invalid command +syslog: telnetd: cannot create session task +syslog: telnetd: started successfully on port 23 +syslog: telnetd: cannot bind server socket + +*** END OF TEST TELNETD 1 *** diff --git a/lwip/test/telnetd01/wscript b/lwip/test/telnetd01/wscript new file mode 100644 index 0000000..f24f2ad --- /dev/null +++ b/lwip/test/telnetd01/wscript @@ -0,0 +1,52 @@ +# +# RTEMS Project (https://www.rtems.org/) +# +# Copyright (c) 2021 Regents of University of Colorado +# Written by Vijay Kumar Banerjee <vijay@rtems.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 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 +import os + + +def init(ctx): + pass + + +def configure(conf): + pass + + +def build(bld): + arch_lib_path = rtems.arch_bsp_lib_path(bld.env.RTEMS_VERSION, + bld.env.RTEMS_ARCH_BSP) + lib_path = os.path.join(bld.env.PREFIX, arch_lib_path) + bld.read_stlib('telnetd', paths=[lib_path]) + + bld.program(target='telnetd01.exe', + features='c cprogram', + cflags=['-O2', '-g'], + includes='. .. ../include ../../ ../../include', + use=['telnetd', 'networking'], + source='init.c') |