[PATCH 20/20] sdk_dpaa: Add MAC-less driver test program
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Jan 19 13:54:10 UTC 2018
---
libbsd.py | 1 +
libbsd_waf.py | 10 ++
testsuite/dpaa/test_main.c | 227 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 238 insertions(+)
create mode 100644 testsuite/dpaa/test_main.c
diff --git a/libbsd.py b/libbsd.py
index 7b0b5537b..dd2fc51c1 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -4370,6 +4370,7 @@ def in_cksum(mm):
#
def tests(mm):
mod = builder.Module('tests')
+ mod.addTest(mm.generator['test']('dpaa', ['test_main']))
mod.addTest(mm.generator['test']('nfs01', ['test_main'], netTest = True))
mod.addTest(mm.generator['test']('foobarclient', ['test_main'],
runTest = False, netTest = True))
diff --git a/libbsd_waf.py b/libbsd_waf.py
index 4ea3e8c86..1777aa2cf 100644
--- a/libbsd_waf.py
+++ b/libbsd_waf.py
@@ -2634,6 +2634,16 @@ def build(bld):
lib = ["m", "z"],
install_path = None)
+ test_dpaa = ['testsuite/dpaa/test_main.c']
+ bld.program(target = "dpaa.exe",
+ features = "cprogram",
+ cflags = cflags,
+ includes = includes,
+ source = test_dpaa,
+ use = ["bsd"],
+ lib = ["m", "z"],
+ install_path = None)
+
test_evdev01 = ['testsuite/evdev01/init.c']
bld.program(target = "evdev01.exe",
features = "cprogram",
diff --git a/testsuite/dpaa/test_main.c b/testsuite/dpaa/test_main.c
new file mode 100644
index 000000000..8d515f427
--- /dev/null
+++ b/testsuite/dpaa/test_main.c
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 2010, 2018 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems at embedded-brains.de>
+ *
+ * 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/param.h>
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+
+#include <machine/rtems-bsd-commands.h>
+
+#include <rtems/console.h>
+#include <rtems/ftpd.h>
+#include <rtems/media.h>
+#include <rtems/shell.h>
+#include <rtems/telnetd.h>
+
+#define TEST_NAME "LIBBSD DPAA 1"
+
+struct rtems_ftpd_configuration rtems_ftpd_configuration = {
+ /* FTPD task priority */
+ .priority = 100,
+
+ /* Maximum buffersize for hooks */
+ .max_hook_filesize = 0,
+
+ /* Well-known port */
+ .port = 21,
+
+ /* List of hooks */
+ .hooks = NULL,
+
+ /* Root for FTPD or NULL for "/" */
+ .root = NULL,
+
+ /* Max. connections depending on processor count */
+ .tasks_count = 4,
+
+ /* Idle timeout in seconds or 0 for no (infinite) timeout */
+ .idle = 5 * 60,
+
+ /* Access: 0 - r/w, 1 - read-only, 2 - write-only, 3 - browse-only */
+ .access = 0
+};
+
+static void
+telnet_shell(char *name, void *arg)
+{
+ rtems_shell_env_t env;
+
+ memset(&env, 0, sizeof(env));
+
+ env.devname = name;
+ env.taskname = "TLNT";
+ env.login_check = NULL;
+ env.forever = false;
+
+ rtems_shell_main_loop(&env);
+}
+
+rtems_telnetd_config_table rtems_telnetd_config = {
+ .command = telnet_shell,
+ .arg = NULL,
+ .priority = 0,
+ .stack_size = 0,
+ .login_check = NULL,
+ .keep_stdio = false
+};
+
+static void
+ifconfig(char *ifname, char *self_ip, char *netmask)
+{
+ int exit_code;
+ char *ifcfg[] = {
+ "ifconfig",
+ ifname,
+ "inet",
+ self_ip,
+ "netmask",
+ netmask,
+ NULL
+ };
+
+ exit_code = rtems_bsd_command_ifconfig(RTEMS_BSD_ARGC(ifcfg), ifcfg);
+ assert(exit_code == EX_OK);
+}
+
+static void
+route(char *ifname, char *gateway_ip)
+{
+ int exit_code;
+ char *dflt_route[] = {
+ "route",
+ "add",
+ "-host",
+ gateway_ip,
+ "-iface",
+ ifname,
+ NULL
+ };
+ char *dflt_route2[] = {
+ "route",
+ "add",
+ "default",
+ gateway_ip,
+ NULL
+ };
+
+ exit_code = rtems_bsd_command_route(RTEMS_BSD_ARGC(dflt_route), dflt_route);
+ assert(exit_code == EXIT_SUCCESS);
+
+ exit_code = rtems_bsd_command_route(RTEMS_BSD_ARGC(dflt_route2), dflt_route2);
+ assert(exit_code == EXIT_SUCCESS);
+}
+
+#define MAC_LESS_IFACE "ml0"
+
+static void
+test_main(void)
+{
+ rtems_status_code sc;
+ int rv;
+
+ ifconfig(MAC_LESS_IFACE, "10.1.1.2", "255.255.255.0");
+ route(MAC_LESS_IFACE, "10.1.1.1");
+
+ rv = rtems_initialize_ftpd();
+ assert(rv == 0);
+
+ sc = rtems_telnetd_initialize();
+ assert(sc == RTEMS_SUCCESSFUL);
+
+ sc = rtems_shell_init("SHLL", 16 * 1024, 1, CONSOLE_DEVICE_NAME,
+ false, true, NULL);
+ assert(sc == RTEMS_SUCCESSFUL);
+
+ exit(0);
+}
+
+#define DEFAULT_EARLY_INITIALIZATION
+
+static void
+early_initialization(void)
+{
+ int i;
+
+ for (i = 0; i < 5; ++i) {
+ sleep(1);
+ printf("start %i\n", i);
+ }
+}
+
+#define CONFIGURE_MICROSECONDS_PER_TICK 1000
+
+#define CONFIGURE_MAXIMUM_DRIVERS 32
+
+#define DEFAULT_NETWORK_NO_INTERFACE_0
+
+#include <rtems/bsd/test/default-network-init.h>
+
+#define CONFIGURE_SHELL_COMMANDS_INIT
+
+#include <bsp/irq-info.h>
+
+#include <rtems/netcmds-config.h>
+
+#define CONFIGURE_SHELL_USER_COMMANDS \
+ &bsp_interrupt_shell_command, \
+ &rtems_shell_ARP_Command, \
+ &rtems_shell_HOSTNAME_Command, \
+ &rtems_shell_PING_Command, \
+ &rtems_shell_ROUTE_Command, \
+ &rtems_shell_NETSTAT_Command, \
+ &rtems_shell_SYSCTL_Command, \
+ &rtems_shell_IFCONFIG_Command, \
+ &rtems_shell_VMSTAT_Command
+
+#define CONFIGURE_SHELL_COMMAND_CPUINFO
+#define CONFIGURE_SHELL_COMMAND_CPUUSE
+#define CONFIGURE_SHELL_COMMAND_PERIODUSE
+#define CONFIGURE_SHELL_COMMAND_STACKUSE
+
+#define CONFIGURE_SHELL_COMMAND_CP
+#define CONFIGURE_SHELL_COMMAND_PWD
+#define CONFIGURE_SHELL_COMMAND_LS
+#define CONFIGURE_SHELL_COMMAND_LN
+#define CONFIGURE_SHELL_COMMAND_LSOF
+#define CONFIGURE_SHELL_COMMAND_CHDIR
+#define CONFIGURE_SHELL_COMMAND_CD
+#define CONFIGURE_SHELL_COMMAND_MKDIR
+#define CONFIGURE_SHELL_COMMAND_RMDIR
+#define CONFIGURE_SHELL_COMMAND_CAT
+#define CONFIGURE_SHELL_COMMAND_MV
+#define CONFIGURE_SHELL_COMMAND_RM
+#define CONFIGURE_SHELL_COMMAND_MALLOC_INFO
+
+#include <rtems/shellconfig.h>
--
2.12.3
More information about the devel
mailing list