Magellan Linux

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

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

revision 1737 by niro, Sat Feb 18 01:02:56 2012 UTC revision 2255 by niro, Mon Oct 21 14:00:38 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
114      echo -------------------------------------------------------------      echo -------------------------------------------------------------
115      echo -n "PASS: "      echo -n "PASS: "
116      printf "%q " "${runme[@]}"; echo      printf "%q " "${runme[@]}"; echo
117      "${runme[@]}" | diff -U30 "$cfg" -      "${runme[@]}" 2>&1 | diff -U30 "$cfg" -
118      echo      echo
119   fi   fi
120      else      else
# Line 96  oneDisplayTest() { Line 122  oneDisplayTest() {
122   echo -------------------------------------------------------------   echo -------------------------------------------------------------
123   echo -n "FAIL: "   echo -n "FAIL: "
124   printf "%q " "${runme[@]}"; echo   printf "%q " "${runme[@]}"; echo
125   "${runme[@]}" | diff -U30 "$correct" -   "${runme[@]}" 2>&1 | diff -U30 "$correct" -
126     echo
127        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   echo
156      fi      fi
157  }  }
# Line 126  while true; do Line 181  while true; do
181  done  done
182    
183  export MALLOC_CHECK_=2  export MALLOC_CHECK_=2
184    if [ -n "${RANDOM}" ]; then
185        export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
186    else
187        export MALLOC_PERTURB_=1
188    fi
189    
190  testing="Parse/write comparison"  testing="Parse/write comparison"
191  for n in test/*.[0-9]*; do  for n in test/*.[0-9]*; do
192        [ -d $n ] && continue
193      n=${n#*/} # remove test/      n=${n#*/} # remove test/
194      b=${n%.*} # remove suffix      b=${n%.*} # remove suffix
195      [[ $b == $opt_bootloader ]] || continue      [[ $b == $opt_bootloader ]] || continue
# Line 203  grubTest grub.4 default/g4.1 --boot-file Line 264  grubTest grub.4 default/g4.1 --boot-file
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=/
266    
267    testing="GRUB default index directive"
268    grubTest grub.13 setdefaultindex/g.13.0 --set-default-index=0
269    grubTest grub.13 setdefaultindex/g.13.1 --set-default-index=1
270    grubTest grub.13 setdefaultindex/g.13.9 --set-default-index=9
271    
272  testing="GRUB display default index"  testing="GRUB display default index"
273  grubDisplayTest grub.1 defaultindex/0 --default-index  grubDisplayTest grub.1 defaultindex/0 --default-index
274  grubDisplayTest grub.2 defaultindex/0 --default-index  grubDisplayTest grub.2 defaultindex/0 --default-index
# Line 305  grubTest grub.11 updargs/g11.2 --boot-fi Line 371  grubTest grub.11 updargs/g11.2 --boot-fi
371      --update-kernel=/vmlinuz-2.4.7-2smp \      --update-kernel=/vmlinuz-2.4.7-2smp \
372      --args "ro root=LABEL=/ single"      --args "ro root=LABEL=/ single"
373    
374    testing="GRUB lba and root information on SuSE systems"
375    GRUBBY_SUSE_RELEASE=test/grub.12-support_files/etc/SuSE-release \
376        GRUBBY_SUSE_GRUB_CONF=test/grub.12-support_files/etc/grub.conf \
377        GRUBBY_GRUB_DEVICE_MAP=test/grub.12-support_files/boot/grub/device.map \
378        grubTest grub.12 info/g12.1 --info=0
379    
380  testing="LILO update kernel argument handling"  testing="LILO update kernel argument handling"
381  liloTest lilo.1 updargs/l1.1 --update-kernel=/boot/vmlinuz-2.4.18-4 \  liloTest lilo.1 updargs/l1.1 --update-kernel=/boot/vmlinuz-2.4.18-4 \
382      --args="root=/dev/md1"      --args="root=/dev/md1"
# Line 360  grubTest grub.11 add/g11.1 --add-kernel= Line 432  grubTest grub.11 add/g11.1 --add-kernel=
432      --initrd=/boot/new-initrd --boot-filesystem=/boot --copy-default \      --initrd=/boot/new-initrd --boot-filesystem=/boot --copy-default \
433      --args='console=tty0 console=ttyS1,9600n81 single'      --args='console=tty0 console=ttyS1,9600n81 single'
434    
435  testing="GRUB2 add kernel"  testgrub2=n
436  grub2Test grub2.1 add/g2-1.1 --add-kernel=/boot/new-kernel.img --title='title' \  ARCH=$(uname -m | sed s,i[3456789]86,ia32,)
437      --initrd=/boot/new-initrd --boot-filesystem=/boot/ --copy-default  case $ARCH in
438  grub2Test grub2.1 add/g2-1.2 --add-kernel=/boot/new-kernel.img --title='title' \      aarch64|ppc|ppc64|ia32|x86_64) testgrub2=y ;;
439      --initrd=/boot/new-initrd --boot-filesystem=/boot/ \  esac
440      --copy-default --make-default  
441  grub2Test grub2.1 add/g2-1.3 --add-kernel=/boot/new-kernel.img --title='title' \  if [ "$testgrub2" == "y" ]; then
442      --boot-filesystem=/boot/ --copy-default --make-default      testing="GRUB2 add kernel"
443  grub2Test grub2.1 remove/g2-1.4 --remove-kernel=/boot/vmlinuz-2.6.38.2-9.fc15.x86_64 \      grub2Test grub2.1 add/g2-1.1 --add-kernel=/boot/new-kernel.img \
444      --boot-filesystem=/boot/          --title='title' --initrd=/boot/new-initrd --boot-filesystem=/boot/ \
445            --copy-default
446  testing="GRUB2 add initrd"      grub2Test grub2.1 add/g2-1.6 --add-kernel=/boot/new-kernel.img \
447  grub2Test grub2.2 add/g2-1.4 --update-kernel=/boot/new-kernel.img \          --title='title' --initrd=/boot/new-initrd --boot-filesystem=/boot/ \
448      --initrd=/boot/new-initrd --boot-filesystem=/boot/          --copy-default --efi
449        grub2Test grub2.6 add/g2-1.7 --add-kernel=/boot/new-kernel.img \
450  testing="GRUB2 display default index"          --title='title' --initrd=/boot/new-initrd --boot-filesystem=/boot/ \
451  grub2DisplayTest grub2.1 defaultindex/0 --default-index          --copy-default --efi
452  grub2DisplayTest grub2.2 defaultindex/0 --default-index      grub2Test grub2.1 add/g2-1.2 --add-kernel=/boot/new-kernel.img \
453            --title='title' --initrd=/boot/new-initrd --boot-filesystem=/boot/ \
454  testing="GRUB2 display default title"          --copy-default --make-default
455  grub2DisplayTest grub2.1 defaulttitle/g2.1 --default-title      grub2Test grub2.1 add/g2-1.3 --add-kernel=/boot/new-kernel.img \
456  grub2DisplayTest grub2.2 defaulttitle/g2.2 --default-title          --title='title' --boot-filesystem=/boot/ --copy-default --make-default
457        grub2Test grub2.1 remove/g2-1.4 \
458  testing="GRUB2 display debug failure"          --remove-kernel=/boot/vmlinuz-2.6.38.2-9.fc15.x86_64 \
459  grub2DisplayTest grub2.1 debug/g2.1 --bad-image-bad --default-kernel --debug          --boot-filesystem=/boot/
460  testing="GRUB2 display debug success"      grub2Test grub2.5 add/g2-1.5 --add-kernel=/boot/new-kernel.img \
461  grub2DisplayTest grub2.1 debug/g2.1.2 --default-kernel --debug          --title='title' --initrd=/boot/new-initrd --boot-filesystem=/boot/ \
462            --copy-default
463    
464        testing="GRUB2 add initrd"
465        grub2Test grub2.2 add/g2-1.4 --update-kernel=/boot/new-kernel.img \
466            --initrd=/boot/new-initrd --boot-filesystem=/boot/
467    
468        testing="GRUB2 display default index"
469        grub2DisplayTest grub2.1 defaultindex/0 --default-index
470        grub2DisplayTest grub2.2 defaultindex/0 --default-index
471    
472        testing="GRUB2 display default title"
473        grub2DisplayTest grub2.1 defaulttitle/g2.1 --default-title
474        grub2DisplayTest grub2.2 defaulttitle/g2.2 --default-title
475    
476        testing="GRUB2 display debug failure"
477        grub2DisplayTest grub2.1 debug/g2.1 --bad-image-bad \
478            --boot-filesystem=/boot --default-kernel --debug
479        testing="GRUB2 display debug success"
480        grub2DisplayTest grub2.1 debug/g2.1.2 --boot-filesystem=/boot \
481            --default-kernel --debug
482    
483        testing="GRUB2 remove kernel via index"
484        grub2Test grub2.3 remove/g2-1.1 --remove-kernel=1
485    
486        testing="GRUB2 remove kernel via title"
487        grub2Test grub2.3 remove/g2-1.1 --remove-kernel="TITLE=title2"
488    
489        testing="GRUB2 (submenu) remove kernel via index"
490        grub2Test grub2.4 remove/g2-1.2 --remove-kernel=2
491    
492        testing="GRUB2 (submenu) remove kernel via title"
493        grub2Test grub2.4 remove/g2-1.2 --remove-kernel="TITLE=title2"
494    
495        testing="GRUB2 default index directive"
496        grub2Test grub2.1 setdefaultindex/g2.1.0 --set-default-index=0
497        grub2Test grub2.1 setdefaultindex/g2.1.1 --set-default-index=1
498        grub2Test grub2.1 setdefaultindex/g2.1.9 --set-default-index=9
499    
500        testing="GRUB2 add kernel with default=saved_entry"
501        grub2Test grub2.7 add/g2-1.8 --env grubenv.1 \
502            --add-kernel=/boot/new-kernel.img \
503            --title='title' --initrd=/boot/new-initrd --boot-filesystem=/boot/ \
504            --copy-default
505        commandTest "saved_default output" \
506            "grub2-editenv test/grub2-support_files/env_temp list" \
507            "saved_entry=Linux, with Fedora 2.6.38.8-32.fc15.x86_64"
508    
509        testing="GRUB2 set default with default=saved_entry"
510        grub2Test grub2.8 add/g2-1.8 --env grubenv.1 --set-default-index=0
511        commandTest "saved_default output" \
512            "grub2-editenv test/grub2-support_files/env_temp list" \
513            "saved_entry=title"
514    
515        testing="GRUB2 --default-index with default=saved_entry"
516        grub2DisplayTest grub2.8 defaultindex/1 --env grubenv.1 --default-index
517    
518        testing="GRUB2 --default-index with default=saved_entry"
519        grub2DisplayTest grub2.8 defaultindex/0 --env grubenv.2 --default-index
520    
521        testing="GRUB2 --default-title with default=saved_entry"
522        grub2DisplayTest grub2.8 defaulttitle/g2.1 --env grubenv.1 --default-title
523    
524        testing="GRUB2 --default-index with default=saved_entry and empty grubenv"
525        grub2DisplayTest grub2.8 defaultindex/0 --env grubenv.0 --default-index
526    fi
527    
528  testing="YABOOT add kernel"  testing="YABOOT add kernel"
529  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  \

Legend:
Removed from v.1737  
changed lines
  Added in v.2255