grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/3] grub-shell: Create run.sh in working directory for easily ru


From: Glenn Washburn
Subject: [PATCH 2/3] grub-shell: Create run.sh in working directory for easily running test again
Date: Sat, 21 Jan 2023 00:10:45 -0600

Now it becomes trivial to re-run a test from the output in its working
directory. This also makes it easy to send a reproducible failing test to
the mailing list. This has allowed a refactor so that the duplicated code
to call QEMU has be condensed (eg. the use of timeout and file descriptor
redirection). The run.sh script will pass any arguments given to QEMU.
This allows QEMU to be easily started in a state ready for GDB to be
attached.

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

diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in
index 60494bcf1d..658485f7ea 100644
--- a/tests/util/grub-shell.in
+++ b/tests/util/grub-shell.in
@@ -521,8 +521,11 @@ if [ x$boot = xnet ]; then
     cp "${cfgfile}" "$netdir/boot/grub/grub.cfg"
     cp "${source}" "$netdir/boot/grub/testcase.cfg"
     [ -z "$files" ] || copy_extra_files "$netdir" $files
-    setup_qemu_logger
-    timeout -s KILL $timeout "${qemu}" ${qemuopts} ${serial_null} -serial 
file:/dev/stdout -boot n -net 
"user,tftp=$netdir,bootfile=/boot/grub/${grub_modinfo_target_cpu}-${grub_modinfo_platform}/core.$netbootext"
  -net nic > "$work_directory/qemu-pipe" || ret=$?
+    cat >"$work_directory/run.sh" <<EOF
+#! @BUILD_SHEBANG@
+qemuopts="${qemuopts}"
+exec "${qemu}" \${qemuopts} ${serial_null} -serial file:/dev/stdout -boot n 
-net 
"user,tftp=$netdir,bootfile=/boot/grub/${grub_modinfo_target_cpu}-${grub_modinfo_platform}/core.$netbootext"
  -net nic "\$@"
+EOF
 elif [ x$boot = xemu ]; then
     rootdir="$work_directory/rootdir"
     grubdir="$rootdir/boot/grub"
@@ -541,11 +544,25 @@ elif [ x$boot = xemu ]; then
     [ -z "$files" ] || copy_extra_files "$rootdir" $files
     roottar="$work_directory/root.tar"
     (cd "$rootdir"; tar cf "$roottar" .)
-    setup_qemu_logger
-    "${builddir}/grub-core/grub-emu" -m "$device_map" --memdisk "$roottar" -r 
memdisk -d "/boot/grub" > "$work_directory/qemu-pipe" || ret=$?
+    cat >"$work_directory/run.sh" <<EOF
+#! @BUILD_SHEBANG@
+SDIR=\$(realpath -e \${0%/*})
+exec "$(realpath -e "${builddir}")/grub-core/grub-emu" -m 
"\$SDIR/${device_map##*/}" --memdisk "\$SDIR/${roottar##*/}" -r memdisk -d 
"/boot/grub"
+EOF
 else
+    cat >"$work_directory/run.sh" <<EOF
+#! @BUILD_SHEBANG@
+SDIR=\$(realpath -e \${0%/*})
+qemuopts="${qemuopts}"
+cd "\$SDIR"
+exec "${qemu}" \${qemuopts} ${serial_null} -serial file:/dev/stdout 
-${device}"\${SDIR}/${isofile##*/}" ${bootdev} "\$@"
+EOF
+fi
+
+if [ -f "$work_directory/run.sh" ]; then
     setup_qemu_logger
-    timeout -s KILL $timeout "${qemu}" ${qemuopts} ${serial_null} -serial 
file:/dev/stdout -${device}"${isofile}" ${bootdev} > 
"$work_directory/qemu-pipe" || ret=$?
+    chmod +x "$work_directory/run.sh"
+    timeout -s KILL $timeout "$work_directory/run.sh" > 
"$work_directory/qemu-pipe" || ret=$?
 fi
 
 wait
@@ -565,6 +582,7 @@ fi
 test -n "$debug" || rm -f "${isofile}"
 test -n "$debug" || rm -rf "${rom_directory}"
 test -n "$debug" || rm -f "${tmpfile}" "${cfgfile}" "${goutfile}"
+test -n "$debug" || rm -f "$work_directory/run.sh"
 
 exit $ret
 
-- 
2.34.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]