[PATCH 1/3] test: Prepare for tunbridge based tests
I plan to start converting many of our tests to the tunbridge[0] network
simulator framework. This is the first step: downloading and setting up
tunbridge to work within our test scripts. It also introduces a 'tasst'
Python library for code that we might want to reuse across various
tunbridge based tests.
Signed-off-by: David Gibson
One nit only (given it's a RFC...):
On Thu, 2 Oct 2025 17:57:06 +1000
David Gibson
I plan to start converting many of our tests to the tunbridge[0] network simulator framework. This is the first step: downloading and setting up tunbridge to work within our test scripts. It also introduces a 'tasst' Python library for code that we might want to reuse across various tunbridge based tests.
Signed-off-by: David Gibson
--- test/.gitignore | 2 ++ test/Makefile | 19 +++++++++++-------- test/run | 2 +- test/smoke/smoke.py | 26 ++++++++++++++++++++++++++ test/tasst/__init__.py | 10 ++++++++++ 5 files changed, 50 insertions(+), 9 deletions(-) create mode 100755 test/smoke/smoke.py create mode 100644 test/tasst/__init__.py diff --git a/test/.gitignore b/test/.gitignore index 9412f0d3..71409c51 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -12,4 +12,6 @@ rampstream guest-key guest-key.pub /exeter/ +/tunbridge/ *.bats +__pycache__/ diff --git a/test/Makefile b/test/Makefile index 5b5f0fc1..f66c7e7e 100644 --- a/test/Makefile +++ b/test/Makefile @@ -54,7 +54,7 @@ UBUNTU_NEW_IMGS = xenial-server-cloudimg-powerpc-disk1.img \ jammy-server-cloudimg-s390x.img UBUNTU_IMGS = $(UBUNTU_OLD_IMGS) $(UBUNTU_NEW_IMGS)
-DOWNLOAD_ASSETS = $(EXETOOL) mbuto podman \ +DOWNLOAD_ASSETS = $(EXETOOL) tunbridge mbuto podman \ $(DEBIAN_IMGS) $(FEDORA_IMGS) $(OPENSUSE_IMGS) $(UBUNTU_IMGS) TESTDATA_ASSETS = small.bin big.bin medium.bin \ rampstream @@ -65,15 +65,15 @@ LOCAL_ASSETS = mbuto.img mbuto.mem.img podman/bin/podman QEMU_EFI.fd \
ASSETS = $(DOWNLOAD_ASSETS) $(LOCAL_ASSETS)
-EXETER_PYPATH = exeter/py3 -EXETER_PYTHON = build/build.py -EXETER_BATS = smoke/smoke.sh.bats \ - $(EXETER_PYTHON:%=%.bats) build/static_checkers.sh.bats +EXETER_SH = smoke/smoke.sh build/static_checkers.sh +EXETER_PYPATH = exeter/py3:tunbridge/:. +EXETER_PYTHON = smoke/smoke.py build/build.py +EXETER_BATS = $(EXETER_SH:%=%.bats) $(EXETER_PYTHON:%=%.bats) BATS_FILES = $(EXETER_BATS) \ podman/test/system/505-networking-pasta.bats
# Python test code (for linters) -PYPKGS = $(EXETER_PYTHON) +PYPKGS = $(EXETER_PYTHON) tasst
CFLAGS = -Wall -Werror -Wextra -pedantic -std=c99
@@ -88,6 +88,9 @@ exeter:
exeter/exetool/exetool: pull-exeter
+tunbridge: + git clone https://gitlab.com/dgibson/tunbridge.git + mbuto: git clone git://mbuto.sh/mbuto
@@ -139,7 +142,7 @@ flake8: pull-exeter mypy: pull-exeter PYTHONPATH=$(EXETER_PYPATH) $(MYPY) $(PYPKGS)
-$(EXETER_BATS): %.bats: % $(EXETOOL) +$(EXETER_BATS): %.bats: % $(EXETOOL) pull-tunbridge PYTHONPATH=$(EXETER_PYPATH) $(EXETOOL) bats -- $< > $@
bats: $(BATS_FILES) pull-podman @@ -153,7 +156,7 @@ debug: assets
clean: rm -f perf.js *~ - rm -rf .mypy_cache + rm -rf .mypy_cache __pycache__ rm -f $(LOCAL_ASSETS) rm -f $(EXETER_BATS) rm -rf test_logs diff --git a/test/run b/test/run index f858e558..3872a56e 100755 --- a/test/run +++ b/test/run @@ -44,7 +44,7 @@ KERNEL=${KERNEL:-"/boot/vmlinuz-$(uname -r)"} COMMIT="$(git log --oneline --no-decorate -1)"
# Let exeter tests written in Python find their modules -export PYTHONPATH=${BASEPATH}/exeter/py3 +export PYTHONPATH=${BASEPATH}/exeter/py3:${BASEPATH}/tunbridge:${BASEPATH}
. lib/util . lib/context diff --git a/test/smoke/smoke.py b/test/smoke/smoke.py new file mode 100755 index 00000000..cbf77ad9 --- /dev/null +++ b/test/smoke/smoke.py @@ -0,0 +1,26 @@ +#! /usr/bin/env python3 +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +# test/smoke/smoke.py - Python smoke tests +# +# Copyright Red Hat +# Author: David Gibson
+ +import exeter + + +@exeter.test +def py_test_libraries() -> None: + """Check test in Python have access to the libraries we need"""
tests -- Stefano
On Tue, Oct 07, 2025 at 10:00:51PM +0200, Stefano Brivio wrote:
One nit only (given it's a RFC...):
On Thu, 2 Oct 2025 17:57:06 +1000 David Gibson
wrote: [snip] diff --git a/test/smoke/smoke.py b/test/smoke/smoke.py new file mode 100755 index 00000000..cbf77ad9 --- /dev/null +++ b/test/smoke/smoke.py @@ -0,0 +1,26 @@ +#! /usr/bin/env python3 +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +# test/smoke/smoke.py - Python smoke tests +# +# Copyright Red Hat +# Author: David Gibson
+ +import exeter + + +@exeter.test +def py_test_libraries() -> None: + """Check test in Python have access to the libraries we need""" tests
Fixed. -- David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson
participants (2)
-
David Gibson
-
Stefano Brivio