Add few more tests.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-04-30 17:41:32 +02:00
parent 583e5b645c
commit 3f9634e550
17 changed files with 265 additions and 20 deletions

View file

@ -1,3 +1,7 @@
2013-04-30 Vladimir Serbinenko <phcoder@gmail.com>
Add few more tests.
2013-04-30 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/arc/arc.h: Account for missing "other" peripheral on

View file

@ -700,6 +700,18 @@ script = {
common = tests/grub_cmd_date.in;
};
script = {
testcase;
name = grub_cmd_set_date;
common = tests/grub_cmd_set_date.in;
};
script = {
testcase;
name = grub_cmd_sleep;
common = tests/grub_cmd_sleep.in;
};
script = {
testcase;
name = grub_script_expansion;

View file

@ -20,12 +20,13 @@ grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: Don't mess with real devices when OS is active
*-emu)
exit 0;;
# FIXME: qemu gets bonito DMA wrong
mipsel-loongson)
exit 0;;
# no AHCI on ARC and qemu-mips platforms
# PLATFORM: no AHCI on ARC and qemu-mips platforms
mips*-arc | mips*-qemu_mips)
exit 0;;
# FIXME: No native drivers are available for those

View file

@ -20,9 +20,10 @@ grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: emu is different
*-emu)
exit 0;;
# Flash targets
# PLATFORM: Flash targets
i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
exit 0;;
# FIXME: currently grub-shell uses only -kernel for loongson

View file

@ -19,8 +19,8 @@ grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
# FIXME: Only mips currently supports configurable core compression
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# FIXME: Only mips currently supports configurable core compression
*-emu | i386-* | x86_64-* | sparc64-* | ia64-*)
exit 0
;;

View file

@ -20,12 +20,13 @@ grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: Don't mess with real devices when OS is active
*-emu)
exit 0;;
# FIXME: qemu gets bonito DMA wrong
mipsel-loongson)
exit 0;;
# no USB on ARC and qemu-mips platforms
# PLATFORM: no USB on ARC and qemu-mips platforms
mips*-arc | mips*-qemu_mips)
exit 0;;
# FIXME: No native drivers are available for those

View file

@ -20,9 +20,10 @@ grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: emu is different
*-emu)
exit 0;;
# Flash targets
# PLATFORM: Flash targets
i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
exit 0;;
# FIXME: currently grub-shell uses only -kernel for loongson
@ -40,7 +41,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# FIXME: QEMU doesn't emulate SCSI floppies
mipsel-arc | mips-arc)
exit 0;;
# powerpc doesn't boot from floppy except OldWorld Macs which we don't support anyway
# PLATFORM: powerpc doesn't boot from floppy except OldWorld Macs which we don't support anyway
powerpc-ieee1275)
exit 0;;
esac

View file

@ -13,8 +13,17 @@ dt=`echo date | @builddir@/grub-shell`
dtg="$(date -u -d "$dt" +%s)"
ndt="$(date -u +%s)"
if [ $pdt -le $dtg ] && [ $dtg -le $ndt ]; then
exit 0;
fi
if [ $pdt -gt $dtg ] || [ $dtg -gt $ndt ]; then
echo "Date not in range: $pdt <= $dtg <= $ndt"
exit 1
fi
pdt="$(date -u +%s)"
dt=`echo 'insmod datehook; echo $YEAR-$MONTH-$DAY $HOUR:$MINUTE:$SECOND' | @builddir@/grub-shell`
dtg="$(date -u -d "$dt" +%s)"
ndt="$(date -u +%s)"
if [ $pdt -gt $dtg ] || [ $dtg -gt $ndt ]; then
echo "Date not in range: $pdt <= $dtg <= $ndt"
exit 1
fi

View file

@ -0,0 +1,35 @@
#! /bin/bash
set -e
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# FIXME: OpenBIOS on sparc64 doesn't implement RTC
sparc64-ieee1275)
exit 0;;
# PLATFORM: ARC doesn't provide any way to set time
*-arc)
exit 0;;
# PLATFORM: EMU doesn't provide any way to set time
# Even if it did we'd need some kind of sandbox to avoid
# modifying real system time.
*-emu)
exit 0;;
esac
out=$(cat <<EOF | @builddir@/grub-shell
insmod datehook
date
if [ \$YEAR = 2004 -a \$MONTH = 4 -a \$DAY = 4 -a \$HOUR = 20 -a \$MINUTE = 47 ]; then
hello
halt
fi
date 2004-04-04 20:47:00
reboot
EOF
)
if [ "$(echo "$out" | tail -n 1)" != "Hello World" ]; then
echo "Test failed: $out"
exit 1
fi

20
tests/grub_cmd_sleep.in Normal file
View file

@ -0,0 +1,20 @@
#! /bin/bash
set -e
. "@builddir@/grub-core/modinfo.sh"
# FIXME: OpenBIOS on sparc64 doesn't implement RTC
if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = sparc64-ieee1275 ]; then
exit 0
fi
# Compare RTC with interval timer.
# Not 100% proper but should check that timer is running ok
dt=`echo 'date; sleep 10; date' | @builddir@/grub-shell`
dt1="$(date -u -d "$(echo "$dt" | head -n 1)" +%s)"
dt2="$(date -u -d "$(echo "$dt" | tail -n 1)" +%s)"
if [ $((dt2 - dt1)) -gt 11 ] || [ $((dt2 - dt1)) -lt 9 ]; then
echo "Interval not in range $dt2-$dt1 != 10"
exit 1
fi

View file

@ -20,9 +20,10 @@ grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: emu is different
*-emu)
exit 0;;
# Flash targets
# PLATFORM: Flash targets
i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
exit 0;;
# FIXME: currently grub-shell uses only -kernel for loongson

View file

@ -20,9 +20,10 @@ grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: emu is different
*-emu)
exit 0;;
# Flash targets
# PLATFORM: Flash targets
i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
exit 0;;
# FIXME: currently grub-shell uses only -kernel for loongson

View file

@ -20,12 +20,13 @@ grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: Don't mess with real devices when OS is active
*-emu)
exit 0;;
# FIXME: qemu gets bonito DMA wrong
mipsel-loongson)
exit 0;;
# no USB on ARC and qemu-mips platforms
# PLATFORM: no USB on ARC and qemu-mips platforms
mips*-arc | mips*-qemu_mips)
exit 0;;
# FIXME: No native drivers are available for those

View file

@ -253,13 +253,19 @@ ${parted} -a none -s "${imgfile}" mklabel sun mkpart 0 10M mkpart 10M 20M mkpart
list_parts part_sun "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,sun1 $disk,sun2 $disk,sun4 $disk,sun5 $disk,sun6 $disk,sun7
# 7 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel sun mkpart 0 10M mkpart 10M 20M mkpart 20M 30M mkpart 30M 40M mkpart 40M 50M mkpart 50M 60M mkpart 60M 70M
list_parts part_sun "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,sun1 $disk,sun2 $disk,sun4 $disk,sun5 $disk,sun6 $disk,sun7 $disk,sun8
#
# Apple partition types
#
# Partition table itself is part of some partition, so there is always
# a partition by default. But I don't understand why GRUB displays
# two partitions by default :-(
# a partition by default. Furthermore free space is also a partition,
# so there is always at least 2 partitions
#
echo "Checking APPLE partition types..."
@ -305,3 +311,153 @@ create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel mac mkpart a 1M 10M mkpart b 10M 20M mkpart c 20M 30M mkpart d 30M 40M mkpart e 40M 50M mkpart f 50M 60M
list_parts part_apple "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,apple1 $disk,apple2 $disk,apple4 $disk,apple5 $disk,apple6 $disk,apple7 $disk,apple8
#
# DVH partition types
#
# Partition #11 is reserved for whole disk by parted.
# Parted also aliases #9 as whole disk
#
echo "Checking DVH partition types..."
# 0 parts
create_disk_image "${imgfile}" 64
${parted} -a none -s "${imgfile}" mklabel dvh
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk
# 1 parts
create_disk_image "${imgfile}" 64
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1
# 2 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2
# 3 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3
# 4 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4
# 5 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5
# 6 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6
# 7 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M mkpart primary 60M 70M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6 $disk,dvh7
# 8 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M mkpart primary 60M 70M mkpart primary 70M 80M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6 $disk,dvh7 $disk,dvh8
# 9 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M mkpart primary 60M 70M mkpart primary 70M 80M mkpart primary 80M 90M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6 $disk,dvh7 $disk,dvh8 $disk,dvh10
# 10 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M mkpart primary 60M 70M mkpart primary 70M 80M mkpart primary 80M 90M mkpart primary 90M 100M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6 $disk,dvh7 $disk,dvh8 $disk,dvh10 $disk,dvh12
# 11 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M mkpart primary 60M 70M mkpart primary 70M 80M mkpart primary 80M 90M mkpart primary 90M 100M mkpart primary 100M 110M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6 $disk,dvh7 $disk,dvh8 $disk,dvh10 $disk,dvh12 $disk,dvh13
# 12 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M mkpart primary 60M 70M mkpart primary 70M 80M mkpart primary 80M 90M mkpart primary 90M 100M mkpart primary 100M 110M mkpart primary 110M 120M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6 $disk,dvh7 $disk,dvh8 $disk,dvh10 $disk,dvh12 $disk,dvh13 $disk,dvh14
# 13 parts
create_disk_image "${imgfile}" 135
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M mkpart primary 60M 70M mkpart primary 70M 80M mkpart primary 80M 90M mkpart primary 90M 100M mkpart primary 100M 110M mkpart primary 110M 120M mkpart primary 120M 130M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6 $disk,dvh7 $disk,dvh8 $disk,dvh10 $disk,dvh12 $disk,dvh13 $disk,dvh14 $disk,dvh15
# 14 parts
create_disk_image "${imgfile}" 145
${parted} -a none -s "${imgfile}" mklabel dvh mkpart primary 3M 10M mkpart primary 10M 20M mkpart primary 20M 30M mkpart primary 30M 40M mkpart primary 40M 50M mkpart primary 50M 60M mkpart primary 60M 70M mkpart primary 70M 80M mkpart primary 80M 90M mkpart primary 90M 100M mkpart primary 100M 110M mkpart primary 110M 120M mkpart primary 120M 130M mkpart primary 130M 140M
list_parts part_dvh "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,dvh1 $disk,dvh2 $disk,dvh3 $disk,dvh4 $disk,dvh5 $disk,dvh6 $disk,dvh7 $disk,dvh8 $disk,dvh10 $disk,dvh12 $disk,dvh13 $disk,dvh14 $disk,dvh15 $disk,dvh16
echo "Checking AMIGA partition types..."
# 0 parts
create_disk_image "${imgfile}" 64
${parted} -a none -s "${imgfile}" mklabel amiga
list_parts part_amiga "${imgfile}" "${outfile}"
check_output "${outfile}" $disk
# 1 parts
create_disk_image "${imgfile}" 64
${parted} -a none -s "${imgfile}" mklabel amiga mkpart x 0 10M
list_parts part_amiga "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,amiga1
# 2 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel amiga mkpart x 0 10M mkpart x 10M 20M
list_parts part_amiga "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,amiga1 $disk,amiga2
# 3 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel amiga mkpart x 0 10M mkpart x 10M 20M mkpart x 20M 30M
list_parts part_amiga "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,amiga1 $disk,amiga2 $disk,amiga3
# 4 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel amiga mkpart x 0 10M mkpart x 10M 20M mkpart x 20M 30M mkpart x 30M 40M
list_parts part_amiga "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,amiga1 $disk,amiga2 $disk,amiga3 $disk,amiga4
# 5 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel amiga mkpart x 0 10M mkpart x 10M 20M mkpart x 20M 30M mkpart x 30M 40M mkpart x 40M 50M
list_parts part_amiga "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,amiga1 $disk,amiga2 $disk,amiga3 $disk,amiga4 $disk,amiga5
# 6 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel amiga mkpart x 0 10M mkpart x 10M 20M mkpart x 20M 30M mkpart x 30M 40M mkpart x 40M 50M mkpart x 50M 60M
list_parts part_amiga "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,amiga1 $disk,amiga2 $disk,amiga3 $disk,amiga4 $disk,amiga5 $disk,amiga6
# 7 parts
create_disk_image "${imgfile}" 128
${parted} -a none -s "${imgfile}" mklabel amiga mkpart x 0 10M mkpart x 10M 20M mkpart x 20M 30M mkpart x 30M 40M mkpart x 40M 50M mkpart x 50M 60M mkpart x 60M 70M
list_parts part_amiga "${imgfile}" "${outfile}"
check_output "${outfile}" $disk $disk,amiga1 $disk,amiga2 $disk,amiga3 $disk,amiga4 $disk,amiga5 $disk,amiga6 $disk,amiga7

View file

@ -23,9 +23,10 @@ disk=hda
indisk=ata0
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: Don't mess with real devices when OS is active
*-emu)
exit 0;;
# no ATA on ARC platforms (they use SCSI)
# PLATFORM: no ATA on ARC platforms (they use SCSI)
*-arc)
exit 0;;
# FIXME: No native drivers are available for those

View file

@ -20,12 +20,13 @@ grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
# PLATFORM: Don't mess with real devices when OS is active
*-emu)
exit 0;;
# FIXME: qemu gets bonito DMA wrong
mipsel-loongson)
exit 0;;
# no USB on ARC and qemu-mips platforms
# PLATFORM: no USB on ARC and qemu-mips platforms
mips*-arc | mips*-qemu_mips)
exit 0;;
# FIXME: No native drivers are available for those

View file

@ -103,7 +103,8 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
boot=cd
qemu=qemu-system-mips64
qemuopts="$qemuopts -M indy"
console=console
serial_port=arc/serial0/line0
console=
trim=1
;;
mipsel-arc)
@ -124,9 +125,8 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
mipsel-loongson)
boot=mipsel_fulong2e
qemu=qemu-system-mips64el
qemuopts="$qemuopts -no-reboot -M fulong2e"
qemuopts="$qemuopts -M fulong2e"
console=
halt_cmd=reboot
trim=1
;;
i386-coreboot)