Don't assume sa.sa_family is a short int.
[tinc] / test / variables.test
1 #!/bin/sh
2
3 . ./testlib.sh
4
5 # Initialize one node
6
7 $tinc $c1 init foo
8 test "`$tinc $c1 get Name`" = "foo"
9
10 # Test case sensitivity
11
12 $tinc $c1 set Mode switch
13 test "`$tinc $c1 get Mode`" = "switch"
14 test "`$tinc $c1 get mode`" = "switch"
15 $tinc $c1 set mode router
16 test "`$tinc $c1 get Mode`" = "router"
17 test "`$tinc $c1 get mode`" = "router"
18 $tinc $c1 set Mode Switch
19 test "`$tinc $c1 get Mode`" = "Switch"
20
21 # Test deletion
22
23 $tinc $c1 del Mode hub && exit 1 || true
24 $tinc $c1 del Mode switch
25 test -z "`$tinc $c1 get Mode`"
26
27 # There can only be one Mode variable
28
29 $tinc $c1 add Mode switch
30 $tinc $c1 add Mode hub
31 test "`$tinc $c1 get Mode`" = "hub"
32
33 # Test addition/deletion of multivalued variables
34
35 $tinc $c1 add Subnet 1
36 $tinc $c1 add Subnet 2
37 $tinc $c1 add Subnet 2
38 $tinc $c1 add Subnet 3
39 test "`$tinc $c1 get Subnet`" = "1
40 2
41 3"
42 $tinc $c1 del Subnet 2
43 test "`$tinc $c1 get Subnet`" = "1
44 3"
45 $tinc $c1 del Subnet
46 test -z "`$tinc $c1 get Subnet`"
47
48 # We should not be able to get/set server variables using node.variable syntax
49
50 test -z "`$tinc $c1 get foo.Name`"
51 $tinc $c1 set foo.Name bar && exit 1 || true
52
53 # Test getting/setting host variables for other nodes
54
55 touch $d1/hosts/bar
56
57 $tinc $c1 add bar.PMTU 1
58 $tinc $c1 add bar.PMTU 2
59 test "`$tinc $c1 get bar.PMTU`" = "2"
60
61 $tinc $c1 add bar.Subnet 1
62 $tinc $c1 add bar.Subnet 2
63 $tinc $c1 add bar.Subnet 2
64 $tinc $c1 add bar.Subnet 3
65 test "`$tinc $c1 get bar.Subnet`" = "1
66 2
67 3"
68 $tinc $c1 del bar.Subnet 2
69 test "`$tinc $c1 get bar.Subnet`" = "1
70 3"
71 $tinc $c1 del bar.Subnet
72 test -z "`$tinc $c1 get bar.Subnet`"
73
74 # We should not be able to get/set for nodes with invalid names
75
76 touch $d1/hosts/qu-ux
77
78 $tinc $c1 set qu-ux.Subnet 1 && exit 1 || true
79
80 # We should not be able to set obsolete variables unless forced
81
82 $tinc $c1 set PrivateKey 12345 && exit 1 || true
83 $tinc $c1 --force set PrivateKey 12345
84 test "`$tinc $c1 get PrivateKey`" = "12345"
85 $tinc $c1 del PrivateKey
86 test -z "`$tinc $c1 get PrivateKey`"