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.

> +# 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

Reply via email to