diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2025-09-05 16:43:13 +1000 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2025-09-05 13:00:04 +0200 |
commit | a283ef47b9b3d525e54d1679f0bbc68ed5498e27 (patch) | |
tree | 85779f99f7906048110b067f95fdee794eecdc9b | |
parent | ca38be0141d17cbdd419fc49fb028a96612aa3b5 (diff) | |
download | passt-a283ef47b9b3d525e54d1679f0bbc68ed5498e27.tar passt-a283ef47b9b3d525e54d1679f0bbc68ed5498e27.tar.gz passt-a283ef47b9b3d525e54d1679f0bbc68ed5498e27.tar.bz2 passt-a283ef47b9b3d525e54d1679f0bbc68ed5498e27.tar.lz passt-a283ef47b9b3d525e54d1679f0bbc68ed5498e27.tar.xz passt-a283ef47b9b3d525e54d1679f0bbc68ed5498e27.tar.zst passt-a283ef47b9b3d525e54d1679f0bbc68ed5498e27.zip |
test: Extend test scripts to allow running exeter tests.
Introduce some trivial testcases based on the exeter library. These run
passt and pasta with --help and --version options. Extend our test
scripts to run these tests.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r-- | test/.gitignore | 1 | ||||
-rw-r--r-- | test/Makefile | 10 | ||||
-rw-r--r-- | test/lib/exeter | 58 | ||||
-rwxr-xr-x | test/run | 9 | ||||
-rwxr-xr-x | test/smoke/smoke.sh | 33 |
5 files changed, 108 insertions, 3 deletions
diff --git a/test/.gitignore b/test/.gitignore index 3573444..cf48b88 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -11,3 +11,4 @@ nstool rampstream guest-key guest-key.pub +/exeter/ diff --git a/test/Makefile b/test/Makefile index bf63db8..bfb58f2 100644 --- a/test/Makefile +++ b/test/Makefile @@ -5,6 +5,7 @@ # Copyright Red Hat # Author: David Gibson <david@gibson.dropbear.id.au> +EXETOOL = exeter/exetool/exetool WGET = wget -c DEBIAN_IMGS = debian-8.11.0-openstack-amd64.qcow2 \ @@ -50,14 +51,14 @@ UBUNTU_NEW_IMGS = xenial-server-cloudimg-powerpc-disk1.img \ jammy-server-cloudimg-s390x.img UBUNTU_IMGS = $(UBUNTU_OLD_IMGS) $(UBUNTU_NEW_IMGS) -DOWNLOAD_ASSETS = mbuto podman \ +DOWNLOAD_ASSETS = exeter mbuto podman \ $(DEBIAN_IMGS) $(FEDORA_IMGS) $(OPENSUSE_IMGS) $(UBUNTU_IMGS) TESTDATA_ASSETS = small.bin big.bin medium.bin \ rampstream LOCAL_ASSETS = mbuto.img mbuto.mem.img podman/bin/podman QEMU_EFI.fd \ $(DEBIAN_IMGS:%=prepared-%) $(FEDORA_IMGS:%=prepared-%) \ $(UBUNTU_NEW_IMGS:%=prepared-%) \ - nstool guest-key guest-key.pub \ + nstool guest-key guest-key.pub $(EXETOOL) \ $(TESTDATA_ASSETS) ASSETS = $(DOWNLOAD_ASSETS) $(LOCAL_ASSETS) @@ -70,6 +71,11 @@ assets: $(ASSETS) pull-%: % git -C $* pull +exeter: + git clone https://gitlab.com/dgibson/exeter.git + +exeter/exetool/exetool: pull-exeter + mbuto: git clone git://mbuto.sh/mbuto diff --git a/test/lib/exeter b/test/lib/exeter new file mode 100644 index 0000000..3b19bea --- /dev/null +++ b/test/lib/exeter @@ -0,0 +1,58 @@ +#!/bin/sh +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/lib/exeter - Run exeter tests within the rest of passt's tests +# +# Copyright Red Hat +# Author: David Gibson <david@gibson.dropbear.id.au> + +EXETOOL="$BASEPATH/exeter/exetool/exetool" + +# is_exeter() - Determine if a test file is an exeter program +# $@: Command line to invoke test program +is_exeter() { + $EXETOOL probe -- "$@" +} + +# exeter() - Run each test in an exeter program, logging each test separately +# $@: Command line to invoke exeter test program +exeter() { + STATESETUP="${STATEBASE}/$1" + mkdir -p "${STATESETUP}" + + context_setup_host host + layout_host + + cd test + + __ntests=$($EXETOOL list -- "$@" | wc -l) + if [ $? != 0 ]; then + info "Failed to get exeter manifest for $@" + pause_continue \ + "Press any key to pause test session" \ + "Resuming in " \ + "Paused, press any key to continue" \ + 5 + return + fi + + status_file_start "$* (exeter)" ${__ntests} + [ ${CI} -eq 1 ] && video_link "${1}" + + for __testid in $($EXETOOL list -- "$@"); do + __desc="$($EXETOOL desc -- "$@" -- ${__testid})" + status_test_start "${__desc}" + context_run host "$@" "${__testid}" && status_test_ok || status_test_fail + done + + cd .. + + teardown_context_watch ${PANE_HOST} host +} @@ -53,6 +53,7 @@ COMMIT="$(git log --oneline --no-decorate -1)" . lib/layout_ugly . lib/test . lib/video +. lib/exeter # cleanup() - Remove temporary files cleanup() { @@ -67,6 +68,8 @@ run() { perf_init [ ${CI} -eq 1 ] && video_start ci + exeter smoke/smoke.sh + setup build test build/all test build/cppcheck @@ -223,6 +226,10 @@ run_selected() { __setup= for __test; do + if is_exeter "test/${__test}"; then + exeter "${__test}" + continue + fi # HACK: the migrate tests need the setup repeated for # each test if [ "${__test%%/*}" != "${__setup}" -o \ @@ -234,7 +241,7 @@ run_selected() { test "${__test}" done - teardown "${__setup}" + [ -n "${__setup}" ] && teardown "${__setup}" log "PASS: ${STATUS_PASS}, FAIL: ${STATUS_FAIL}, SKIPPED: ${STATUS_SKIPPED}" diff --git a/test/smoke/smoke.sh b/test/smoke/smoke.sh new file mode 100755 index 0000000..a642fb9 --- /dev/null +++ b/test/smoke/smoke.sh @@ -0,0 +1,33 @@ +#! /bin/sh +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/smoke/smoke.sh - Basic smoke tests +# +# Copyright Red Hat +# Author: David Gibson <david@gibson.dropbear.id.au> + +. $(dirname $0)/../exeter/sh/exeter.sh + +PASST=$(dirname $0)/../../passt +PASTA=$(dirname $0)/../../pasta + +exeter_register passt_version $PASST --version +exeter_set_description passt_version "Check passt --version works" + +exeter_register pasta_version $PASTA --version +exeter_set_description pasta_version "Check pasta --version works" + +exeter_register passt_help $PASST --help +exeter_set_description passt_help "Check passt --help works" + +exeter_register pasta_help $PASTA --help +exeter_set_description pasta_help "Check pasta --help works" + +exeter_main "$@" |