From 22a46d4f7bc371a2289446248d2ea8ea4fdd2163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 4 Aug 2022 16:31:58 +0200 Subject: [PATCH] tests/kvm: Allow passing multi argument test cases This means we can wrap the test case in another executable, or pass arguments to test case executables. Part-of: --- src/tests/kvm/run-kvm-test.sh | 3 +-- src/tests/kvm/virtme-run.sh | 10 ++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/tests/kvm/run-kvm-test.sh b/src/tests/kvm/run-kvm-test.sh index 3f022d147..974ff75ea 100755 --- a/src/tests/kvm/run-kvm-test.sh +++ b/src/tests/kvm/run-kvm-test.sh @@ -5,7 +5,6 @@ set -e WRAPPER="$1" WRAPPER_ARGS="$2" TEST_RESULT="$3" -TEST_EXECUTABLE="$4" export XDG_RUNTIME_DIR="/tmp/sub-runtime-dir-$UID" export GSETTINGS_SCHEMA_DIR="$PWD/build/data" @@ -18,6 +17,6 @@ mkdir -p -m 700 $XDG_RUNTIME_DIR glib-compile-schemas $GSETTINGS_SCHEMA_DIR -"$WRAPPER" $WRAPPER_ARGS "$TEST_EXECUTABLE" +"$WRAPPER" $WRAPPER_ARGS "${@:4}" echo $? > $TEST_RESULT diff --git a/src/tests/kvm/virtme-run.sh b/src/tests/kvm/virtme-run.sh index 191493258..e41d21c77 100755 --- a/src/tests/kvm/virtme-run.sh +++ b/src/tests/kvm/virtme-run.sh @@ -8,7 +8,6 @@ WRAPPER="$2" WRAPPER_ARGS="$3" TEST_BUILD_DIR="$4" VM_ENV="$5" -TEST_EXECUTABLE="$6" TEST_RESULT_FILE=$(mktemp -p "$TEST_BUILD_DIR" -t test-result-XXXXXX) echo 1 > "$TEST_RESULT_FILE" @@ -30,12 +29,19 @@ if [[ "$(stat -c '%t:%T' -L /proc/$$/fd/0)" == "0:0" ]]; then rm -f $XDG_RUNTIME_DIR/fake-stdin.$$ fi +SCRIPT="\ + env $VIRTME_ENV $DIRNAME/run-kvm-test.sh \ + \\\"$WRAPPER\\\" \\\"$WRAPPER_ARGS\\\" \ + \\\"$TEST_RESULT_FILE\\\" \ + $(printf "\"%s\" " "${@:6}")\ +" + virtme-run \ --memory=256M \ --rw \ --pwd \ --kimg "$IMAGE" \ - --script-sh "sh -c \"env $VIRTME_ENV $DIRNAME/run-kvm-test.sh \\\"$WRAPPER\\\" \\\"$WRAPPER_ARGS\\\" \\\"$TEST_RESULT_FILE\\\" \\\"$TEST_EXECUTABLE\\\"\"" \ + --script-sh "sh -c \"$SCRIPT\"" \ --qemu-opts -cpu host,pdcm=off -smp 2 TEST_RESULT="$(cat "$TEST_RESULT_FILE")"