]> git.proxmox.com Git - grub2.git/commitdiff
Add few new tests.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 29 Apr 2013 10:25:57 +0000 (12:25 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 29 Apr 2013 10:25:57 +0000 (12:25 +0200)
ChangeLog
Makefile.util.def
tests/ahci_test.in [new file with mode: 0644]
tests/ehci_test.in [new file with mode: 0644]
tests/grub_script_escape_comma.in [new file with mode: 0644]
tests/help_test.in [new file with mode: 0644]
tests/ohci_test.in [new file with mode: 0644]
tests/pata_test.in [new file with mode: 0644]
tests/uhci_test.in [new file with mode: 0644]
tests/util/grub-shell.in

index 1dea1aa8d1854c022c55437763783652a4150ddd..e4a73078617230457970a13a3fbc6742bf972b92 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index caa6c059ce1411a7b80ae351fca3c1c2d45415d0..3cfc592dcd794c78f4151a19d0ad708885bfaec7 100644 (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;
diff --git a/tests/ahci_test.in b/tests/ahci_test.in
new file mode 100644 (file)
index 0000000..fa5314c
--- /dev/null
@@ -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"
+
+
diff --git a/tests/ehci_test.in b/tests/ehci_test.in
new file mode 100644 (file)
index 0000000..d9999f8
--- /dev/null
@@ -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"
diff --git a/tests/grub_script_escape_comma.in b/tests/grub_script_escape_comma.in
new file mode 100644 (file)
index 0000000..eff3179
--- /dev/null
@@ -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 \\
+
diff --git a/tests/help_test.in b/tests/help_test.in
new file mode 100644 (file)
index 0000000..e780924
--- /dev/null
@@ -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
diff --git a/tests/ohci_test.in b/tests/ohci_test.in
new file mode 100644 (file)
index 0000000..d6c1e0c
--- /dev/null
@@ -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"
diff --git a/tests/pata_test.in b/tests/pata_test.in
new file mode 100644 (file)
index 0000000..3671300
--- /dev/null
@@ -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"
diff --git a/tests/uhci_test.in b/tests/uhci_test.in
new file mode 100644 (file)
index 0000000..ec6731c
--- /dev/null
@@ -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"
index b034e96a35861482bd0f53bc2d407988cfc75eb3..5b20ca3fb5084b5bbba809d6c39e9d700009d586 100644 (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