Add tests to cover some of the fixed leaks.
[tinc] / test / commandline.test
1 #!/bin/sh
2
3 . ./testlib.sh
4
5 echo [STEP] Initialize one node
6
7 tinc foo <<EOF
8 init foo
9 set DeviceType dummy
10 set Port 0
11 EOF
12
13 create_script foo tinc-up '
14   tinc foo stop &
15 '
16
17 echo [STEP] Test tincd command line options that should work
18
19 tincd foo -D
20 tincd foo --no-detach
21 tincd foo -D -d
22 tincd foo -D -d2
23 tincd foo -D -d 2
24 tincd foo -D -n foo
25 tincd foo -D -nfoo
26 tincd foo -D --net=foo
27 tincd foo -D --net foo
28
29 echo [STEP] Test tincd command line options that should not work
30
31 must_fail tincd foo foo
32 must_fail tincd foo --pidfile
33 must_fail tincd foo --foo
34
35 echo [STEP] Test tinc command line options that should work
36
37 tinc foo get name
38 tinc foo -n foo get name
39 tinc foo -nfoo get name
40 tinc foo --net=foo get name
41 tinc foo --net foo get name
42
43 echo [STEP] Test tinc command line options that should not work
44
45 must_fail tinc foo -n foo get somethingreallyunknown
46 must_fail tinc foo --net
47 must_fail tinc foo --net get name
48 must_fail tinc foo foo
49
50 # Most of these should fail with ASAN. Some leaks are only detected by Valgrind.
51 echo [STEP] Trigger previously known memory leaks
52
53 tincd foo -c . -c . --help
54 tincd foo -n net -n net --help
55 tincd foo -n net -o FakeOpt=42 --help
56 tincd foo --logfile=one --logfile=two --help
57 tincd foo --pidfile=one --pidfile=two --help
58 expect_code "$EXIT_FAILURE" tincd foo -n net -o Compression= --help
59 expect_code "$EXIT_FAILURE" tincd foo -c fakedir -n 'n/e\t'
60
61 tinc foo -c conf -c conf --help
62 tinc foo -n net -n net --help
63 tinc foo --pidfile=pid --pidfile=pid --help
64 expect_code "$EXIT_FAILURE" tinc foo -c conf -n 'n/e\t'