]> rtime.felk.cvut.cz Git - novaboot.git/blob - tests/novaboot.wv
tests: Fix ssh key setup for server tests
[novaboot.git] / tests / novaboot.wv
1 #!/usr/bin/env bash
2
3 cd $(dirname $0)
4 . wvtest.sh
5
6 WVSTART Invoke with no script
7 WVPASS novaboot -t '' < /dev/null
8
9 WVSTART Invoke as script
10 create_dummy
11 WVPASS ./script --gen-only
12
13 WVSTART Invoke as script with absolute path
14 create_dummy
15 WVPASS $PWD/script --gen-only
16
17 WVSTART Pulsar root
18 create_dummy
19 WVPASS ./script --gen-only --pulsar --pulsar-root=ASDF
20 WVPASS grep "root ASDF" config-novaboot
21
22 WVSTART Pulsar supports chld
23 create_script <<EOF
24 chld grub
25 EOF
26 WVPASS ./script --gen-only --pulsar
27 WVPASS grep "chld grub" config-novaboot
28
29 WVSTART GRUB2 with default BOOT_METHOD=multiboot
30 create_script <<EOF
31 load kernel
32 load ramdisk
33 EOF
34 WVPASS ./script --gen-only --grub2
35 WVPASS git diff --no-index --color - boot/grub/grub.cfg <<EOF
36 menuentry script {
37   multiboot kernel 
38   module ramdisk ramdisk
39 }
40 EOF
41
42 WVSTART GRUB2 with BOOT_METHOD=linux
43 create_script <<EOF
44 BOOT_METHOD=linux
45 load kernel
46 load ramdisk
47 EOF
48 WVPASS ./script --gen-only --grub2
49 WVPASS git diff --no-index --color - boot/grub/grub.cfg <<EOF
50 menuentry script {
51   linux kernel 
52   initrd ramdisk
53 }
54 EOF
55
56 WVSTART Configuration files
57 create_dummy
58 echo '1;' > .novaboot
59 WVPASS sh -c "./script --gen-only 2> log"
60 WVPASS grep "novaboot: Read $PWD/.novaboot" log
61
62 WVSTART Configuration files in symlinked directories
63 mkdir config
64 echo '1;' > config/.novaboot
65 mkdir script
66 ( cd script; create_dummy )
67 ln -s ../script config
68 WVPASS sh -c "./config/script/script --gen-only 2> log"
69 WVPASS grep "novaboot: Read $PWD/config/.novaboot" log
70
71 WVSTART Builddir configuration variable
72 WVPASS mkdir -p build
73 cat > .novaboot <<'EOF'
74 $builddir="build";
75 1;
76 EOF
77 create_script <<'EOF'
78 load file < echo Hello
79 EOF
80 WVPASS ./script --gen-only
81 WVPASS test -f build/file
82
83 WVSTART Configuration directory
84 mkdir -p dir
85 echo '$test_a = 1;' > dir/a
86 echo '$test_c = 2;' > dir/c
87 echo '$test_c = 1;' > dir/b     # Overriden by the 'c' file
88 echo '$test_ign=1;' > dir/b.txt # Ignored
89 WVPASS sh -c 'NOVABOOT_CONFIG_DIR=./dir novaboot --dump-config > config'
90 WVPASS sh -c 'grep \$test config > test'
91 WVPASS diff -u - test <<'EOF'
92 $test_a = 1;
93 $test_c = 2;
94 EOF
95
96 WVSTART Fail with unknown target
97 create_dummy
98 WVFAIL sh -c "./script --gen-only -t non-existing-target"
99
100 WVSTART BUILDDIR variable
101 WVPASS mkdir -p build
102 create_script <<'EOF'
103 BUILDDIR=build
104 load file < echo Hello
105 EOF
106 WVPASS ./script --gen-only
107 WVPASS test -f build/file
108
109 WVSTART Hypervisor configuration variable
110 create_dummy
111 echo '$hypervisor="HYP";' > .novaboot
112 WVPASS ./script --gen-only --pulsar
113 WVPASS grep "exec HYP" config-novaboot
114
115 WVSTART ISO image generation
116 create_dummy
117 WVPASS ./script --iso --gen-only
118
119 WVSTART Recursive target definition
120 create_dummy
121 cat > .novaboot <<EOF
122 %targets = (
123     't1' => '--reset-cmd="echo MyResetCmd"',
124     't2' => '--target t1',
125 );
126 EOF
127 WVPASS sh -c "./script --target=t2|tee output"
128 WVPASS grep -q ^MyResetCmd output
129
130 WVSTART Wrong target definition
131 create_dummy
132 cat > .novaboot <<EOF
133 %targets = ('t1' => '--nonsense');
134 EOF
135 WVPASS sh -c "./script --target=t1 2>&1 |tee output"
136 WVPASS grep -q "Error in target definition" output
137
138 WVSTART Different ways of specifying target
139 cat > .novaboot <<'EOF'
140 %targets = ('t1' => '--remote-cmd="echo Target1 > t"',
141             't2' => '--remote-cmd="echo Target2 > t"',
142             't3' => '--remote-cmd="echo Target3 > t"');
143 $default_target = 't1';
144 EOF
145 WVPASSSH 'novaboot /dev/null'
146 WVPASS test "$(cat t)" = Target1
147 WVPASSSH 'NOVABOOT_TARGET=t2 novaboot /dev/null'
148 WVPASS test "$(cat t)" = Target2
149 WVPASSSH 'NOVABOOT_TARGET=t2 novaboot --target t3 /dev/null'
150 WVPASS test "$(cat t)" = Target3
151
152 WVSTART --iprelay-cmd
153 WVPASS novaboot --iprelay-cmd="$(which echo) -e '<iprelayd: connected>\xFF\xFA\x2C\x97\xDF\xFF\xF0 \xFF\xFA\x2C\x97\xFF\xFF\xF0'" --on
154
155 WVSTART Killing of --remote-cmd when it ignores SIGHUP
156 WVPASS tee script <<'EOF'
157 $SIG{HUP}='IGNORE';
158 open(FH, ">", "pid") or die;
159 print FH "$$";
160 close FH;
161 print "ready pid=$$\n";
162 print "exit\n";
163 sleep;
164 EOF
165 WVPASS novaboot --remote-cmd='perl script' --remote-expect=ready --exiton=exit /dev/null
166 WVFAIL test -d /proc/$(cat pid)
167 coproc novaboot --remote-cmd='perl script' --remote-expect=ready /dev/null
168 WVPASS sed -e '/ready/q0' <&${COPROC[0]}
169 WVPASS kill $COPROC_PID
170 WVFAIL wait $COPROC_PID # Signal termination is considered a failure
171 WVFAIL test -d /proc/$(cat pid)
172
173 WVSTART Correct invocation path
174 WVPASS mkdir dir
175 WVPASS tee dir/.novaboot <<<'print "Config OK\n";'
176 (
177     WVPASS cd dir
178     WVPASS novaboot /dev/null | WVPASS grep "Config OK"
179 )
180 WVPASS tee dir/Makefile <<EOF
181 all:
182         novaboot /dev/null
183 EOF
184 WVPASS make -C dir | WVPASS grep "Config OK"
185
186 WVSTART "INTERACTION variable"
187 WVPASS novaboot --remote-cmd=cat <<<INTERACTION=0
188
189 WVSTART "Do not accept directories"
190 WVPASS mkdir -p tftproot
191 WVFAIL novaboot --server=tftproot <<<"load $PWD"
192
193 WVSTART "Accept /dev/null file"
194 WVPASS mkdir -p tftproot
195 WVPASS novaboot --server=tftproot <<<"load /dev/null"
196
197 # Hi-lock: (("^.*\\(?:WVSTART\\).*$" (0 (quote hi-black-b) t)))