]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/sys/net/if_bridge_test.sh
bridge: Basic test case
[FreeBSD/FreeBSD.git] / tests / sys / net / if_bridge_test.sh
1 # $FreeBSD$
2 #
3 # SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 #
5 # Copyright (c) 2020 The FreeBSD Foundation
6 # All rights reserved.
7 #
8 # This software was developed by Kristof Provost under sponsorship
9 # from the FreeBSD Foundation.
10 #
11 # Redistribution and use in source and binary forms, with or without
12 # modification, are permitted provided that the following conditions
13 # are met:
14 # 1. Redistributions of source code must retain the above copyright
15 #    notice, this list of conditions and the following disclaimer.
16 # 2. Redistributions in binary form must reproduce the above copyright
17 #    notice, this list of conditions and the following disclaimer in the
18 #    documentation and/or other materials provided with the distribution.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 # SUCH DAMAGE.
31
32 . $(atf_get_srcdir)/../common/vnet.subr
33
34 atf_test_case "bridge_transmit_ipv4_unicast" "cleanup"
35 bridge_transmit_ipv4_unicast_head()
36 {
37         atf_set descr 'bridge_transmit_ipv4_unicast bridging test'
38         atf_set require.user root
39 }
40
41 bridge_transmit_ipv4_unicast_body()
42 {
43         vnet_init
44
45         epair_alcatraz=$(vnet_mkepair)
46         epair_singsing=$(vnet_mkepair)
47
48         vnet_mkjail alcatraz ${epair_alcatraz}b
49         vnet_mkjail singsing ${epair_singsing}b
50
51         jexec alcatraz ifconfig ${epair_alcatraz}b 192.0.2.1/24 up
52         jexec singsing ifconfig ${epair_singsing}b 192.0.2.2/24 up
53
54         bridge=$(vnet_mkbridge)
55
56         ifconfig ${bridge} up
57         ifconfig ${epair_alcatraz}a up
58         ifconfig ${epair_singsing}a up
59         ifconfig ${bridge} addm ${epair_alcatraz}a
60         ifconfig ${bridge} addm ${epair_singsing}a
61
62         atf_check -s exit:0 -o ignore jexec alcatraz ping -c 3 -t 1 192.0.2.2
63         atf_check -s exit:0 -o ignore jexec singsing ping -c 3 -t 1 192.0.2.1
64 }
65
66 bridge_transmit_ipv4_unicast_cleanup()
67 {
68         vnet_cleanup
69 }
70
71 atf_init_test_cases()
72 {
73         atf_add_test_case "bridge_transmit_ipv4_unicast"
74 }