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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2561>
This commit is contained in:
Jonas Ådahl 2022-08-04 16:31:58 +02:00
parent 2df9ccd598
commit 22a46d4f7b
2 changed files with 9 additions and 4 deletions

View File

@ -5,7 +5,6 @@ set -e
WRAPPER="$1" WRAPPER="$1"
WRAPPER_ARGS="$2" WRAPPER_ARGS="$2"
TEST_RESULT="$3" TEST_RESULT="$3"
TEST_EXECUTABLE="$4"
export XDG_RUNTIME_DIR="/tmp/sub-runtime-dir-$UID" export XDG_RUNTIME_DIR="/tmp/sub-runtime-dir-$UID"
export GSETTINGS_SCHEMA_DIR="$PWD/build/data" export GSETTINGS_SCHEMA_DIR="$PWD/build/data"
@ -18,6 +17,6 @@ mkdir -p -m 700 $XDG_RUNTIME_DIR
glib-compile-schemas $GSETTINGS_SCHEMA_DIR glib-compile-schemas $GSETTINGS_SCHEMA_DIR
"$WRAPPER" $WRAPPER_ARGS "$TEST_EXECUTABLE" "$WRAPPER" $WRAPPER_ARGS "${@:4}"
echo $? > $TEST_RESULT echo $? > $TEST_RESULT

View File

@ -8,7 +8,6 @@ WRAPPER="$2"
WRAPPER_ARGS="$3" WRAPPER_ARGS="$3"
TEST_BUILD_DIR="$4" TEST_BUILD_DIR="$4"
VM_ENV="$5" VM_ENV="$5"
TEST_EXECUTABLE="$6"
TEST_RESULT_FILE=$(mktemp -p "$TEST_BUILD_DIR" -t test-result-XXXXXX) TEST_RESULT_FILE=$(mktemp -p "$TEST_BUILD_DIR" -t test-result-XXXXXX)
echo 1 > "$TEST_RESULT_FILE" 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.$$ rm -f $XDG_RUNTIME_DIR/fake-stdin.$$
fi fi
SCRIPT="\
env $VIRTME_ENV $DIRNAME/run-kvm-test.sh \
\\\"$WRAPPER\\\" \\\"$WRAPPER_ARGS\\\" \
\\\"$TEST_RESULT_FILE\\\" \
$(printf "\"%s\" " "${@:6}")\
"
virtme-run \ virtme-run \
--memory=256M \ --memory=256M \
--rw \ --rw \
--pwd \ --pwd \
--kimg "$IMAGE" \ --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 --qemu-opts -cpu host,pdcm=off -smp 2
TEST_RESULT="$(cat "$TEST_RESULT_FILE")" TEST_RESULT="$(cat "$TEST_RESULT_FILE")"