48 |
typeset mode=$1 cfg=test/$2 correct=test/results/$3 |
typeset mode=$1 cfg=test/$2 correct=test/results/$3 |
49 |
shift 3 |
shift 3 |
50 |
|
|
51 |
|
local ENV_FILE="" |
52 |
|
if [ "$mode" == "--grub2" ]; then |
53 |
|
ENV_FILE="test/grub2-support_files/env_temp" |
54 |
|
if [ "$1" == "--env" ]; then |
55 |
|
cp "test/grub2-support_files/$2" "$ENV_FILE" |
56 |
|
shift 2 |
57 |
|
else |
58 |
|
cp "test/grub2-support_files/grubenv.0" "$ENV_FILE" |
59 |
|
fi |
60 |
|
ENV_FILE="--env=$ENV_FILE" |
61 |
|
fi |
62 |
|
|
63 |
|
|
64 |
echo "$testing ... $mode $cfg $correct" |
echo "$testing ... $mode $cfg $correct" |
65 |
runme=( ./grubby "$mode" --bad-image-okay -c "$cfg" -o - "$@" ) |
runme=( ./grubby "$mode" --bad-image-okay $ENV_FILE -c "$cfg" -o - "$@" ) |
66 |
if "${runme[@]}" | cmp "$correct" > /dev/null; then |
if "${runme[@]}" | cmp "$correct" > /dev/null; then |
67 |
(( pass++ )) |
(( pass++ )) |
68 |
if $opt_verbose; then |
if $opt_verbose; then |
87 |
oneDisplayTest() { |
oneDisplayTest() { |
88 |
typeset mode=$1 cfg=test/$2 correct=test/results/$3 |
typeset mode=$1 cfg=test/$2 correct=test/results/$3 |
89 |
shift 3 |
shift 3 |
90 |
|
|
91 |
|
local ENV_FILE="" |
92 |
|
if [ "$mode" == "--grub2" ]; then |
93 |
|
ENV_FILE="test/grub2-support_files/env_temp" |
94 |
|
if [ "$1" == "--env" ]; then |
95 |
|
cp "test/grub2-support_files/$2" "$ENV_FILE" |
96 |
|
shift 2 |
97 |
|
else |
98 |
|
cp "test/grub2-support_files/grubenv.0" "$ENV_FILE" |
99 |
|
fi |
100 |
|
ENV_FILE="--env=$ENV_FILE" |
101 |
|
fi |
102 |
|
|
103 |
local BIO="--bad-image-okay" |
local BIO="--bad-image-okay" |
104 |
if [ "$1" == "--bad-image-bad" ]; then |
if [ "$1" == "--bad-image-bad" ]; then |
105 |
BIO="" |
BIO="" |
107 |
fi |
fi |
108 |
|
|
109 |
echo "$testing ... $mode $cfg $correct" |
echo "$testing ... $mode $cfg $correct" |
110 |
runme=( ./grubby "$mode" $BIO -c "$cfg" "$@" ) |
runme=( ./grubby "$mode" $BIO $ENV_FILE -c "$cfg" "$@" ) |
111 |
if "${runme[@]}" 2>&1 | cmp "$correct" > /dev/null; then |
if "${runme[@]}" 2>&1 | cmp "$correct" > /dev/null; then |
112 |
(( pass++ )) |
(( pass++ )) |
113 |
if $opt_verbose; then |
if $opt_verbose; then |
127 |
fi |
fi |
128 |
} |
} |
129 |
|
|
130 |
|
commandTest() { |
131 |
|
description=$1 |
132 |
|
cmd0=$2 |
133 |
|
text1=$3 |
134 |
|
shift 3 |
135 |
|
echo "$description" |
136 |
|
output0=$(mktemp) |
137 |
|
|
138 |
|
$cmd0 > $output0 |
139 |
|
|
140 |
|
if echo $text1 | cmp $output0 - >/dev/null; then |
141 |
|
(( pass++)) |
142 |
|
if $opt_verbose; then |
143 |
|
echo ------------------------------------------------------------- |
144 |
|
echo -n "PASS: " |
145 |
|
printf "%q " "\"$cmd0\""; echo |
146 |
|
echo $text1 | diff -U30 $output0 - |
147 |
|
echo |
148 |
|
fi |
149 |
|
else |
150 |
|
(( fail++ )) |
151 |
|
echo ------------------------------------------------------------- |
152 |
|
echo -n "FAIL: " |
153 |
|
printf "%q " "\"$cmd0\""; echo |
154 |
|
echo $text1 | diff -U30 $output0 - |
155 |
|
echo |
156 |
|
fi |
157 |
|
} |
158 |
|
|
159 |
# generate convenience functions |
# generate convenience functions |
160 |
for b in $(./grubby --help | \ |
for b in $(./grubby --help | \ |
161 |
sed -n 's/^.*--\([^ ]*\) *configure \1 bootloader$/\1/p'); do |
sed -n 's/^.*--\([^ ]*\) *configure \1 bootloader$/\1/p'); do |
263 |
grubTest grub.4 default/g4.1 --boot-filesystem=/ --set-default=/boot/vmlinuz-2.4.7-ac3 --remove-kernel /boot/vmlinuz-2.4.7-2.5 |
grubTest grub.4 default/g4.1 --boot-filesystem=/ --set-default=/boot/vmlinuz-2.4.7-ac3 --remove-kernel /boot/vmlinuz-2.4.7-2.5 |
264 |
grubTest grub.4 default/g4.2 --boot-filesystem=/ --set-default=/boot/vmlinuz-2.4.7-ac3 --remove-kernel /boot/vmlinuz-2.4.7-2.5 --add-kernel=/boot/new-kernel --copy-default --title New_Title |
grubTest grub.4 default/g4.2 --boot-filesystem=/ --set-default=/boot/vmlinuz-2.4.7-ac3 --remove-kernel /boot/vmlinuz-2.4.7-2.5 --add-kernel=/boot/new-kernel --copy-default --title New_Title |
265 |
grubTest grub.6 default/g6.1 --remove-kernel=/boot/vmlinuz-2.4.7-2.9 --boot-filesystem=/ |
grubTest grub.6 default/g6.1 --remove-kernel=/boot/vmlinuz-2.4.7-2.9 --boot-filesystem=/ |
|
grubTest grub.14 add/g1.7 --boot-filesystem=/boot --add-kernel /boot/new-kernel --title Some_Title |
|
266 |
|
|
267 |
testing="GRUB default index directive" |
testing="GRUB default index directive" |
268 |
grubTest grub.13 setdefaultindex/g.13.0 --set-default-index=0 |
grubTest grub.13 setdefaultindex/g.13.0 --set-default-index=0 |
483 |
grub2Test grub2.1 setdefaultindex/g2.1.1 --set-default-index=1 |
grub2Test grub2.1 setdefaultindex/g2.1.1 --set-default-index=1 |
484 |
grub2Test grub2.1 setdefaultindex/g2.1.9 --set-default-index=9 |
grub2Test grub2.1 setdefaultindex/g2.1.9 --set-default-index=9 |
485 |
|
|
486 |
|
testing="GRUB2 add kernel with default=saved_entry" |
487 |
|
grub2Test grub2.7 add/g2-1.8 --env grubenv.1 --add-kernel=/boot/new-kernel.img \ |
488 |
|
--title='title' --initrd=/boot/new-initrd --boot-filesystem=/boot/ \ |
489 |
|
--copy-default |
490 |
|
commandTest "saved_default output" "grub2-editenv test/grub2-support_files/env_temp list" "saved_entry=Linux, with Fedora 2.6.38.8-32.fc15.x86_64" |
491 |
|
|
492 |
|
testing="GRUB2 set default with default=saved_entry" |
493 |
|
grub2Test grub2.8 add/g2-1.8 --env grubenv.1 --set-default-index=0 |
494 |
|
commandTest "saved_default output" "grub2-editenv test/grub2-support_files/env_temp list" "saved_entry=title" |
495 |
|
|
496 |
|
testing="GRUB2 --default-index with default=saved_entry" |
497 |
|
grub2DisplayTest grub2.8 defaultindex/1 --env grubenv.1 --default-index |
498 |
|
|
499 |
|
testing="GRUB2 --default-index with default=saved_entry" |
500 |
|
grub2DisplayTest grub2.8 defaultindex/0 --env grubenv.2 --default-index |
501 |
|
|
502 |
|
testing="GRUB2 --default-title with default=saved_entry" |
503 |
|
grub2DisplayTest grub2.8 defaulttitle/g2.1 --env grubenv.1 --default-title |
504 |
|
|
505 |
testing="YABOOT add kernel" |
testing="YABOOT add kernel" |
506 |
yabootTest yaboot.1 add/y1.1 --copy-default --boot-filesystem=/ --add-kernel=/boot/new-kernel \ |
yabootTest yaboot.1 add/y1.1 --copy-default --boot-filesystem=/ --add-kernel=/boot/new-kernel \ |
507 |
--title=newtitle |
--title=newtitle |