Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / tests / test_grub.aug
1 module Test_grub =
2
3   let conf = "# grub.conf generated by anaconda
4 #
5 # Note that you do not have to rerun grub after making changes to this file
6 # NOTICE:  You have a /boot partition.  This means that
7 #          all kernel and initrd paths are relative to /boot/, eg.
8 #          root (hd0,0)
9 #          kernel /vmlinuz-version ro root=/dev/vg00/lv00
10 #          initrd /initrd-version.img
11 boot=/dev/sda
12 device (hd0) HD(1,800,64000,9895c137-d4b2-4e3b-a93b-dc9ac4)
13 password --md5 $1$M9NLj$p2gs87vwNv48BUu.wAfVw0
14 default=0
15 setkey
16 setkey less backquote
17 background 103332
18 timeout=5
19 splashimage=(hd0,0)/grub/splash.xpm.gz
20 gfxmenu=(hd0,0)/boot/message
21 verbose = 0
22 hiddenmenu
23 title Fedora (2.6.24.4-64.fc8)
24         root (hd0,0)
25         kernel /vmlinuz-2.6.24.4-64.fc8 ro root=/dev/vg00/lv00 crashkernel=
26         initrd /initrd-2.6.24.4-64.fc8.img
27 title=Fedora (2.6.24.3-50.fc8)
28         root (hd0,0)
29         kernel /vmlinuz-2.6.24.3-50.fc8 ro root=/dev/vg00/lv00
30         initrd /initrd-2.6.24.3-50.fc8.img
31 title Fedora (2.6.21.7-3.fc8xen)
32         root (hd0,0)
33         kernel /xen.gz-2.6.21.7-3.fc8
34         module /vmlinuz-2.6.21.7-3.fc8xen ro root=/dev/vg00/lv00
35         module /initrd-2.6.21.7-3.fc8xen.img
36 title Fedora (2.6.24.3-34.fc8)
37         root (hd0,0)
38         kernel /vmlinuz-2.6.24.3-34.fc8 ro root=/dev/vg00/lv00
39         initrd /initrd-2.6.24.3-34.fc8.img
40         map (hd0) (hd1)
41 title othermenu
42         lock
43         makeactive
44         configfile /boot/grub/othergrub.conf
45 "
46
47   test Grub.lns get conf =
48     { "#comment" = "grub.conf generated by anaconda" }
49     {}
50     { "#comment" = "Note that you do not have to rerun grub after making changes to this file" }
51     { "#comment" = "NOTICE:  You have a /boot partition.  This means that" }
52     { "#comment" = "all kernel and initrd paths are relative to /boot/, eg." }
53     { "#comment" = "root (hd0,0)" }
54     { "#comment" = "kernel /vmlinuz-version ro root=/dev/vg00/lv00" }
55     { "#comment" = "initrd /initrd-version.img" }
56     { "boot" = "/dev/sda" }
57     { "device"   = "(hd0)"
58         { "file" = "HD(1,800,64000,9895c137-d4b2-4e3b-a93b-dc9ac4)" } }
59     { "password" = "$1$M9NLj$p2gs87vwNv48BUu.wAfVw0"
60         { "md5" } }
61     { "default" = "0" }
62     { "setkey" }
63     { "setkey"
64         { "to" = "less" }
65         { "from" = "backquote" } }
66     { "background" = "103332" }
67     { "timeout" = "5" }
68     { "splashimage" = "(hd0,0)/grub/splash.xpm.gz" }
69     { "gfxmenu" = "(hd0,0)/boot/message" }
70     { "verbose" = "0" }
71     { "hiddenmenu" }
72     { "title" = "Fedora (2.6.24.4-64.fc8)"
73         { "root" = "(hd0,0)" }
74         { "kernel" = "/vmlinuz-2.6.24.4-64.fc8"
75             { "ro" }  { "root" = "/dev/vg00/lv00" } {"crashkernel" = ""} }
76         { "initrd" = "/initrd-2.6.24.4-64.fc8.img" } }
77     { "title" = "Fedora (2.6.24.3-50.fc8)"
78         { "root" = "(hd0,0)" }
79         { "kernel" = "/vmlinuz-2.6.24.3-50.fc8"
80             { "ro" } { "root" = "/dev/vg00/lv00" } }
81         { "initrd" = "/initrd-2.6.24.3-50.fc8.img" } }
82     { "title" = "Fedora (2.6.21.7-3.fc8xen)"
83         { "root" = "(hd0,0)" }
84         { "kernel" = "/xen.gz-2.6.21.7-3.fc8" }
85         { "module" = "/vmlinuz-2.6.21.7-3.fc8xen"
86             { "ro" } { "root" = "/dev/vg00/lv00" } }
87         { "module" = "/initrd-2.6.21.7-3.fc8xen.img" } }
88     { "title" = "Fedora (2.6.24.3-34.fc8)"
89         { "root" = "(hd0,0)" }
90         { "kernel" = "/vmlinuz-2.6.24.3-34.fc8"
91             { "ro" } { "root" = "/dev/vg00/lv00" } }
92         { "initrd" = "/initrd-2.6.24.3-34.fc8.img" }
93         { "map" { "from" = "(hd0)" } { "to" = "(hd1)" } } }
94     { "title" = "othermenu"
95         { "lock" }
96         { "makeactive" }
97         { "configfile" = "/boot/grub/othergrub.conf" } }
98
99
100   test Grub.lns put conf after set "default" "0" = conf
101
102   test Grub.lns get "# menu.lst - See: grub(8), info grub, update-grub(8)
103
104 ## default num\n" =
105     { "#comment" = "menu.lst - See: grub(8), info grub, update-grub(8)" }
106     {}
107     { "#comment" = "# default num" }
108
109   (* Color directive *)
110   test Grub.lns get "color cyan/blue white/blue\n" =
111     { "color"
112       { "normal"    { "foreground" = "cyan" }
113                     { "background" = "blue" } }
114       { "highlight" { "foreground" = "white" }
115                     { "background" = "blue" } } }
116
117   test Grub.lns get "\tcolor cyan/light-blue\n" =
118     { "color"
119       { "normal" { "foreground" = "cyan" }
120                  { "background" = "light-blue" } } }
121
122   test Grub.lns put "color cyan/light-blue\n" after
123     set "/color/highlight/foreground" "white";
124     set "/color/highlight/background" "black"    =
125     "color cyan/light-blue white/black\n"
126
127   (* Boot stanza with savedefault *)
128   let boot_savedefault =
129 "title\t\tDebian GNU/Linux, kernel 2.6.18-6-vserver-686
130 root\t\t(hd0,0)
131   kernel\t\t/boot/vmlinuz-2.6.18-6-vserver-686 root=/dev/md0 ro
132 initrd\t\t/boot/initrd.img-2.6.18-6-vserver-686
133 \tsavedefault\n"
134
135   test Grub.lns get boot_savedefault =
136     { "title" = "Debian GNU/Linux, kernel 2.6.18-6-vserver-686"
137       { "root" = "(hd0,0)" }
138       { "kernel" = "/boot/vmlinuz-2.6.18-6-vserver-686"
139           { "root" = "/dev/md0" } { "ro" } }
140       { "initrd" = "/boot/initrd.img-2.6.18-6-vserver-686" }
141       { "savedefault" } }
142
143   test Grub.lns get
144       "serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1\n"
145     =
146     { "serial"
147         { "unit" = "0" }
148         { "speed" = "9600" }
149         { "word" = "8" }
150         { "parity" = "no" }
151         { "stop" = "1" } }
152
153   test Grub.lns get
154       "terminal --timeout=10 serial console\n" =
155     { "terminal"
156         { "timeout" = "10" }
157         { "serial" }
158         { "console" } }
159
160   test Grub.boot_setting get
161       "chainloader --force +1 \n" = { "chainloader" = "+1" { "force" } }
162
163   test Grub.savedefault put "savedefault\n" after
164     set "/savedefault" "3" = "savedefault 3\n"
165
166   test Grub.lns get
167 "password foo
168 password foo /boot/grub/custom.lst
169 password --md5 $1$Ahx/T0$Sgcp7Z0xgGlyANIJCdESi.
170 password --encrypted ^9^32kwzzX./3WISQ0C
171 password --encrypted ^9^32kwzzX./3WISQ0C /boot/grub/custom.lst
172 " =
173     { "password" = "foo" }
174     { "password" = "foo"
175         { "file" = "/boot/grub/custom.lst" } }
176     { "password" = "$1$Ahx/T0$Sgcp7Z0xgGlyANIJCdESi."
177         { "md5" } }
178     { "password" = "^9^32kwzzX./3WISQ0C"
179         { "encrypted" } }
180     { "password" = "^9^32kwzzX./3WISQ0C"
181         { "encrypted" }
182         { "file" = "/boot/grub/custom.lst" } }
183
184   (* BZ 590067 - handle comments in a title section *)
185   (* Comments within a boot stanza belong to that boot stanza *)
186   test Grub.lns get "title Red Hat Enterprise Linux AS (2.4.21-63.ELsmp)
187     root (hd0,0)
188     kernel /vmlinuz-2.4.21-63.ELsmp ro root=LABEL=/
189     #initrd /initrd-2.4.21-63.ELsmp.img
190     initrd /initrd-2.4.21-63.EL.img.e1000.8139\n" =
191   { "title" = "Red Hat Enterprise Linux AS (2.4.21-63.ELsmp)"
192     { "root" = "(hd0,0)" }
193     { "kernel" = "/vmlinuz-2.4.21-63.ELsmp" { "ro" } { "root" = "LABEL=/" } }
194     { "#comment" = "initrd /initrd-2.4.21-63.ELsmp.img" }
195     { "initrd" = "/initrd-2.4.21-63.EL.img.e1000.8139" } }
196
197   (* Comments at the end of a boot stanza go into the top level *)
198   test Grub.lns get "title Red Hat Enterprise Linux AS (2.4.21-63.ELsmp)
199     root (hd0,0)
200     kernel /vmlinuz-2.4.21-63.ELsmp ro root=LABEL=/
201     initrd /initrd-2.4.21-63.EL.img.e1000.8139
202     # Now for something completely different\n" =
203   { "title" = "Red Hat Enterprise Linux AS (2.4.21-63.ELsmp)"
204     { "root" = "(hd0,0)" }
205     { "kernel" = "/vmlinuz-2.4.21-63.ELsmp" { "ro" } { "root" = "LABEL=/" } }
206     { "initrd" = "/initrd-2.4.21-63.EL.img.e1000.8139" } }
207   { "#comment" = "Now for something completely different" }
208
209   (* Solaris 10 extensions: kernel$ and module$ are permitted and enable *)
210   (* variable expansion.  findroot (similar to root) and bootfs added *)
211   test Grub.lns get "title Solaris 10 10/09 s10x_u8wos_08a X86
212     findroot (pool_rpool,0,a)
213     bootfs rpool/mybootenv-alt
214     kernel$ /platform/i86pc/multiboot -B $ZFS-BOOTFS
215     module$ /platform/i86pc/boot_archive\n" =
216   { "title" = "Solaris 10 10/09 s10x_u8wos_08a X86"
217     { "findroot" = "(pool_rpool,0,a)" }
218     { "bootfs" = "rpool/mybootenv-alt" }
219     { "kernel$" = "/platform/i86pc/multiboot" { "-B" } { "$ZFS-BOOTFS" } }
220     { "module$" = "/platform/i86pc/boot_archive" } }
221
222   (* Solaris 10 extension: multiboot kernel may take a path as its first *)
223   (* argument. *)
224   test Grub.lns get "title Solaris failsafe
225     findroot (pool_rpool,0,a)
226     kernel /boot/multiboot kernel/unix -s
227     module /boot/x86.miniroot-safe\n" =
228   { "title" = "Solaris failsafe"
229     { "findroot" = "(pool_rpool,0,a)" }
230     { "kernel" = "/boot/multiboot" { "@path" = "kernel/unix" } { "-s" } }
231     { "module" = "/boot/x86.miniroot-safe" } }
232
233   test Grub.lns get "title SUSE Linux Enterprise Server 11 SP1 - 2.6.32.27-0.2
234     kernel (hd0,0)/vmlinuz root=/dev/vg_root/lv_root resume=/dev/vg_root/lv_swap splash=silent showopts
235     initrd (hd0,0)/initrd\n" =
236   { "title" = "SUSE Linux Enterprise Server 11 SP1 - 2.6.32.27-0.2"
237     { "kernel" = "(hd0,0)/vmlinuz"
238       { "root" = "/dev/vg_root/lv_root" }
239       { "resume" = "/dev/vg_root/lv_swap" }
240       { "splash" = "silent" }
241       { "showopts" } }
242     { "initrd" = "(hd0,0)/initrd" } }
243
244   (* Password protected kernel, issue #229 *)
245   test Grub.lns get "title Password Protected Kernel
246         root (hd0,0)
247         kernel /vmlinuz ro root=/dev/mapper/root
248         initrd /initramfs
249         password --md5 secret\n" =
250   { "title" = "Password Protected Kernel"
251     { "root" = "(hd0,0)" }
252     { "kernel" = "/vmlinuz"
253       { "ro" }
254       { "root" = "/dev/mapper/root" }
255     }
256     { "initrd" = "/initramfs" }
257     { "password" = "secret"
258       { "md5" }
259     } }
260
261     (* Test kernel options with different special characters. *)
262     test Grub.lns get "title Fedora (2.6.24.4-64.fc8)
263         root (hd0,0)
264         kernel /vmlinuz-2.6.24.4-64.fc8 ro root=/dev/vg00/lv00 with.dot=1 with-dash=1 with_underscore=1 with+plus=1
265         initrd /initrd-2.6.24.4-64.fc8.img\n" =
266   { "title" = "Fedora (2.6.24.4-64.fc8)"
267     { "root" = "(hd0,0)" }
268     { "kernel" = "/vmlinuz-2.6.24.4-64.fc8"
269       { "ro" }
270       { "root" = "/dev/vg00/lv00" }
271       { "with.dot" = "1" }
272       { "with-dash" = "1" }
273       { "with_underscore" = "1" }
274       { "with+plus" = "1" }
275     }
276     { "initrd" = "/initrd-2.6.24.4-64.fc8.img" } }
277
278   (* Test parsing of invalid entries via menu_error *)
279   test Grub.lns get "default=0\ncrud=no\n" =
280   { "default" = "0" }
281   { "#error" = "crud=no" }
282
283   (* We handle some pretty bizarre bad syntax *)
284   test Grub.lns get "default=0
285 crud no
286 valid:nope
287 nonsense  =   yes
288 bad arg1 arg2 arg3=v\n" =
289   { "default" = "0" }
290   { "#error" = "crud no" }
291   { "#error" = "valid:nope" }
292   { "#error" = "nonsense  =   yes" }
293   { "#error" = "bad arg1 arg2 arg3=v" }
294
295   (* Test parsing of invalid entries via boot_error *)
296   test Grub.lns get "title test
297     root (hd0,0)
298     crud foo\n" =
299   { "title" = "test"
300     { "root" = "(hd0,0)" }
301     { "#error" = "crud foo" } }