Add network test support

This commit is contained in:
Sebastian Huber 2013-11-13 15:09:40 +01:00
parent fafa9e2716
commit 6ab78d66d4
5 changed files with 104 additions and 7 deletions

1
.gitignore vendored
View File

@ -14,6 +14,7 @@ freebsd/lib/libc/net/nslexer.c
freebsd/lib/libc/net/nsparser.c
rtemsbsd/rtems/rtems-kvm-symbols.c
rtemsbsd/include/machine/rtems-bsd-kernel-space.h
testsuite/include/rtems/bsd/test/network-config.h
/*.i
/*.s
/log

View File

@ -33,8 +33,14 @@ NEED_DUMMY_PIC_IRQ=yes
# do nothing default so sed on rtems-bsd-kernel-space.h always works.
SED_PATTERN += -e 's/^//'
TEST_NETWORK_CONFIG = testsuite/include/rtems/bsd/test/network-config.h
TESTS =
RUN_TESTS =
NET_TESTS =
RUN_NET_TESTS =
O_FILES =
D_FILES =
@ -937,14 +943,26 @@ LIB_O_FILES = $(LIB_C_FILES:%.c=%.o)
O_FILES += $(LIB_O_FILES)
D_FILES += $(LIB_C_FILES:%.c=%.d)
all: $(LIB) $(TESTS)
all: $(LIB) $(TESTS) $(TEST_NETWORK_CONFIG) $(NET_TESTS)
$(LIB): $(LIB_GEN_FILES) $(LIB_O_FILES)
$(AR) rcu $@ $^
run_tests: $(RUN_TESTS)
$(TEST_RUNNER) $^
check_endof
run_net_tests: $(RUN_NET_TESTS)
$(TEST_RUNNER) -N -T $(NET_TAP_INTERFACE) $^
check_endof
$(TEST_NETWORK_CONFIG): $(TEST_NETWORK_CONFIG).in config.inc
sed -e 's/@NET_CFG_SELF_IP@/$(NET_CFG_SELF_IP)/' \
-e 's/@NET_CFG_NETMASK@/$(NET_CFG_NETMASK)/' \
-e 's/@NET_CFG_PEER_IP@/$(NET_CFG_PEER_IP)/' \
-e 's/@NET_CFG_GATEWAY_IP@/$(NET_CFG_GATEWAY_IP)/' \
< $< > $@
# The following targets use the MIPS Generic in_cksum routine
rtemsbsd/include/machine/rtems-bsd-kernel-space.h: rtemsbsd/include/machine/rtems-bsd-kernel-space.h.in
sed $(SED_PATTERN) <$< >$@

View File

@ -3,3 +3,8 @@ RTEMS_MAKEFILE_PATH = ${HOME}/newbsd/bsp-install/mips-rtems4.11/$(BSP)
INSTALL_BASE = ${HOME}/newbsd/install
DISABLE_IPV6=no
TEST_RUNNER = $(BSP)
NET_CFG_SELF_IP = 10.0.2.1
NET_CFG_NETMASK = 255.255.0.0
NET_CFG_PEER_IP = 192.168.100.11
NET_CFG_GATEWAY_IP = 192.168.100.11
NET_TAP_INTERFACE = tap0

View File

@ -304,10 +304,11 @@ class SourceFileMakefileFragmentComposer(MakefileFragmentComposer):
return 'LIB_C_FILES += ' + path + '\n'
class TestMakefileFragementComposer(MakefileFragmentComposer):
def __init__(self, testName, fileFragments, runTest):
def __init__(self, testName, fileFragments, runTest, netTest):
self.testName = testName
self.fileFragments = fileFragments
self.runTest = runTest
self.netTest = netTest
def compose(self, path):
testPrefix = 'TEST_' + self.testName.upper()
@ -316,6 +317,9 @@ class TestMakefileFragementComposer(MakefileFragmentComposer):
testDir = 'testsuite/' + self.testName
testExe = testDir + '/' + self.testName + '.exe'
testMap = testDir + '/' + self.testName + '.map'
testCollection = 'TESTS'
if self.netTest:
testCollection = 'NET_' + testCollection
makefileFragment = '\n' + testPrefix + ' = ' + testExe + '\n' \
+ testOFiles + ' =\n' \
+ testDFiles + ' =\n'
@ -324,11 +328,11 @@ class TestMakefileFragementComposer(MakefileFragmentComposer):
+ testDFiles + ' += ' + testDir + '/' + fileFragment + '.d\n'
makefileFragment = makefileFragment + '$(' + testPrefix + '): $(' + testOFiles + ') $(LIB)\n' \
'\t$(LINK.c) -Wl,-Map,' + testMap + ' $^ -lm -lz -o $@\n' \
'TESTS += $(' + testPrefix + ')\n' \
+ testCollection + ' += $(' + testPrefix + ')\n' \
'O_FILES += $(' + testOFiles + ')\n' \
'D_FILES += $(' + testDFiles + ')\n'
if self.runTest:
makefileFragment = makefileFragment + 'RUN_TESTS += $(' + testPrefix + ')\n'
makefileFragment = makefileFragment + 'RUN_' + testCollection + ' += $(' + testPrefix + ')\n'
return makefileFragment
class File(object):
@ -419,8 +423,14 @@ class ModuleManager:
'# do nothing default so sed on rtems-bsd-kernel-space.h always works.\n' \
'SED_PATTERN += -e \'s/^//\'\n' \
'\n' \
'TEST_NETWORK_CONFIG = testsuite/include/rtems/bsd/test/network-config.h\n' \
'\n' \
'TESTS =\n' \
'RUN_TESTS =\n' \
'\n' \
'NET_TESTS =\n' \
'RUN_NET_TESTS =\n' \
'\n' \
'O_FILES =\n' \
'D_FILES =\n' \
'\n' \
@ -452,14 +462,26 @@ class ModuleManager:
'O_FILES += $(LIB_O_FILES)\n' \
'D_FILES += $(LIB_C_FILES:%.c=%.d)\n' \
'\n' \
'all: $(LIB) $(TESTS)\n' \
'all: $(LIB) $(TESTS) $(TEST_NETWORK_CONFIG) $(NET_TESTS)\n' \
'\n' \
'$(LIB): $(LIB_GEN_FILES) $(LIB_O_FILES)\n' \
'\t$(AR) rcu $@ $^\n' \
'\n' \
'run_tests: $(RUN_TESTS)\n' \
'\t$(TEST_RUNNER) $^\n' \
'\tcheck_endof\n' \
'\n' \
'run_net_tests: $(RUN_NET_TESTS)\n' \
'\t$(TEST_RUNNER) -N -T $(NET_TAP_INTERFACE) $^\n' \
'\tcheck_endof\n' \
'\n' \
'$(TEST_NETWORK_CONFIG): $(TEST_NETWORK_CONFIG).in config.inc\n' \
'\tsed -e \'s/@NET_CFG_SELF_IP@/$(NET_CFG_SELF_IP)/\' \\\n' \
'\t-e \'s/@NET_CFG_NETMASK@/$(NET_CFG_NETMASK)/\' \\\n' \
'\t-e \'s/@NET_CFG_PEER_IP@/$(NET_CFG_PEER_IP)/\' \\\n' \
'\t-e \'s/@NET_CFG_GATEWAY_IP@/$(NET_CFG_GATEWAY_IP)/\' \\\n' \
'\t< $< > $@\n' \
'\n' \
'# The following targets use the MIPS Generic in_cksum routine\n' \
'rtemsbsd/include/machine/rtems-bsd-kernel-space.h: rtemsbsd/include/machine/rtems-bsd-kernel-space.h.in\n' \
'\tsed $(SED_PATTERN) <$< >$@\n' \
@ -590,8 +612,8 @@ class Module:
self.initCPUDependencies(cpu)
self.cpuDependentSourceFiles [cpu] = self.addFiles(self.cpuDependentSourceFiles [cpu], files, TargetSourceCPUDependentPathComposer(cpu, sourceCPU), FromFreeBSDToRTEMSSourceConverter(), NoConverter(), assertSourceFile, SourceFileMakefileFragmentComposer())
def addTest(self, testName, fileFragments, runTest = True):
self.files.append(File(testName, PathComposer(), NoConverter(), NoConverter(), TestMakefileFragementComposer(testName, fileFragments, runTest)))
def addTest(self, testName, fileFragments, runTest = True, netTest = False):
self.files.append(File(testName, PathComposer(), NoConverter(), NoConverter(), TestMakefileFragementComposer(testName, fileFragments, runTest, netTest)))
def addDependency(self, dep):
self.dependencies.append(dep)

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2013 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
* 82178 Puchheim
* Germany
* <rtems@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.
*/
#ifndef _RTEMS_BSD_TEST_NETWORK_CONFIG_H_
#define _RTEMS_BSD_TEST_NETWORK_CONFIG_H_
#include <bsp.h>
#if defined(LIBBSP_ARM_REALVIEW_PBX_A9_BSP_H)
#define NET_CFG_INTERFACE_0 "smc0"
#else
#define NET_CFG_INTERFACE_0 "lo0"
#endif
#define NET_CFG_SELF_IP "@NET_CFG_SELF_IP@"
#define NET_CFG_NETMASK "@NET_CFG_NETMASK@"
#define NET_CFG_PEER_IP "@NET_CFG_PEER_IP@"
#define NET_CFG_GATEWAY_IP "@NET_CFG_GATEWAY_IP@"
#endif /* _RTEMS_BSD_TEST_NETWORK_CONFIG_H_ */