Fix running the test suite in out-of-tree builds.
[tinc] / test / import-export.test
1 #!/bin/sh
2
3 # shellcheck source=testlib.sh
4 . ./testlib.sh
5
6 echo [STEP] Initialize three nodes
7
8 tinc foo <<EOF
9 init foo
10 set DeviceType dummy
11 set Port 30000
12 set Address localhost
13 EOF
14
15 tinc bar <<EOF
16 init bar
17 set DeviceType dummy
18 set Port 0
19 EOF
20
21 tinc baz <<EOF
22 init baz
23 set DeviceType dummy
24 set Port 0
25 EOF
26
27 echo [STEP] Test import, export and exchange commands
28
29 tinc foo export | tinc bar exchange | tinc foo import
30
31 echo [STEP] Test export-all and exchange-all
32
33 tinc foo export-all | tinc baz exchange | tinc foo import
34 tinc foo exchange-all </dev/null | tinc bar import
35
36 echo [STEP] Test equivalence of host config files
37
38 diff -w "$DIR_FOO/hosts/foo" "$DIR_BAR/hosts/foo"
39 diff -w "$DIR_FOO/hosts/foo" "$DIR_BAZ/hosts/foo"
40 diff -w "$DIR_FOO/hosts/bar" "$DIR_BAR/hosts/bar"
41 diff -w "$DIR_FOO/hosts/bar" "$DIR_BAZ/hosts/bar"
42 diff -w "$DIR_FOO/hosts/baz" "$DIR_BAR/hosts/baz"
43 diff -w "$DIR_FOO/hosts/baz" "$DIR_BAZ/hosts/baz"
44
45 echo [STEP] Check whether the nodes can connect to each other
46
47 create_script foo tinc-up '
48   tinc bar add ConnectTo foo
49   tinc baz add ConnectTo foo
50 '
51
52 create_script foo hosts/bar-up
53 create_script foo hosts/baz-up
54
55 start_tinc foo
56
57 wait_script foo tinc-up
58
59 start_tinc bar
60 start_tinc baz
61
62 wait_script foo hosts/bar-up
63 wait_script foo hosts/baz-up
64
65 require_nodes foo 3
66 require_nodes bar 3
67 require_nodes baz 3