tests/util/grub-shell: Create run.sh in working directory for easily running test again
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 (e.g. 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> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
parent
cb7afebc36
commit
73f2e73815
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user