]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/sys/net/if_tun_test.sh
zfs: merge openzfs/zfs@d96e29576
[FreeBSD/FreeBSD.git] / tests / sys / net / if_tun_test.sh
1 # $FreeBSD$
2
3 . $(atf_get_srcdir)/../common/vnet.subr
4
5 atf_test_case "235704" "cleanup"
6 235704_head()
7 {
8         atf_set descr "Test PR #235704"
9         atf_set require.user root
10 }
11 235704_body()
12 {
13         vnet_init
14         vnet_mkjail one
15
16         tun=$(jexec one ifconfig tun create)
17         jexec one ifconfig ${tun} name foo
18         atf_check -s exit:0 jexec one ifconfig foo destroy
19 }
20 235704_cleanup()
21 {
22         vnet_cleanup
23 }
24
25 atf_test_case "basic" "cleanup"
26 basic_head()
27 {
28         atf_set descr "Test if_tun using nc"
29         atf_set require.user root
30 }
31 basic_body()
32 {
33         vnet_init
34
35         epair=$(vnet_mkepair)
36
37         tun_duke=$(ifconfig tun create)
38         tun_bass=$(ifconfig tun create)
39
40         vnet_mkjail duke ${epair}a ${tun_duke}
41         vnet_mkjail bass ${epair}b ${tun_bass}
42
43         jexec duke ifconfig ${epair}a inet 10.0.0.1/24 up
44         jexec bass ifconfig ${epair}b inet 10.0.0.2/24 up
45
46         jexec duke nc -u -l --tun /dev/${tun_duke} 10.0.0.1 2600 &
47         jexec bass nc -u --tun /dev/${tun_bass} 10.0.0.1 2600 &
48
49         jexec duke ifconfig ${tun_duke} inet 10.100.0.1/24 10.100.0.2 up
50         jexec bass ifconfig ${tun_bass} inet 10.100.0.2/24 10.100.0.1 up
51
52         atf_check -s exit:0 -o ignore \
53                 jexec bass ping -c 1 10.100.0.1
54 }
55 basic_cleanup()
56 {
57         vnet_cleanup
58 }
59
60 atf_init_test_cases()
61 {
62         atf_add_test_case "235704"
63         atf_add_test_case "basic"
64 }