tests: add tests for TCP with nc
This commit is contained in:
parent
a18735eded
commit
c3619612ae
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: mi,v 1.1224 2022/10/11 09:55:21 knakahara Exp $
|
||||
# $NetBSD: mi,v 1.1225 2022/11/02 09:37:56 ozaki-r Exp $
|
||||
#
|
||||
# Note: don't delete entries from here - mark them as "obsolete" instead.
|
||||
#
|
||||
|
@ -4283,6 +4283,10 @@
|
|||
./usr/tests/net/sys/t_listen tests-obsolete obsolete
|
||||
./usr/tests/net/sys/t_rfc6056 tests-net-tests compattestfile,atf
|
||||
./usr/tests/net/sys/t_socketpair tests-obsolete obsolete
|
||||
./usr/tests/net/tcp tests-net-tests compattestfile,atf
|
||||
./usr/tests/net/tcp/Atffile tests-net-tests compattestfile,atf
|
||||
./usr/tests/net/tcp/Kyuafile tests-net-tests compattestfile,atf,kyua
|
||||
./usr/tests/net/tcp/t_tcp_nc tests-net-tests compattestfile,atf
|
||||
./usr/tests/net/wireguard tests-obsolete obsolete
|
||||
./usr/tests/net/wireguard/Atffile tests-obsolete obsolete
|
||||
./usr/tests/net/wireguard/Kyuafile tests-obsolete obsolete
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: NetBSD.dist.tests,v 1.193 2022/07/21 09:52:48 kre Exp $
|
||||
# $NetBSD: NetBSD.dist.tests,v 1.194 2022/11/02 09:37:56 ozaki-r Exp $
|
||||
|
||||
./usr/libdata/debug/usr/tests
|
||||
./usr/libdata/debug/usr/tests/atf
|
||||
|
@ -382,6 +382,7 @@
|
|||
./usr/tests/net/npf
|
||||
./usr/tests/net/route
|
||||
./usr/tests/net/sys
|
||||
./usr/tests/net/tcp
|
||||
./usr/tests/rump
|
||||
./usr/tests/rump/modautoload
|
||||
./usr/tests/rump/rumpkern
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.39 2021/07/14 03:22:33 ozaki-r Exp $
|
||||
# $NetBSD: Makefile,v 1.40 2022/11/02 09:37:56 ozaki-r Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
|
@ -9,7 +9,7 @@ TESTS_SUBDIRS= fdpass in_cksum net sys
|
|||
TESTS_SUBDIRS+= altq arp bpf bpfilter can carp icmp if if_bridge if_gif
|
||||
TESTS_SUBDIRS+= if_ipsec if_l2tp if_lagg if_loop if_pppoe if_tap
|
||||
TESTS_SUBDIRS+= if_tun if_vether if_vlan if_wg ipsec mcast mpls
|
||||
TESTS_SUBDIRS+= ndp npf route
|
||||
TESTS_SUBDIRS+= ndp npf route tcp
|
||||
.if (${MKSLJIT} != "no")
|
||||
TESTS_SUBDIRS+= bpfjit
|
||||
.endif
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# $NetBSD: Makefile,v 1.1 2022/11/02 09:37:56 ozaki-r Exp $
|
||||
#
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
TESTSDIR= ${TESTSBASE}/net/tcp
|
||||
|
||||
.for name in tcp_nc
|
||||
TESTS_SH+= t_${name}
|
||||
TESTS_SH_SRC_t_${name}= ../net_common.sh t_${name}.sh
|
||||
.endfor
|
||||
|
||||
.include <bsd.test.mk>
|
|
@ -0,0 +1,161 @@
|
|||
# $NetBSD: t_tcp_nc.sh,v 1.1 2022/11/02 09:37:56 ozaki-r Exp $
|
||||
#
|
||||
# Copyright (c) 2022 Internet Initiative Japan Inc.
|
||||
# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
#
|
||||
|
||||
SOCK_LOCAL=unix://tcp_nc_local
|
||||
SOCK_PEER=unix://tcp_nc_peer
|
||||
BUS=./bus_tcp_nc
|
||||
FILE_SND=./file.snd
|
||||
FILE_RCV=./file.rcv
|
||||
IP_LOCAL=10.0.0.1
|
||||
IP_PEER=10.0.0.2
|
||||
NC_OPTS="-w 3"
|
||||
|
||||
DEBUG=${DEBUG:-false}
|
||||
|
||||
setup_servers()
|
||||
{
|
||||
|
||||
rump_server_start $SOCK_LOCAL
|
||||
rump_server_start $SOCK_PEER
|
||||
rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
|
||||
rump_server_add_iface $SOCK_PEER shmif0 $BUS
|
||||
export RUMP_SERVER=$SOCK_LOCAL
|
||||
atf_check -s exit:0 rump.ifconfig shmif0 $IP_LOCAL/24
|
||||
export RUMP_SERVER=$SOCK_PEER
|
||||
atf_check -s exit:0 rump.ifconfig shmif0 $IP_PEER/24
|
||||
}
|
||||
|
||||
prepare_snd_file()
|
||||
{
|
||||
local file=$FILE_SND
|
||||
local size=${1:-5120}
|
||||
|
||||
# XXX accepts only multiple of 512
|
||||
dd if=/dev/zero of=$file bs=512 count=$(($size / 512))
|
||||
}
|
||||
|
||||
cleanup_file()
|
||||
{
|
||||
|
||||
rm -f $FILE_SND
|
||||
rm -f $FILE_RCV
|
||||
}
|
||||
|
||||
test_tcp_nc_econnrefused()
|
||||
{
|
||||
|
||||
export RUMP_SERVER=$SOCK_LOCAL
|
||||
|
||||
atf_check -s not-exit:0 -e match:'Connection refused' \
|
||||
$HIJACKING nc $NC_OPTS -v 127.0.0.1 80 < $FILE_SND
|
||||
atf_check -s not-exit:0 -e match:'Connection refused' \
|
||||
$HIJACKING nc $NC_OPTS -v $IP_PEER 80 < $FILE_SND
|
||||
}
|
||||
|
||||
test_tcp_nc_rcvbuf()
|
||||
{
|
||||
|
||||
start_nc_server $SOCK_PEER 80 $FILE_RCV ipv4 "-O 16384"
|
||||
|
||||
atf_check -s exit:0 $HIJACKING nc $NC_OPTS $IP_PEER 80 < $FILE_SND
|
||||
}
|
||||
|
||||
test_tcp_nc_small_rcvbuf()
|
||||
{
|
||||
|
||||
start_nc_server $SOCK_PEER 80 $FILE_RCV ipv4 "-O 1024"
|
||||
|
||||
prepare_snd_file $((512 * 1024))
|
||||
atf_check -s exit:0 $HIJACKING nc $NC_OPTS $IP_PEER 80 < $FILE_SND
|
||||
}
|
||||
|
||||
test_tcp_nc_sndbuf()
|
||||
{
|
||||
|
||||
start_nc_server $SOCK_PEER 80 $FILE_RCV ipv4
|
||||
|
||||
atf_check -s exit:0 $HIJACKING nc $NC_OPTS -I 16384 $IP_PEER 80 < $FILE_SND
|
||||
}
|
||||
|
||||
test_tcp_nc_small_sndbuf()
|
||||
{
|
||||
|
||||
start_nc_server $SOCK_PEER 80 $FILE_RCV ipv4
|
||||
|
||||
prepare_snd_file $((512 * 1024))
|
||||
atf_check -s exit:0 $HIJACKING nc $NC_OPTS -I 1024 $IP_PEER 80 < $FILE_SND
|
||||
}
|
||||
|
||||
test_tcp_nc_md5sig()
|
||||
{
|
||||
|
||||
atf_expect_fail "TCP_SIGNATURE is not enabled by default"
|
||||
|
||||
start_nc_server $SOCK_PEER 80 $FILE_RCV ipv4
|
||||
|
||||
atf_check -s exit:0 $HIJACKING nc $NC_OPTS -S $IP_PEER 80 < $FILE_SND
|
||||
}
|
||||
|
||||
add_test_tcp_nc()
|
||||
{
|
||||
local type=$1
|
||||
local name= desc=
|
||||
|
||||
desc="Test TCP with nc ($type)"
|
||||
name="tcp_nc_${type}"
|
||||
|
||||
atf_test_case ${name} cleanup
|
||||
eval "
|
||||
${name}_head() {
|
||||
atf_set descr \"$desc\"
|
||||
atf_set require.progs rump_server nc
|
||||
}
|
||||
${name}_body() {
|
||||
setup_servers
|
||||
prepare_snd_file
|
||||
test_tcp_nc_$type
|
||||
rump_server_destroy_ifaces
|
||||
}
|
||||
${name}_cleanup() {
|
||||
cleanup_file
|
||||
\$DEBUG && dump
|
||||
cleanup
|
||||
}
|
||||
"
|
||||
atf_add_test_case ${name}
|
||||
}
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
|
||||
add_test_tcp_nc econnrefused
|
||||
add_test_tcp_nc rcvbuf
|
||||
add_test_tcp_nc small_rcvbuf
|
||||
add_test_tcp_nc sndbuf
|
||||
add_test_tcp_nc small_sndbuf
|
||||
add_test_tcp_nc md5sig
|
||||
}
|
Loading…
Reference in New Issue