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