Use getmsg()/putmsg() instead of read()/write() on Solaris.
[tinc] / test / scripts.test
1 #!/bin/sh
2
3 . ./testlib.sh
4
5 # Initialize server node
6
7 $tinc $c1 <<EOF
8 init foo
9 set DeviceType dummy
10 set Port 32759
11 set Address 127.0.0.1
12 add Subnet 10.0.0.1
13 add Subnet fec0::/64
14 EOF
15
16 # Set up scripts
17
18 OUT=$d1/scripts.out
19 rm -f $OUT 
20
21 for script in tinc-up tinc-down host-up host-down subnet-up subnet-down hosts/foo-up hosts/foo-down hosts/bar-up hosts/bar-down invitation-created invitation-accepted; do
22 cat >$d1/$script << EOF
23 #!/bin/sh
24 echo $script \$NETNAME,\$NAME,\$DEVICE,\$IFACE,\$NODE,\$REMOTEADDRESS,\$REMOTEPORT,\$SUBNET,\$WEIGHT,\$INVITATION_FILE,\$INVITATION_URL,\$DEBUG >>$OUT
25 EOF
26 chmod u+x $d1/$script
27 done
28
29 # Start server node
30
31 $tinc -n netname $c1 start $r1
32
33 echo foo-started >>$OUT
34
35 # Invite client node
36
37 url=`$tinc -n netname2 $c1 invite bar`
38 file=`cd $d1/invitations; ls | grep -v ed25519_key.priv`
39 echo bar-invited >>$OUT
40 $tinc -n netname3 $c2 join $url
41 echo bar-joined >>$OUT
42
43 # Start and stop client node
44
45 $tinc $c2 << EOF
46 set DeviceType dummy
47 set Port 32760
48 add Subnet 10.0.0.2
49 add Subnet fec0::/64#5
50 start $r2
51 EOF
52
53 sleep 1
54
55 echo bar-started >>$OUT
56
57 $tinc $c1 debug 4
58 $tinc $c2 stop
59
60 sleep 1
61
62 echo bar-stopped >>$OUT
63
64 $tinc $c1 debug 5
65 $tinc $c2 start $r2
66
67 sleep 1
68
69 echo bar-started >>$OUT
70
71 # Stop server node
72
73 $tinc $c1 stop
74
75 # Check if the script output is what is expected
76
77 cat >$OUT.expected << EOF
78 tinc-up netname,foo,dummy,,,,,,,,,5
79 subnet-up netname,foo,dummy,,foo,,,10.0.0.1,,,,5
80 subnet-up netname,foo,dummy,,foo,,,fec0::/64,,,,5
81 foo-started
82 invitation-created netname2,foo,,,bar,,,,,$d1/invitations/$file,$url,
83 bar-invited
84 invitation-accepted netname,foo,dummy,,bar,127.0.0.1,,,,,,5
85 bar-joined
86 host-up netname,foo,dummy,,bar,127.0.0.1,32760,,,,,5
87 hosts/bar-up netname,foo,dummy,,bar,127.0.0.1,32760,,,,,5
88 subnet-up netname,foo,dummy,,bar,127.0.0.1,32760,10.0.0.2,,,,5
89 subnet-up netname,foo,dummy,,bar,127.0.0.1,32760,fec0::/64,5,,,5
90 bar-started
91 host-down netname,foo,dummy,,bar,127.0.0.1,32760,,,,,4
92 hosts/bar-down netname,foo,dummy,,bar,127.0.0.1,32760,,,,,4
93 subnet-down netname,foo,dummy,,bar,127.0.0.1,32760,10.0.0.2,,,,4
94 subnet-down netname,foo,dummy,,bar,127.0.0.1,32760,fec0::/64,5,,,4
95 bar-stopped
96 host-up netname,foo,dummy,,bar,127.0.0.1,32760,,,,,5
97 hosts/bar-up netname,foo,dummy,,bar,127.0.0.1,32760,,,,,5
98 subnet-up netname,foo,dummy,,bar,127.0.0.1,32760,10.0.0.2,,,,5
99 subnet-up netname,foo,dummy,,bar,127.0.0.1,32760,fec0::/64,5,,,5
100 bar-started
101 host-down netname,foo,dummy,,bar,127.0.0.1,32760,,,,,5
102 hosts/bar-down netname,foo,dummy,,bar,127.0.0.1,32760,,,,,5
103 subnet-down netname,foo,dummy,,bar,127.0.0.1,32760,10.0.0.2,,,,5
104 subnet-down netname,foo,dummy,,bar,127.0.0.1,32760,fec0::/64,5,,,5
105 subnet-down netname,foo,dummy,,foo,,,10.0.0.1,,,,5
106 subnet-down netname,foo,dummy,,foo,,,fec0::/64,,,,5
107 tinc-down netname,foo,dummy,,,,,,,,,5
108 EOF
109
110 cmp $OUT $OUT.expected