From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202508 header.b=Kz54xMi3; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 6933B5A0619 for ; Thu, 02 Oct 2025 09:57:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202508; t=1759391830; bh=fsX4G0dAtsgqKlrK43R5xiV4jyFDEcf6za0m5k4FaGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kz54xMi3TSkzf1zv0IB1iYi1+JnJHHbyYvLscdwurjl9p4wy6QWMNg7nxyBzqYihD 0mxi5rwN0pxxy6CVfSfVSGkzi79tcj1W4DwrNZDSiOwStXmo0G+EjCgEigYHYovCJz ah3UBTqCIQygCuA/3UpfGREsYtRTZomsmt5EegUTGfHANSBpeuEV1VI6/vkvawaxvb e/W+TblHLIx0Y0mNaiYQrw+GEVPsxLfMiZemoefelM0aY/JhvVK4HZrvg3stngb9wv 7LzTh2h+CdsiuzkYDakmD27Sj/IU5DpiZYqkkiR+GKA4OT8p0SxHaYrN0rGe9yxmIL LlP/O5xLbXz/w== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4cckfG2lxqz4w9w; Thu, 2 Oct 2025 17:57:10 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 1/3] test: Prepare for tunbridge based tests Date: Thu, 2 Oct 2025 17:57:06 +1000 Message-ID: <20251002075708.461931-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251002075708.461931-1-david@gibson.dropbear.id.au> References: <20251002075708.461931-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: K6XQ42OH7ZNRWFTME6PG7YRBIH4JQZBC X-Message-ID-Hash: K6XQ42OH7ZNRWFTME6PG7YRBIH4JQZBC X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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""" + + import tunbridge + import tasst + + print(f"Imported exeter: {exeter}") + print(f"Imported tunbridge: {tunbridge}") + print(f"Imported tasst: {tasst}") + + +if __name__ == '__main__': + exeter.main() diff --git a/test/tasst/__init__.py b/test/tasst/__init__.py new file mode 100644 index 00000000..fd4fe9a8 --- /dev/null +++ b/test/tasst/__init__.py @@ -0,0 +1,10 @@ +#! /usr/bin/env python3 +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +# TASST - Test A Simple Socket Transport +# +# test/tasst/__init.py__ - Python library code useful for test cases +# +# Copyright Red Hat +# Author: David Gibson -- 2.51.0