Pierrick Bouvier <[email protected]> writes: > On 7/9/2026 8:03 AM, Pierrick Bouvier wrote: >> On 7/9/2026 7:52 AM, Alex Bennée wrote: >>> Pierrick Bouvier <[email protected]> writes: >>> >>>> Runs a record and replay test, and make sure the output produced by >>>> both runs is the same. >>>> >>>> Signed-off-by: Pierrick Bouvier <[email protected]> >>>> --- >>>> tests/tcg/meson.build | 1 + >>>> tests/tcg/scripts/record_replay.sh | 16 ++++++++++++++++ >>>> 2 files changed, 17 insertions(+) >>>> create mode 100755 tests/tcg/scripts/record_replay.sh >>>> >>>> diff --git a/tests/tcg/meson.build b/tests/tcg/meson.build >>>> index 30178df0f7a..e610ce30f40 100644 >>>> --- a/tests/tcg/meson.build >>>> +++ b/tests/tcg/meson.build >>>> @@ -7,6 +7,7 @@ if config_host.has_key('GDB') >>>> endif >>>> gdb = find_program(gdb_progs, required: false) >>>> prog_gdb_test = find_program('../guest-debug/run-test.py') >>>> +prog_record_replay = find_program('./scripts/record_replay.sh') >>>> prog_run_and_diff = find_program('./scripts/run_and_diff.sh') >>>> prog_run_with_input = find_program('./scripts/run_with_input.sh') >>>> prog_run_and_check_forbidden_output = find_program( >>>> diff --git a/tests/tcg/scripts/record_replay.sh >>>> b/tests/tcg/scripts/record_replay.sh >>>> new file mode 100755 >>>> index 00000000000..57775a2d4c1 >>>> --- /dev/null >>>> +++ b/tests/tcg/scripts/record_replay.sh >>>> @@ -0,0 +1,16 @@ >>>> +#!/usr/bin/env bash >>> >>> While at it is there any reason this couldn't be plain POSIX shell. I >>> don't think we explicitly require bash although its super likely to be >>> on most systems. configure is all POSIX shell. >>> >> >> The main reason for me to use bash is that it supports set -uo pipefail >> in combination with set -e. >> >> Which produces: >> - exit if a variable is undefined >> - exit if any command in a pipe sequence fails >> Without this, script shells are pretty much house of cards waiting to >> collapse on any corner case. >> >> bash is available out of the box at least on macos, msys2, and I expect, >> every single linux distro out there. Not sure about bsds though. >> >> If that's such a big issue, I can port the scripts to sh. >> > > Interestingly, QEMU main Makefile makes bash a defacto requirement, > since it uses it for every single command to run. The reason is... to > use -o pipefail. > > https://gitlab.com/qemu-project/qemu/-/blob/master/Makefile?ref_type=heads#L17 >
Well it looks like I misremembered as we list bash as a dependency in qemu-minimal: packages: - bash so I drop my objection. >>>> +# SPDX-License-Identifier: GPL-2.0-or-later >>>> + >>>> +set -euo pipefail >>>> + >>>> +if [ $# -lt 2 ]; then >>>> + echo "record_replay: qemu_bin [args]..." 1>&2 >>>> + exit 1 >>>> +fi >>>> +qemu="$1";shift >>>> +tmp=$(mktemp -d) >>>> +trap "rm -rf $tmp" EXIT >>>> +set -x >>>> +$qemu -icount shift=5,rr=record,rrfile=$tmp/rr.bin "$@" |& tee $tmp/record >>>> +$qemu -icount shift=5,rr=replay,rrfile=$tmp/rr.bin "$@" |& tee $tmp/replay >>>> +diff $tmp/record $tmp/replay >>> >> -- Alex Bennée Virtualisation Tech Lead @ Linaro
