Blame SOURCES/0390-Add-few-new-tests.patch

f96e0b
From a34197c479d81185ada7a64ee680ae4e5157215d Mon Sep 17 00:00:00 2001
f96e0b
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
f96e0b
Date: Mon, 29 Apr 2013 12:25:57 +0200
f96e0b
Subject: [PATCH 390/482] 	Add few new tests.
f96e0b
f96e0b
---
f96e0b
 ChangeLog                         |  4 +++
f96e0b
 Makefile.util.def                 | 42 ++++++++++++++++++++++++++++++
f96e0b
 tests/ahci_test.in                | 52 +++++++++++++++++++++++++++++++++++++
f96e0b
 tests/ehci_test.in                | 50 ++++++++++++++++++++++++++++++++++++
f96e0b
 tests/grub_script_escape_comma.in | 18 +++++++++++++
f96e0b
 tests/help_test.in                | 16 ++++++++++++
f96e0b
 tests/ohci_test.in                | 50 ++++++++++++++++++++++++++++++++++++
f96e0b
 tests/pata_test.in                | 54 +++++++++++++++++++++++++++++++++++++++
f96e0b
 tests/uhci_test.in                | 50 ++++++++++++++++++++++++++++++++++++
f96e0b
 tests/util/grub-shell.in          |  2 +-
f96e0b
 10 files changed, 337 insertions(+), 1 deletion(-)
f96e0b
 create mode 100644 tests/ahci_test.in
f96e0b
 create mode 100644 tests/ehci_test.in
f96e0b
 create mode 100644 tests/grub_script_escape_comma.in
f96e0b
 create mode 100644 tests/help_test.in
f96e0b
 create mode 100644 tests/ohci_test.in
f96e0b
 create mode 100644 tests/pata_test.in
f96e0b
 create mode 100644 tests/uhci_test.in
f96e0b
f96e0b
diff --git a/ChangeLog b/ChangeLog
f96e0b
index 1dea1aa..e4a7307 100644
f96e0b
--- a/ChangeLog
f96e0b
+++ b/ChangeLog
f96e0b
@@ -1,5 +1,9 @@
f96e0b
 2013-04-29  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
 
f96e0b
+	Add few new tests.
f96e0b
+
f96e0b
+2013-04-29  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
+
f96e0b
 	Enforce disabling of firmware disk drivers when native drivers kick in.
f96e0b
 
f96e0b
 2013-04-29  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
diff --git a/Makefile.util.def b/Makefile.util.def
f96e0b
index caa6c05..3cfc592 100644
f96e0b
--- a/Makefile.util.def
f96e0b
+++ b/Makefile.util.def
f96e0b
@@ -546,6 +546,36 @@ script = {
f96e0b
 
f96e0b
 script = {
f96e0b
   testcase;
f96e0b
+  name = pata_test;
f96e0b
+  common = tests/pata_test.in;
f96e0b
+};
f96e0b
+
f96e0b
+script = {
f96e0b
+  testcase;
f96e0b
+  name = ahci_test;
f96e0b
+  common = tests/ahci_test.in;
f96e0b
+};
f96e0b
+
f96e0b
+script = {
f96e0b
+  testcase;
f96e0b
+  name = uhci_test;
f96e0b
+  common = tests/uhci_test.in;
f96e0b
+};
f96e0b
+
f96e0b
+script = {
f96e0b
+  testcase;
f96e0b
+  name = ohci_test;
f96e0b
+  common = tests/ohci_test.in;
f96e0b
+};
f96e0b
+
f96e0b
+script = {
f96e0b
+  testcase;
f96e0b
+  name = ehci_test;
f96e0b
+  common = tests/ehci_test.in;
f96e0b
+};
f96e0b
+
f96e0b
+script = {
f96e0b
+  testcase;
f96e0b
   name = example_grub_script_test;
f96e0b
   common = tests/example_grub_script_test.in;
f96e0b
 };
f96e0b
@@ -750,12 +780,24 @@ script = {
f96e0b
 
f96e0b
 script = {
f96e0b
   testcase;
f96e0b
+  name = help_test;
f96e0b
+  common = tests/help_test.in;
f96e0b
+};
f96e0b
+
f96e0b
+script = {
f96e0b
+  testcase;
f96e0b
   name = grub_script_gettext;
f96e0b
   common = tests/grub_script_gettext.in;
f96e0b
 };
f96e0b
 
f96e0b
 script = {
f96e0b
   testcase;
f96e0b
+  name = grub_script_escape_comma;
f96e0b
+  common = tests/grub_script_escape_comma.in;
f96e0b
+};
f96e0b
+
f96e0b
+script = {
f96e0b
+  testcase;
f96e0b
   name = grub_script_strcmp;
f96e0b
   common = tests/grub_script_strcmp.in;
f96e0b
 };
f96e0b
diff --git a/tests/ahci_test.in b/tests/ahci_test.in
f96e0b
new file mode 100644
f96e0b
index 0000000..fa5314c
f96e0b
--- /dev/null
f96e0b
+++ b/tests/ahci_test.in
f96e0b
@@ -0,0 +1,52 @@
f96e0b
+#! /bin/sh
f96e0b
+# Copyright (C) 2013  Free Software Foundation, Inc.
f96e0b
+#
f96e0b
+# GRUB is free software: you can redistribute it and/or modify
f96e0b
+# it under the terms of the GNU General Public License as published by
f96e0b
+# the Free Software Foundation, either version 3 of the License, or
f96e0b
+# (at your option) any later version.
f96e0b
+#
f96e0b
+# GRUB is distributed in the hope that it will be useful,
f96e0b
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
f96e0b
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f96e0b
+# GNU General Public License for more details.
f96e0b
+#
f96e0b
+# You should have received a copy of the GNU General Public License
f96e0b
+# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
f96e0b
+
f96e0b
+set -e
f96e0b
+grubshell=@builddir@/grub-shell
f96e0b
+
f96e0b
+. "@builddir@/grub-core/modinfo.sh"
f96e0b
+
f96e0b
+case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
f96e0b
+    *-emu)
f96e0b
+	exit 0;;
f96e0b
+    # FIXME: qemu gets bonito DMA wrong
f96e0b
+    mipsel-loongson)
f96e0b
+	exit 0;;
f96e0b
+    # no AHCI on ARC and qemu-mips platforms
f96e0b
+    mips*-arc | mips*-qemu_mips)
f96e0b
+	exit 0;;
f96e0b
+    # FIXME: No native drivers are available for those
f96e0b
+    powerpc-ieee1275 | sparc64-ieee1275)
f96e0b
+	exit 0;;
f96e0b
+esac
f96e0b
+
f96e0b
+imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
f96e0b
+outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
f96e0b
+
f96e0b
+echo "hello" > "$outfile"
f96e0b
+
f96e0b
+tar cf "$imgfile" "$outfile"
f96e0b
+
f96e0b
+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
f96e0b
+   rm "$imgfile"
f96e0b
+   rm "$outfile"
f96e0b
+   exit 1
f96e0b
+fi
f96e0b
+
f96e0b
+rm "$imgfile"
f96e0b
+rm "$outfile"
f96e0b
+
f96e0b
+
f96e0b
diff --git a/tests/ehci_test.in b/tests/ehci_test.in
f96e0b
new file mode 100644
f96e0b
index 0000000..d9999f8
f96e0b
--- /dev/null
f96e0b
+++ b/tests/ehci_test.in
f96e0b
@@ -0,0 +1,50 @@
f96e0b
+#! /bin/sh
f96e0b
+# Copyright (C) 2013  Free Software Foundation, Inc.
f96e0b
+#
f96e0b
+# GRUB is free software: you can redistribute it and/or modify
f96e0b
+# it under the terms of the GNU General Public License as published by
f96e0b
+# the Free Software Foundation, either version 3 of the License, or
f96e0b
+# (at your option) any later version.
f96e0b
+#
f96e0b
+# GRUB is distributed in the hope that it will be useful,
f96e0b
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
f96e0b
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f96e0b
+# GNU General Public License for more details.
f96e0b
+#
f96e0b
+# You should have received a copy of the GNU General Public License
f96e0b
+# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
f96e0b
+
f96e0b
+set -e
f96e0b
+grubshell=@builddir@/grub-shell
f96e0b
+
f96e0b
+. "@builddir@/grub-core/modinfo.sh"
f96e0b
+
f96e0b
+case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
f96e0b
+    *-emu)
f96e0b
+	exit 0;;
f96e0b
+    # FIXME: qemu gets bonito DMA wrong
f96e0b
+    mipsel-loongson)
f96e0b
+	exit 0;;
f96e0b
+    # no USB on ARC and qemu-mips platforms
f96e0b
+    mips*-arc | mips*-qemu_mips)
f96e0b
+	exit 0;;
f96e0b
+    # FIXME: No native drivers are available for those
f96e0b
+    powerpc-ieee1275 | sparc64-ieee1275)
f96e0b
+	exit 0;;
f96e0b
+esac
f96e0b
+
f96e0b
+imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
f96e0b
+outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
f96e0b
+
f96e0b
+echo "hello" > "$outfile"
f96e0b
+
f96e0b
+tar cf "$imgfile" "$outfile"
f96e0b
+
f96e0b
+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
f96e0b
+   rm "$imgfile"
f96e0b
+   rm "$outfile"
f96e0b
+   exit 1
f96e0b
+fi
f96e0b
+
f96e0b
+rm "$imgfile"
f96e0b
+rm "$outfile"
f96e0b
diff --git a/tests/grub_script_escape_comma.in b/tests/grub_script_escape_comma.in
f96e0b
new file mode 100644
f96e0b
index 0000000..eff3179
f96e0b
--- /dev/null
f96e0b
+++ b/tests/grub_script_escape_comma.in
f96e0b
@@ -0,0 +1,18 @@
f96e0b
+#! @builddir@/grub-shell-tester
f96e0b
+
f96e0b
+x=1\\,1
f96e0b
+echo $x
f96e0b
+y='$'
f96e0b
+echo $y
f96e0b
+z='\'
f96e0b
+echo $z
f96e0b
+t='\*'
f96e0b
+echo $t
f96e0b
+u='$'
f96e0b
+echo $u
f96e0b
+v='\?'
f96e0b
+echo $v
f96e0b
+
f96e0b
+
f96e0b
+echo \\
f96e0b
+
f96e0b
diff --git a/tests/help_test.in b/tests/help_test.in
f96e0b
new file mode 100644
f96e0b
index 0000000..e780924
f96e0b
--- /dev/null
f96e0b
+++ b/tests/help_test.in
f96e0b
@@ -0,0 +1,16 @@
f96e0b
+#! /bin/bash
f96e0b
+set -e
f96e0b
+
f96e0b
+. "@builddir@/grub-core/modinfo.sh"
f96e0b
+
f96e0b
+template="Usage: help [PATTERN ...]
f96e0b
+Show a help message.
f96e0b
+
f96e0b
+-h, --help              Display this help and exit.
f96e0b
+-u, --usage             Display the usage of this command and exit.
f96e0b
+Hello World"
f96e0b
+outpu="$(echo 'help help; hello' | @builddir@/grub-shell)"
f96e0b
+
f96e0b
+if [ "$template" != "$outpu" ]; then
f96e0b
+    exit 1
f96e0b
+fi
f96e0b
diff --git a/tests/ohci_test.in b/tests/ohci_test.in
f96e0b
new file mode 100644
f96e0b
index 0000000..d6c1e0c
f96e0b
--- /dev/null
f96e0b
+++ b/tests/ohci_test.in
f96e0b
@@ -0,0 +1,50 @@
f96e0b
+#! /bin/sh
f96e0b
+# Copyright (C) 2013  Free Software Foundation, Inc.
f96e0b
+#
f96e0b
+# GRUB is free software: you can redistribute it and/or modify
f96e0b
+# it under the terms of the GNU General Public License as published by
f96e0b
+# the Free Software Foundation, either version 3 of the License, or
f96e0b
+# (at your option) any later version.
f96e0b
+#
f96e0b
+# GRUB is distributed in the hope that it will be useful,
f96e0b
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
f96e0b
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f96e0b
+# GNU General Public License for more details.
f96e0b
+#
f96e0b
+# You should have received a copy of the GNU General Public License
f96e0b
+# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
f96e0b
+
f96e0b
+set -e
f96e0b
+grubshell=@builddir@/grub-shell
f96e0b
+
f96e0b
+. "@builddir@/grub-core/modinfo.sh"
f96e0b
+
f96e0b
+case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
f96e0b
+    *-emu)
f96e0b
+	exit 0;;
f96e0b
+    # FIXME: qemu gets bonito DMA wrong
f96e0b
+    mipsel-loongson)
f96e0b
+	exit 0;;
f96e0b
+    # no USB on ARC and qemu-mips platforms
f96e0b
+    mips*-arc | mips*-qemu_mips)
f96e0b
+	exit 0;;
f96e0b
+    # FIXME: No native drivers are available for those
f96e0b
+    powerpc-ieee1275 | sparc64-ieee1275)
f96e0b
+	exit 0;;
f96e0b
+esac
f96e0b
+
f96e0b
+imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
f96e0b
+outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
f96e0b
+
f96e0b
+echo "hello" > "$outfile"
f96e0b
+
f96e0b
+tar cf "$imgfile" "$outfile"
f96e0b
+
f96e0b
+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
f96e0b
+   rm "$imgfile"
f96e0b
+   rm "$outfile"
f96e0b
+   exit 1
f96e0b
+fi
f96e0b
+
f96e0b
+rm "$imgfile"
f96e0b
+rm "$outfile"
f96e0b
diff --git a/tests/pata_test.in b/tests/pata_test.in
f96e0b
new file mode 100644
f96e0b
index 0000000..3671300
f96e0b
--- /dev/null
f96e0b
+++ b/tests/pata_test.in
f96e0b
@@ -0,0 +1,54 @@
f96e0b
+#! /bin/sh
f96e0b
+# Copyright (C) 2013  Free Software Foundation, Inc.
f96e0b
+#
f96e0b
+# GRUB is free software: you can redistribute it and/or modify
f96e0b
+# it under the terms of the GNU General Public License as published by
f96e0b
+# the Free Software Foundation, either version 3 of the License, or
f96e0b
+# (at your option) any later version.
f96e0b
+#
f96e0b
+# GRUB is distributed in the hope that it will be useful,
f96e0b
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
f96e0b
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f96e0b
+# GNU General Public License for more details.
f96e0b
+#
f96e0b
+# You should have received a copy of the GNU General Public License
f96e0b
+# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
f96e0b
+
f96e0b
+set -e
f96e0b
+grubshell=@builddir@/grub-shell
f96e0b
+
f96e0b
+. "@builddir@/grub-core/modinfo.sh"
f96e0b
+
f96e0b
+disk=hda
f96e0b
+indisk=ata0
f96e0b
+
f96e0b
+case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
f96e0b
+    *-emu)
f96e0b
+	exit 0;;
f96e0b
+    # no ATA on ARC platforms (they use SCSI)
f96e0b
+    *-arc)
f96e0b
+	exit 0;;
f96e0b
+    # FIXME: No native drivers are available for those
f96e0b
+    powerpc-ieee1275 | sparc64-ieee1275)
f96e0b
+	exit 0;;
f96e0b
+    i386-ieee1275)
f96e0b
+	disk=hdb
f96e0b
+	indisk=ata1
f96e0b
+	;;
f96e0b
+esac
f96e0b
+
f96e0b
+imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
f96e0b
+outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
f96e0b
+
f96e0b
+echo "hello" > "$outfile"
f96e0b
+
f96e0b
+tar cf "$imgfile" "$outfile"
f96e0b
+
f96e0b
+if [ "$(echo "nativedisk; source '($indisk)/$outfile';" | "${grubshell}" --qemu-opts="-$disk $imgfile")" != "Hello World" ]; then
f96e0b
+   rm "$imgfile"
f96e0b
+   rm "$outfile"
f96e0b
+   exit 1
f96e0b
+fi
f96e0b
+
f96e0b
+rm "$imgfile"
f96e0b
+rm "$outfile"
f96e0b
diff --git a/tests/uhci_test.in b/tests/uhci_test.in
f96e0b
new file mode 100644
f96e0b
index 0000000..ec6731c
f96e0b
--- /dev/null
f96e0b
+++ b/tests/uhci_test.in
f96e0b
@@ -0,0 +1,50 @@
f96e0b
+#! /bin/sh
f96e0b
+# Copyright (C) 2013  Free Software Foundation, Inc.
f96e0b
+#
f96e0b
+# GRUB is free software: you can redistribute it and/or modify
f96e0b
+# it under the terms of the GNU General Public License as published by
f96e0b
+# the Free Software Foundation, either version 3 of the License, or
f96e0b
+# (at your option) any later version.
f96e0b
+#
f96e0b
+# GRUB is distributed in the hope that it will be useful,
f96e0b
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
f96e0b
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f96e0b
+# GNU General Public License for more details.
f96e0b
+#
f96e0b
+# You should have received a copy of the GNU General Public License
f96e0b
+# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
f96e0b
+
f96e0b
+set -e
f96e0b
+grubshell=@builddir@/grub-shell
f96e0b
+
f96e0b
+. "@builddir@/grub-core/modinfo.sh"
f96e0b
+
f96e0b
+case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
f96e0b
+    *-emu)
f96e0b
+	exit 0;;
f96e0b
+    # FIXME: qemu gets bonito DMA wrong
f96e0b
+    mipsel-loongson)
f96e0b
+	exit 0;;
f96e0b
+    # no USB on ARC and qemu-mips platforms
f96e0b
+    mips*-arc | mips*-qemu_mips)
f96e0b
+	exit 0;;
f96e0b
+    # FIXME: No native drivers are available for those
f96e0b
+    powerpc-ieee1275 | sparc64-ieee1275)
f96e0b
+	exit 0;;
f96e0b
+esac
f96e0b
+
f96e0b
+imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
f96e0b
+outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
f96e0b
+
f96e0b
+echo "hello" > "$outfile"
f96e0b
+
f96e0b
+tar cf "$imgfile" "$outfile"
f96e0b
+
f96e0b
+if [ "$(echo "nativedisk; source '(usb0)/$outfile';" | "${grubshell}" --qemu-opts="-usb -usbdevice disk:$imgfile" | tail -n 1)" != "Hello World" ]; then
f96e0b
+   rm "$imgfile"
f96e0b
+   rm "$outfile"
f96e0b
+   exit 1
f96e0b
+fi
f96e0b
+
f96e0b
+rm "$imgfile"
f96e0b
+rm "$outfile"
f96e0b
diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in
f96e0b
index b034e96..5b20ca3 100644
f96e0b
--- a/tests/util/grub-shell.in
f96e0b
+++ b/tests/util/grub-shell.in
f96e0b
@@ -322,7 +322,7 @@ do
f96e0b
 done
f96e0b
 
f96e0b
 cat <<EOF >>${cfgfile}
f96e0b
-source \$prefix/testcase.cfg
f96e0b
+source "\$prefix/testcase.cfg"
f96e0b
 # Stop serial output to suppress "ACPI shutdown failed" error.
f96e0b
 EOF
f96e0b
 if [ x$console != x ]; then
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b