From: David Gibson <david@gibson.dropbear.id.au>
To: passt-dev@passt.top, Stefano Brivio <sbrivio@redhat.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH v2 1/6] test: Add linting of Python test scripts
Date: Thu, 2 Oct 2025 14:50:07 +1000 [thread overview]
Message-ID: <20251002045012.4047974-2-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20251002045012.4047974-1-david@gibson.dropbear.id.au>
We currently have one test moved to the new exeter based framwork written
in Python. We plan to add many more, so add linting (flake8) and type
checking (mypy) of those scripts. This can be invoked manually with
"make flake8" or "make mypy" in test/, and is also added to the static
checkers test set.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
test/Makefile | 14 +++++++++++++-
test/build/build.py | 5 +++--
test/build/static_checkers.sh | 6 +++++-
3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/test/Makefile b/test/Makefile
index 49388276..61ccb075 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -8,6 +8,8 @@
BATS = bats -j $(shell nproc)
EXETOOL = exeter/exetool/exetool
WGET = wget -c
+FLAKE8 = flake8
+MYPY = mypy --strict
DEBIAN_IMGS = debian-8.11.0-openstack-amd64.qcow2 \
debian-10-nocloud-amd64.qcow2 \
@@ -65,11 +67,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 \
- build/build.py.bats build/static_checkers.sh.bats
+ $(EXETER_PYTHON:%=%.bats) build/static_checkers.sh.bats
BATS_FILES = $(EXETER_BATS) \
podman/test/system/505-networking-pasta.bats
+# Python test code (for linters)
+PYPKGS = $(EXETER_PYTHON)
+
CFLAGS = -Wall -Werror -Wextra -pedantic -std=c99
assets: $(ASSETS)
@@ -128,6 +134,12 @@ medium.bin:
big.bin:
dd if=/dev/urandom bs=1M count=10 of=$@
+flake8: pull-exeter
+ PYTHONPATH=$(EXETER_PYPATH) $(FLAKE8) $(PYPKGS)
+
+mypy: pull-exeter
+ PYTHONPATH=$(EXETER_PYPATH) $(MYPY) $(PYPKGS)
+
$(EXETER_BATS): %.bats: % $(EXETOOL)
PYTHONPATH=$(EXETER_PYPATH) $(EXETOOL) bats -- $< > $@
diff --git a/test/build/build.py b/test/build/build.py
index e49287c9..e3de8305 100755
--- a/test/build/build.py
+++ b/test/build/build.py
@@ -18,11 +18,12 @@ import os
from pathlib import Path
import subprocess
import tempfile
-from typing import Iterable, Iterator
+from typing import Iterator
import exeter
-def sh(cmd):
+
+def sh(cmd: str) -> None:
"""Run given command in a shell"""
subprocess.run(cmd, shell=True)
diff --git a/test/build/static_checkers.sh b/test/build/static_checkers.sh
index 42806e79..228b99ae 100755
--- a/test/build/static_checkers.sh
+++ b/test/build/static_checkers.sh
@@ -21,6 +21,10 @@ exeter_set_description cppcheck "passt sources pass cppcheck"
exeter_register clang_tidy make -C .. clang-tidy
exeter_set_description clang_tidy "passt sources pass clang-tidy"
-exeter_main "$@"
+exeter_register flake8 make flake8
+exeter_set_description flake8 "passt tests in Python pass flake8"
+exeter_register mypy make mypy
+exeter_set_description mypy "passt tests in Python pass mypy --strict"
+exeter_main "$@"
--
2.51.0
next prev parent reply other threads:[~2025-10-02 4:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-02 4:50 [PATCH v2 0/6] Test and linter fixups David Gibson
2025-10-02 4:50 ` David Gibson [this message]
2025-10-02 4:50 ` [PATCH v2 2/6] clang-tidy: Suppress redundant expression warning David Gibson
2025-10-02 4:50 ` [PATCH v2 3/6] cppcheck: Suppress the suppression of a suppression David Gibson
2025-10-02 4:50 ` [PATCH v2 4/6] cppcheck: Suppress a buggy cppcheck warning David Gibson
2025-10-02 4:50 ` [PATCH v2 5/6] cppcheck: Suppress variable scope warnings in dhcpv6() David Gibson
2025-10-02 4:50 ` [PATCH v2 6/6] test: Don't delete exetool on make clean David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251002045012.4047974-2-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).