On Wed, 10 Jun 2026 00:47, Pierrick Bouvier <[email protected]> 
wrote:
Semihosting console tests require console interaction, and were flagged
as manual because of this. This wrapper automates interaction, by
sending a specific string on stdin.

Signed-off-by: Pierrick Bouvier <[email protected]>
---

Fyi there is also expect(1) https://packages.debian.org/trixie/expect but is kind of arcane.

tests/tcg/meson.build               |  1 +
tests/tcg/scripts/run_with_input.sh | 12 ++++++++++++
2 files changed, 13 insertions(+)
create mode 100755 tests/tcg/scripts/run_with_input.sh

diff --git a/tests/tcg/meson.build b/tests/tcg/meson.build
index f379449e582..7201a7809e1 100644
--- a/tests/tcg/meson.build
+++ b/tests/tcg/meson.build
@@ -8,6 +8,7 @@ endif
gdb = find_program(gdb_progs, required: false)
prog_gdb_test = find_program('../guest-debug/run-test.py')
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(
  './scripts/run_and_check_forbidden_output.sh'
)
diff --git a/tests/tcg/scripts/run_with_input.sh 
b/tests/tcg/scripts/run_with_input.sh
new file mode 100755
index 00000000000..3d280547c3a
--- /dev/null
+++ b/tests/tcg/scripts/run_with_input.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+set -euo pipefail
+
+if [ $# -lt 2 ]; then
+    echo "run_with_input: input_string cmd [args]..." 1>&2
+    exit 1
+fi
+input="$1";shift
+set -x
+echo "$input" | "$@"
--
2.43.0


Reply via email to