mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-07-23 04:00:39 +08:00
Add network test support
This commit is contained in:
parent
fafa9e2716
commit
6ab78d66d4
1
.gitignore
vendored
1
.gitignore
vendored
@ -14,6 +14,7 @@ freebsd/lib/libc/net/nslexer.c
|
|||||||
freebsd/lib/libc/net/nsparser.c
|
freebsd/lib/libc/net/nsparser.c
|
||||||
rtemsbsd/rtems/rtems-kvm-symbols.c
|
rtemsbsd/rtems/rtems-kvm-symbols.c
|
||||||
rtemsbsd/include/machine/rtems-bsd-kernel-space.h
|
rtemsbsd/include/machine/rtems-bsd-kernel-space.h
|
||||||
|
testsuite/include/rtems/bsd/test/network-config.h
|
||||||
/*.i
|
/*.i
|
||||||
/*.s
|
/*.s
|
||||||
/log
|
/log
|
||||||
|
20
Makefile
20
Makefile
@ -33,8 +33,14 @@ NEED_DUMMY_PIC_IRQ=yes
|
|||||||
# do nothing default so sed on rtems-bsd-kernel-space.h always works.
|
# do nothing default so sed on rtems-bsd-kernel-space.h always works.
|
||||||
SED_PATTERN += -e 's/^//'
|
SED_PATTERN += -e 's/^//'
|
||||||
|
|
||||||
|
TEST_NETWORK_CONFIG = testsuite/include/rtems/bsd/test/network-config.h
|
||||||
|
|
||||||
TESTS =
|
TESTS =
|
||||||
RUN_TESTS =
|
RUN_TESTS =
|
||||||
|
|
||||||
|
NET_TESTS =
|
||||||
|
RUN_NET_TESTS =
|
||||||
|
|
||||||
O_FILES =
|
O_FILES =
|
||||||
D_FILES =
|
D_FILES =
|
||||||
|
|
||||||
@ -937,14 +943,26 @@ LIB_O_FILES = $(LIB_C_FILES:%.c=%.o)
|
|||||||
O_FILES += $(LIB_O_FILES)
|
O_FILES += $(LIB_O_FILES)
|
||||||
D_FILES += $(LIB_C_FILES:%.c=%.d)
|
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)
|
$(LIB): $(LIB_GEN_FILES) $(LIB_O_FILES)
|
||||||
$(AR) rcu $@ $^
|
$(AR) rcu $@ $^
|
||||||
|
|
||||||
run_tests: $(RUN_TESTS)
|
run_tests: $(RUN_TESTS)
|
||||||
$(TEST_RUNNER) $^
|
$(TEST_RUNNER) $^
|
||||||
check_endof
|
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
|
# 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
|
rtemsbsd/include/machine/rtems-bsd-kernel-space.h: rtemsbsd/include/machine/rtems-bsd-kernel-space.h.in
|
||||||
sed $(SED_PATTERN) <$< >$@
|
sed $(SED_PATTERN) <$< >$@
|
||||||
|
@ -3,3 +3,8 @@ RTEMS_MAKEFILE_PATH = ${HOME}/newbsd/bsp-install/mips-rtems4.11/$(BSP)
|
|||||||
INSTALL_BASE = ${HOME}/newbsd/install
|
INSTALL_BASE = ${HOME}/newbsd/install
|
||||||
DISABLE_IPV6=no
|
DISABLE_IPV6=no
|
||||||
TEST_RUNNER = $(BSP)
|
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
|
||||||
|
@ -304,10 +304,11 @@ class SourceFileMakefileFragmentComposer(MakefileFragmentComposer):
|
|||||||
return 'LIB_C_FILES += ' + path + '\n'
|
return 'LIB_C_FILES += ' + path + '\n'
|
||||||
|
|
||||||
class TestMakefileFragementComposer(MakefileFragmentComposer):
|
class TestMakefileFragementComposer(MakefileFragmentComposer):
|
||||||
def __init__(self, testName, fileFragments, runTest):
|
def __init__(self, testName, fileFragments, runTest, netTest):
|
||||||
self.testName = testName
|
self.testName = testName
|
||||||
self.fileFragments = fileFragments
|
self.fileFragments = fileFragments
|
||||||
self.runTest = runTest
|
self.runTest = runTest
|
||||||
|
self.netTest = netTest
|
||||||
|
|
||||||
def compose(self, path):
|
def compose(self, path):
|
||||||
testPrefix = 'TEST_' + self.testName.upper()
|
testPrefix = 'TEST_' + self.testName.upper()
|
||||||
@ -316,6 +317,9 @@ class TestMakefileFragementComposer(MakefileFragmentComposer):
|
|||||||
testDir = 'testsuite/' + self.testName
|
testDir = 'testsuite/' + self.testName
|
||||||
testExe = testDir + '/' + self.testName + '.exe'
|
testExe = testDir + '/' + self.testName + '.exe'
|
||||||
testMap = testDir + '/' + self.testName + '.map'
|
testMap = testDir + '/' + self.testName + '.map'
|
||||||
|
testCollection = 'TESTS'
|
||||||
|
if self.netTest:
|
||||||
|
testCollection = 'NET_' + testCollection
|
||||||
makefileFragment = '\n' + testPrefix + ' = ' + testExe + '\n' \
|
makefileFragment = '\n' + testPrefix + ' = ' + testExe + '\n' \
|
||||||
+ testOFiles + ' =\n' \
|
+ testOFiles + ' =\n' \
|
||||||
+ testDFiles + ' =\n'
|
+ testDFiles + ' =\n'
|
||||||
@ -324,11 +328,11 @@ class TestMakefileFragementComposer(MakefileFragmentComposer):
|
|||||||
+ testDFiles + ' += ' + testDir + '/' + fileFragment + '.d\n'
|
+ testDFiles + ' += ' + testDir + '/' + fileFragment + '.d\n'
|
||||||
makefileFragment = makefileFragment + '$(' + testPrefix + '): $(' + testOFiles + ') $(LIB)\n' \
|
makefileFragment = makefileFragment + '$(' + testPrefix + '): $(' + testOFiles + ') $(LIB)\n' \
|
||||||
'\t$(LINK.c) -Wl,-Map,' + testMap + ' $^ -lm -lz -o $@\n' \
|
'\t$(LINK.c) -Wl,-Map,' + testMap + ' $^ -lm -lz -o $@\n' \
|
||||||
'TESTS += $(' + testPrefix + ')\n' \
|
+ testCollection + ' += $(' + testPrefix + ')\n' \
|
||||||
'O_FILES += $(' + testOFiles + ')\n' \
|
'O_FILES += $(' + testOFiles + ')\n' \
|
||||||
'D_FILES += $(' + testDFiles + ')\n'
|
'D_FILES += $(' + testDFiles + ')\n'
|
||||||
if self.runTest:
|
if self.runTest:
|
||||||
makefileFragment = makefileFragment + 'RUN_TESTS += $(' + testPrefix + ')\n'
|
makefileFragment = makefileFragment + 'RUN_' + testCollection + ' += $(' + testPrefix + ')\n'
|
||||||
return makefileFragment
|
return makefileFragment
|
||||||
|
|
||||||
class File(object):
|
class File(object):
|
||||||
@ -419,8 +423,14 @@ class ModuleManager:
|
|||||||
'# do nothing default so sed on rtems-bsd-kernel-space.h always works.\n' \
|
'# do nothing default so sed on rtems-bsd-kernel-space.h always works.\n' \
|
||||||
'SED_PATTERN += -e \'s/^//\'\n' \
|
'SED_PATTERN += -e \'s/^//\'\n' \
|
||||||
'\n' \
|
'\n' \
|
||||||
|
'TEST_NETWORK_CONFIG = testsuite/include/rtems/bsd/test/network-config.h\n' \
|
||||||
|
'\n' \
|
||||||
'TESTS =\n' \
|
'TESTS =\n' \
|
||||||
'RUN_TESTS =\n' \
|
'RUN_TESTS =\n' \
|
||||||
|
'\n' \
|
||||||
|
'NET_TESTS =\n' \
|
||||||
|
'RUN_NET_TESTS =\n' \
|
||||||
|
'\n' \
|
||||||
'O_FILES =\n' \
|
'O_FILES =\n' \
|
||||||
'D_FILES =\n' \
|
'D_FILES =\n' \
|
||||||
'\n' \
|
'\n' \
|
||||||
@ -452,14 +462,26 @@ class ModuleManager:
|
|||||||
'O_FILES += $(LIB_O_FILES)\n' \
|
'O_FILES += $(LIB_O_FILES)\n' \
|
||||||
'D_FILES += $(LIB_C_FILES:%.c=%.d)\n' \
|
'D_FILES += $(LIB_C_FILES:%.c=%.d)\n' \
|
||||||
'\n' \
|
'\n' \
|
||||||
'all: $(LIB) $(TESTS)\n' \
|
'all: $(LIB) $(TESTS) $(TEST_NETWORK_CONFIG) $(NET_TESTS)\n' \
|
||||||
'\n' \
|
'\n' \
|
||||||
'$(LIB): $(LIB_GEN_FILES) $(LIB_O_FILES)\n' \
|
'$(LIB): $(LIB_GEN_FILES) $(LIB_O_FILES)\n' \
|
||||||
'\t$(AR) rcu $@ $^\n' \
|
'\t$(AR) rcu $@ $^\n' \
|
||||||
|
'\n' \
|
||||||
'run_tests: $(RUN_TESTS)\n' \
|
'run_tests: $(RUN_TESTS)\n' \
|
||||||
'\t$(TEST_RUNNER) $^\n' \
|
'\t$(TEST_RUNNER) $^\n' \
|
||||||
'\tcheck_endof\n' \
|
'\tcheck_endof\n' \
|
||||||
'\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' \
|
'# 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' \
|
'rtemsbsd/include/machine/rtems-bsd-kernel-space.h: rtemsbsd/include/machine/rtems-bsd-kernel-space.h.in\n' \
|
||||||
'\tsed $(SED_PATTERN) <$< >$@\n' \
|
'\tsed $(SED_PATTERN) <$< >$@\n' \
|
||||||
@ -590,8 +612,8 @@ class Module:
|
|||||||
self.initCPUDependencies(cpu)
|
self.initCPUDependencies(cpu)
|
||||||
self.cpuDependentSourceFiles [cpu] = self.addFiles(self.cpuDependentSourceFiles [cpu], files, TargetSourceCPUDependentPathComposer(cpu, sourceCPU), FromFreeBSDToRTEMSSourceConverter(), NoConverter(), assertSourceFile, SourceFileMakefileFragmentComposer())
|
self.cpuDependentSourceFiles [cpu] = self.addFiles(self.cpuDependentSourceFiles [cpu], files, TargetSourceCPUDependentPathComposer(cpu, sourceCPU), FromFreeBSDToRTEMSSourceConverter(), NoConverter(), assertSourceFile, SourceFileMakefileFragmentComposer())
|
||||||
|
|
||||||
def addTest(self, testName, fileFragments, runTest = True):
|
def addTest(self, testName, fileFragments, runTest = True, netTest = False):
|
||||||
self.files.append(File(testName, PathComposer(), NoConverter(), NoConverter(), TestMakefileFragementComposer(testName, fileFragments, runTest)))
|
self.files.append(File(testName, PathComposer(), NoConverter(), NoConverter(), TestMakefileFragementComposer(testName, fileFragments, runTest, netTest)))
|
||||||
|
|
||||||
def addDependency(self, dep):
|
def addDependency(self, dep):
|
||||||
self.dependencies.append(dep)
|
self.dependencies.append(dep)
|
||||||
|
51
testsuite/include/rtems/bsd/test/network-config.h.in
Normal file
51
testsuite/include/rtems/bsd/test/network-config.h.in
Normal 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_ */
|
Loading…
x
Reference in New Issue
Block a user