Don't assume sa.sa_family is a short int.
[tinc] / test / ns-ping.test
1 #!/bin/sh
2
3 . ./testlib.sh
4
5 # Skip this test if we aren't root or if "ip netns" does not exist
6
7 test "`id -u`" = "0" || exit 77
8 ip netns list || exit 77
9
10 # Initialize two nodes
11
12 $tinc $c1 <<EOF
13 init foo
14 set Mode switch
15 set Interface ping.test1
16 set Port 32573
17 set Address localhost
18 EOF
19
20 cat >$d1/tinc-up <<EOF
21 #!/bin/sh
22 ip netns add ping.test1
23 ip link set dev \$INTERFACE netns ping.test1
24 ip netns exec ping.test1 ip addr add 192.168.1.1/24 dev \$INTERFACE
25 ip netns exec ping.test1 ip link set \$INTERFACE up
26 EOF
27
28 $tinc $c2 <<EOF
29 init bar
30 set Mode switch
31 set Interface ping.test2
32 set Port 32574
33 EOF
34
35 cat >$d2/tinc-up <<EOF
36 #!/bin/sh
37 ip netns add ping.test2
38 ip link set dev \$INTERFACE netns ping.test2
39 ip netns exec ping.test2 ip addr add 192.168.1.2/24 dev \$INTERFACE
40 ip netns exec ping.test2 ip link set \$INTERFACE up
41 EOF
42
43 # Exchange configuration files
44
45 $tinc $c1 export | $tinc $c2 exchange | $tinc $c1 import
46
47 # Start tinc
48
49 $tinc $c1 start $r1
50 $tinc $c2 start $r2
51
52 sleep 1
53
54 # The nodes should not be able to ping each other if there is no connection
55
56 ip netns exec ping.test1 ping -W1 -c3 192.168.1.2 && exit 1
57
58 # After connecting they should be
59
60 $tinc $c2 add ConnectTo foo
61 sleep 1
62
63 ip netns exec ping.test1 ping -W1 -c3 192.168.1.2
64
65 # Clean up
66
67 $tinc $c2 stop
68 $tinc $c1 stop
69 ip netns del ping.test2
70 ip netns del ping.test1