All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Add serial test
@ 2023-08-15  3:33 Glenn Washburn
  2023-08-15  3:33 ` [PATCH 1/2] tests/util/grub-shell: Allow explicitly using other serial ports for output Glenn Washburn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Glenn Washburn @ 2023-08-15  3:33 UTC (permalink / raw)
  To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn

Pretty self explanatory. The first patch allows explicitly telling grub-shell
which terminal output device to use so we can test that the right bytes are
getting written there. The second patch, which is the serial test, runs
grub-shell once before the real test to identify the PCI id of the serial
device that shouldbe used in the real test. This is needed because the id
varys across targets.

Glenn

Glenn Washburn (2):
  tests/util/grub-shell: Allow explicitly using other serial ports for
    output
  tests: Add serial_test

 Makefile.util.def        |  6 +++++
 tests/serial_test.in     | 55 ++++++++++++++++++++++++++++++++++++++++
 tests/util/grub-shell.in |  6 +++--
 3 files changed, 65 insertions(+), 2 deletions(-)
 create mode 100644 tests/serial_test.in

-- 
2.34.1


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] tests/util/grub-shell: Allow explicitly using other serial ports for output
  2023-08-15  3:33 [PATCH 0/2] Add serial test Glenn Washburn
@ 2023-08-15  3:33 ` Glenn Washburn
  2023-08-15  3:33 ` [PATCH 2/2] tests: Add serial_test Glenn Washburn
  2023-08-17 15:28 ` [PATCH 0/2] Add serial test Daniel Kiper
  2 siblings, 0 replies; 4+ messages in thread
From: Glenn Washburn @ 2023-08-15  3:33 UTC (permalink / raw)
  To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn

While here, move "-qemu=*" case to be next to the "--qemu-opts=*" case.
This causes no change in logic, but is more logically located.

Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 tests/util/grub-shell.in | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in
index 462099bdc4d0..d0de8ae581a2 100644
--- a/tests/util/grub-shell.in
+++ b/tests/util/grub-shell.in
@@ -267,8 +267,6 @@ for option in "$@"; do
     --mkrescue-arg=*)
 	mkr=`echo "$option" | sed -e 's/--mkrescue-arg=//' -e 's/,/ /g'`
 	mkrescue_args="$mkrescue_args $mkr" ;;
-    --qemu=*)
-	qemu=`echo "$option" | sed -e 's/--qemu=//' -e 's/,/ /g'`;;
     --pseries)
 	qemu=qemu-system-ppc64
 	serial_port=ieee1275/hvterm
@@ -277,6 +275,10 @@ for option in "$@"; do
 	trim=1
 	pseries=y
 	    ;;
+    --serial=*)
+	serial_port=`echo "$option" | sed -e 's/--serial=//'`;;
+    --qemu=*)
+	qemu=`echo "$option" | sed -e 's/--qemu=//' -e 's/,/ /g'`;;
     --qemu-opts=*)
 	qs=`echo "$option" | sed -e 's/--qemu-opts=//'`
 	qemuopts="$qemuopts $qs" ;;
-- 
2.34.1


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] tests: Add serial_test
  2023-08-15  3:33 [PATCH 0/2] Add serial test Glenn Washburn
  2023-08-15  3:33 ` [PATCH 1/2] tests/util/grub-shell: Allow explicitly using other serial ports for output Glenn Washburn
@ 2023-08-15  3:33 ` Glenn Washburn
  2023-08-17 15:28 ` [PATCH 0/2] Add serial test Daniel Kiper
  2 siblings, 0 replies; 4+ messages in thread
From: Glenn Washburn @ 2023-08-15  3:33 UTC (permalink / raw)
  To: grub-devel, Daniel Kiper; +Cc: Glenn Washburn

This test is meant to test output via various serial devices. Currently,
only the PCI serial device is tested.

Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 Makefile.util.def    |  6 +++++
 tests/serial_test.in | 55 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)
 create mode 100644 tests/serial_test.in

diff --git a/Makefile.util.def b/Makefile.util.def
index a7cf53111221..42b6288dc809 100644
--- a/Makefile.util.def
+++ b/Makefile.util.def
@@ -1130,6 +1130,12 @@ script = {
   common = tests/netboot_test.in;
 };
 
+script = {
+  testcase = nonnative;
+  name = serial_test;
+  common = tests/serial_test.in;
+};
+
 script = {
   testcase = nonnative;
   name = pseries_test;
diff --git a/tests/serial_test.in b/tests/serial_test.in
new file mode 100644
index 000000000000..b2332f904df0
--- /dev/null
+++ b/tests/serial_test.in
@@ -0,0 +1,55 @@
+#! @BUILD_SHEBANG@
+# Copyright (C) 2023  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
+    # PLATFORM: emu is different
+    *-emu)
+	exit 77;;
+    # PLATFORM: Flash targets
+    i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips)
+	exit 77;;
+    # FIXME: currently grub-shell uses only -kernel for loongson
+    mipsel-loongson)
+	exit 77;;
+    # FIXME: How do we setup serial ports in QEMU for these platforms?
+    *-ieee1275)
+	exit 77;;
+esac
+
+# Figure out the PCI device ID that the serial device will be on
+output=$(echo terminal_output | "${grubshell}" --qemu-opts="-device pci-serial")
+PCIID=$(echo "$output" | grep -o "serial_pci,..:..\.." | cut -d, -f2)
+
+if [ -z "$PCIID" ]; then
+  echo "Failed to find QEMU serial device." >&2
+  echo "${output}" >&2
+  exit 99
+fi
+
+# Test serial output via an emulated PCI serial card.
+output=$(echo "terminal_output; hello" | \
+  "${grubshell}" --serial="pci,${PCIID}" \
+    --qemu-opts="-chardev file,path=/dev/stdout,id=ser1 -device pci-serial,chardev=ser1")
+
+v=$(echo -e "$output" | tail -n1)
+if [ "$v" != "Hello World" ]; then
+   exit 1
+fi
-- 
2.34.1


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Add serial test
  2023-08-15  3:33 [PATCH 0/2] Add serial test Glenn Washburn
  2023-08-15  3:33 ` [PATCH 1/2] tests/util/grub-shell: Allow explicitly using other serial ports for output Glenn Washburn
  2023-08-15  3:33 ` [PATCH 2/2] tests: Add serial_test Glenn Washburn
@ 2023-08-17 15:28 ` Daniel Kiper
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Kiper @ 2023-08-17 15:28 UTC (permalink / raw)
  To: Glenn Washburn; +Cc: grub-devel

On Mon, Aug 14, 2023 at 10:33:50PM -0500, Glenn Washburn wrote:
> Pretty self explanatory. The first patch allows explicitly telling grub-shell
> which terminal output device to use so we can test that the right bytes are
> getting written there. The second patch, which is the serial test, runs
> grub-shell once before the real test to identify the PCI id of the serial
> device that shouldbe used in the real test. This is needed because the id
> varys across targets.
>
> Glenn
>
> Glenn Washburn (2):
>   tests/util/grub-shell: Allow explicitly using other serial ports for
>     output
>   tests: Add serial_test

For both patches Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>...

Daniel

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-17 15:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-15  3:33 [PATCH 0/2] Add serial test Glenn Washburn
2023-08-15  3:33 ` [PATCH 1/2] tests/util/grub-shell: Allow explicitly using other serial ports for output Glenn Washburn
2023-08-15  3:33 ` [PATCH 2/2] tests: Add serial_test Glenn Washburn
2023-08-17 15:28 ` [PATCH 0/2] Add serial test Daniel Kiper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.