summaryrefslogtreecommitdiffstats
path: root/testsuites/libtests
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-10-09 14:47:02 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-10-10 14:06:27 +0200
commit629faf95046cddedc161ba9bc43fda925ca04ee5 (patch)
treed8bfd198d8814ac4a78c5c949f25cad937ddad33 /testsuites/libtests
parentbuild: Remove local.am (diff)
downloadrtems-629faf95046cddedc161ba9bc43fda925ca04ee5.tar.bz2
telnetd: Remove keep stdio feature
The Telnet service started via rtems_telnetd_start() had a keep stdio feature. This just created a task and executed the command function in a loop. For this kind of service we do not library support. This can be done by an application task on its own. Remove this feature and provide only the real Telnet server functionality. Use syslog() for error and status messages. Add test program for the Telnet server. Close #3542.
Diffstat (limited to 'testsuites/libtests')
-rw-r--r--testsuites/libtests/Makefile.am12
-rw-r--r--testsuites/libtests/configure.ac1
-rw-r--r--testsuites/libtests/telnetd01/init.c118
-rw-r--r--testsuites/libtests/telnetd01/telnetd01.doc24
-rw-r--r--testsuites/libtests/telnetd01/telnetd01.scn12
5 files changed, 167 insertions, 0 deletions
diff --git a/testsuites/libtests/Makefile.am b/testsuites/libtests/Makefile.am
index 52bbc3e3fb..240b04c74c 100644
--- a/testsuites/libtests/Makefile.am
+++ b/testsuites/libtests/Makefile.am
@@ -1134,6 +1134,18 @@ tar03_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_tar03) \
$(support_includes)
endif
+if NETTESTS
+if TEST_telnetd01
+lib_tests += telnetd01
+lib_screens += telnetd01/telnetd01.scn
+lib_docs += telnetd01/telnetd01.doc
+telnetd01_SOURCES = telnetd01/init.c
+telnetd01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_telnetd01) \
+ $(support_includes) -I$(RTEMS_SOURCE_ROOT)/cpukit/libnetworking
+telnetd01_LDADD = $(RTEMS_ROOT)cpukit/libtelnetd.a $(LDADD)
+endif
+endif
+
if TEST_termios
lib_tests += termios
termios_SOURCES = termios/init.c
diff --git a/testsuites/libtests/configure.ac b/testsuites/libtests/configure.ac
index c529b27660..303a165731 100644
--- a/testsuites/libtests/configure.ac
+++ b/testsuites/libtests/configure.ac
@@ -208,6 +208,7 @@ RTEMS_TEST_CHECK([syscall01])
RTEMS_TEST_CHECK([tar01])
RTEMS_TEST_CHECK([tar02])
RTEMS_TEST_CHECK([tar03])
+RTEMS_TEST_CHECK([telnetd01])
RTEMS_TEST_CHECK([termios])
RTEMS_TEST_CHECK([termios01])
RTEMS_TEST_CHECK([termios02])
diff --git a/testsuites/libtests/telnetd01/init.c b/testsuites/libtests/telnetd01/init.c
new file mode 100644
index 0000000000..f2243d9dd8
--- /dev/null
+++ b/testsuites/libtests/telnetd01/init.c
@@ -0,0 +1,118 @@
+/*
+ * 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_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
+
+#define CONFIGURE_MAXIMUM_TASKS 7
+
+#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/testsuites/libtests/telnetd01/telnetd01.doc b/testsuites/libtests/telnetd01/telnetd01.doc
new file mode 100644
index 0000000000..fe1a4d31a3
--- /dev/null
+++ b/testsuites/libtests/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/testsuites/libtests/telnetd01/telnetd01.scn b/testsuites/libtests/telnetd01/telnetd01.scn
new file mode 100644
index 0000000000..2dc2c60846
--- /dev/null
+++ b/testsuites/libtests/telnetd01/telnetd01.scn
@@ -0,0 +1,12 @@
+*** 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
+Telnetd: spawning task failed (status: RTEMS_INVALID_PRIORITY)
+syslog: telnetd: cannot create server task
+syslog: telnetd: started successfully
+syslog: telnetd: already started
+
+*** END OF TEST TELNETD 1 ***