Add few new tests.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-04-29 12:25:57 +02:00
parent e2f27a8c53
commit f7457fb231
10 changed files with 337 additions and 1 deletions

View File

@ -1,3 +1,7 @@
2013-04-29 Vladimir Serbinenko <phcoder@gmail.com>
Add few new tests.
2013-04-29 Vladimir Serbinenko <phcoder@gmail.com>
Enforce disabling of firmware disk drivers when native drivers kick in.

View File

@ -544,6 +544,36 @@ script = {
common = tests/example_scripted_test.in;
};
script = {
testcase;
name = pata_test;
common = tests/pata_test.in;
};
script = {
testcase;
name = ahci_test;
common = tests/ahci_test.in;
};
script = {
testcase;
name = uhci_test;
common = tests/uhci_test.in;
};
script = {
testcase;
name = ohci_test;
common = tests/ohci_test.in;
};
script = {
testcase;
name = ehci_test;
common = tests/ehci_test.in;
};
script = {
testcase;
name = example_grub_script_test;
@ -748,12 +778,24 @@ script = {
common = tests/grub_cmd_echo.in;
};
script = {
testcase;
name = help_test;
common = tests/help_test.in;
};
script = {
testcase;
name = grub_script_gettext;
common = tests/grub_script_gettext.in;
};
script = {
testcase;
name = grub_script_escape_comma;
common = tests/grub_script_escape_comma.in;
};
script = {
testcase;
name = grub_script_strcmp;

52
tests/ahci_test.in Normal file
View File

@ -0,0 +1,52 @@
#! /bin/sh
# Copyright (C) 2013 Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
set -e
grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
*-emu)
exit 0;;
# FIXME: qemu gets bonito DMA wrong
mipsel-loongson)
exit 0;;
# no AHCI on ARC and qemu-mips platforms
mips*-arc | mips*-qemu_mips)
exit 0;;
# FIXME: No native drivers are available for those
powerpc-ieee1275 | sparc64-ieee1275)
exit 0;;
esac
imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
echo "hello" > "$outfile"
tar cf "$imgfile" "$outfile"
if [ "$(echo "nativedisk; source '(ahci0)/$outfile';" | "${grubshell}" --qemu-opts="-drive id=disk,file=$imgfile,if=none -device ahci,id=ahci -device ide-drive,drive=disk,bus=ahci.0 " | tail -n 1)" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
exit 1
fi
rm "$imgfile"
rm "$outfile"

50
tests/ehci_test.in Normal file
View File

@ -0,0 +1,50 @@
#! /bin/sh
# Copyright (C) 2013 Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
set -e
grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
*-emu)
exit 0;;
# FIXME: qemu gets bonito DMA wrong
mipsel-loongson)
exit 0;;
# no USB on ARC and qemu-mips platforms
mips*-arc | mips*-qemu_mips)
exit 0;;
# FIXME: No native drivers are available for those
powerpc-ieee1275 | sparc64-ieee1275)
exit 0;;
esac
imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
echo "hello" > "$outfile"
tar cf "$imgfile" "$outfile"
if [ "$(echo "nativedisk; source '(usb0)/$outfile';" | "${grubshell}" --qemu-opts="-device ich9-usb-ehci1 -drive id=my_usb_disk,file=$imgfile,if=none -device usb-storage,drive=my_usb_disk" | tail -n 1)" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
exit 1
fi
rm "$imgfile"
rm "$outfile"

View File

@ -0,0 +1,18 @@
#! @builddir@/grub-shell-tester
x=1\\,1
echo $x
y='$'
echo $y
z='\'
echo $z
t='\*'
echo $t
u='$'
echo $u
v='\?'
echo $v
echo \\

16
tests/help_test.in Normal file
View File

@ -0,0 +1,16 @@
#! /bin/bash
set -e
. "@builddir@/grub-core/modinfo.sh"
template="Usage: help [PATTERN ...]
Show a help message.
-h, --help Display this help and exit.
-u, --usage Display the usage of this command and exit.
Hello World"
outpu="$(echo 'help help; hello' | @builddir@/grub-shell)"
if [ "$template" != "$outpu" ]; then
exit 1
fi

50
tests/ohci_test.in Normal file
View File

@ -0,0 +1,50 @@
#! /bin/sh
# Copyright (C) 2013 Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
set -e
grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
*-emu)
exit 0;;
# FIXME: qemu gets bonito DMA wrong
mipsel-loongson)
exit 0;;
# no USB on ARC and qemu-mips platforms
mips*-arc | mips*-qemu_mips)
exit 0;;
# FIXME: No native drivers are available for those
powerpc-ieee1275 | sparc64-ieee1275)
exit 0;;
esac
imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
echo "hello" > "$outfile"
tar cf "$imgfile" "$outfile"
if [ "$(echo "nativedisk; source '(usb0)/$outfile';" | "${grubshell}" --qemu-opts="-device pci-ohci -drive id=my_usb_disk,file=$imgfile,if=none -device usb-storage,drive=my_usb_disk" | tail -n 1)" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
exit 1
fi
rm "$imgfile"
rm "$outfile"

54
tests/pata_test.in Normal file
View File

@ -0,0 +1,54 @@
#! /bin/sh
# Copyright (C) 2013 Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
set -e
grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
disk=hda
indisk=ata0
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
*-emu)
exit 0;;
# no ATA on ARC platforms (they use SCSI)
*-arc)
exit 0;;
# FIXME: No native drivers are available for those
powerpc-ieee1275 | sparc64-ieee1275)
exit 0;;
i386-ieee1275)
disk=hdb
indisk=ata1
;;
esac
imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
echo "hello" > "$outfile"
tar cf "$imgfile" "$outfile"
if [ "$(echo "nativedisk; source '($indisk)/$outfile';" | "${grubshell}" --qemu-opts="-$disk $imgfile")" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
exit 1
fi
rm "$imgfile"
rm "$outfile"

50
tests/uhci_test.in Normal file
View File

@ -0,0 +1,50 @@
#! /bin/sh
# Copyright (C) 2013 Free Software Foundation, Inc.
#
# GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GRUB is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
set -e
grubshell=@builddir@/grub-shell
. "@builddir@/grub-core/modinfo.sh"
case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
*-emu)
exit 0;;
# FIXME: qemu gets bonito DMA wrong
mipsel-loongson)
exit 0;;
# no USB on ARC and qemu-mips platforms
mips*-arc | mips*-qemu_mips)
exit 0;;
# FIXME: No native drivers are available for those
powerpc-ieee1275 | sparc64-ieee1275)
exit 0;;
esac
imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
echo "hello" > "$outfile"
tar cf "$imgfile" "$outfile"
if [ "$(echo "nativedisk; source '(usb0)/$outfile';" | "${grubshell}" --qemu-opts="-usb -usbdevice disk:$imgfile" | tail -n 1)" != "Hello World" ]; then
rm "$imgfile"
rm "$outfile"
exit 1
fi
rm "$imgfile"
rm "$outfile"

View File

@ -322,7 +322,7 @@ do
done
cat <<EOF >>${cfgfile}
source \$prefix/testcase.cfg
source "\$prefix/testcase.cfg"
# Stop serial output to suppress "ACPI shutdown failed" error.
EOF
if [ x$console != x ]; then