Magellan Linux

Diff of /tags/grubby-8_40/test.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2234 by niro, Mon Oct 21 13:16:58 2013 UTC revision 2252 by niro, Mon Oct 21 13:59:08 2013 UTC
# Line 48  oneTest() { Line 48  oneTest() {
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
# Line 74  oneTest() { Line 87  oneTest() {
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=""
# Line 81  oneDisplayTest() { Line 107  oneDisplayTest() {
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
# Line 101  oneDisplayTest() { Line 127  oneDisplayTest() {
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
# Line 428  grub2Test grub2.1 setdefaultindex/g2.1.0 Line 483  grub2Test grub2.1 setdefaultindex/g2.1.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

Legend:
Removed from v.2234  
changed lines
  Added in v.2252