[PATCH v3 0/6] Test and linter fixups
Before starting to convert testcases to use tunbridge, I wanted to add linting for the Python test scripts. While doing that I discovered a new crop of cppcheck and clang-tidy false positives, and a Makefile bug. Here's a batch of fixes. I didn't manage to get through the whole testsuite with this. I keep getting hangs on rampstream_out, which I *think* are unrelated. v3: * Delete mypy's cache on make clean v2: * Actually understood why exetool was being deleted, and fixed it properly. David Gibson (6): clang-tidy: Suppress redundant expression warning cppcheck: Suppress the suppression of a suppression cppcheck: Suppress a buggy cppcheck warning cppcheck: Suppress variable scope warnings in dhcpv6() test: Don't delete exetool on make clean test: Add linting of Python test scripts dhcpv6.c | 8 ++++++++ linux_dep.h | 2 +- tcp.c | 5 +++++ test/Makefile | 20 ++++++++++++++++---- test/build/build.py | 5 +++-- test/build/static_checkers.sh | 6 +++++- vhost_user.c | 1 + 7 files changed, 39 insertions(+), 8 deletions(-) -- 2.51.0
Another cppcheck package in Fedora, another bogus false positive. This
one seems to not realise that a variable has been initialised by
getsockopt() under a complicated set of circumstances.
Signed-off-by: David Gibson
exetool is listed in $(LOCAL_ASSETS), which seems like it makes sense,
until you realise that $(LOCAL_ASSETS) are deleted on make clean, and we
can't rebuild exetool after deleting it (since it's just part of the
exeter tree we download). Move it to $(DOWNLOAD_ASSETS) instead.
Signed-off-by: David Gibson
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
clang-tidy 20.1.8 doesn't like (VHOST_USER_MAX_VQS / 2), because it expands
to (2 / 2). But in the context of the #define, this makes logical sense,
so suppress the warning.
I'm not sure why it isn't firing on the debug() line just below. Possibly
it only complains once per expression per function, so we only have to
suppress it once?
Signed-off-by: David Gibson
On Thu, 2 Oct 2025 15:04:32 +1000
David Gibson
clang-tidy 20.1.8 doesn't like (VHOST_USER_MAX_VQS / 2), because it expands to (2 / 2). But in the context of the #define, this makes logical sense, so suppress the warning.
I'm not sure why it isn't firing on the debug() line just below. Possibly it only complains once per expression per function, so we only have to suppress it once?
I have the feeling it's not really "exploring" debug() calls, rather, but I didn't really investigate. Whatever, it doesn't really matter.
Signed-off-by: David Gibson
--- vhost_user.c | 1 + 1 file changed, 1 insertion(+) diff --git a/vhost_user.c b/vhost_user.c index fa343a86..223332d5 100644 --- a/vhost_user.c +++ b/vhost_user.c @@ -939,6 +939,7 @@ static bool vu_get_queue_num_exec(struct vu_dev *vdev, { (void)vdev;
+ /* NOLINTNEXTLINE(misc-redundant-expression) */ vmsg_set_reply_u64(vmsg, VHOST_USER_MAX_VQS / 2);
debug("VHOST_USER_MAX_VQS %u", VHOST_USER_MAX_VQS / 2);
-- Stefano
On Thu, 2 Oct 2025 15:04:31 +1000
David Gibson
Before starting to convert testcases to use tunbridge, I wanted to add linting for the Python test scripts. While doing that I discovered a new crop of cppcheck and clang-tidy false positives, and a Makefile bug.
Here's a batch of fixes.
I didn't manage to get through the whole testsuite with this. I keep getting hangs on rampstream_out, which I *think* are unrelated.
I saw this once too, a couple of weeks ago. Maybe it's the same issue I've been trying to find the time to work on for a while now, that is, the kernel not freezing queues of the sockets from the source instance once they switch to repair mode. But it happened just once so I didn't try re-running with PCAP=1. I might, if it happens again.
v3: * Delete mypy's cache on make clean v2: * Actually understood why exetool was being deleted, and fixed it properly.
David Gibson (6): clang-tidy: Suppress redundant expression warning cppcheck: Suppress the suppression of a suppression cppcheck: Suppress a buggy cppcheck warning cppcheck: Suppress variable scope warnings in dhcpv6() test: Don't delete exetool on make clean test: Add linting of Python test scripts
I'm applying this now, even though, strictly speaking, this breaks tests because test/README.md doesn't mention one needs to install flake8 and mypy, and I don't think they're very commonly installed, so I think you should update it. -- Stefano
On Tue, Oct 07, 2025 at 04:13:46PM +0200, Stefano Brivio wrote:
On Thu, 2 Oct 2025 15:04:31 +1000 David Gibson
wrote: Before starting to convert testcases to use tunbridge, I wanted to add linting for the Python test scripts. While doing that I discovered a new crop of cppcheck and clang-tidy false positives, and a Makefile bug.
Here's a batch of fixes.
I didn't manage to get through the whole testsuite with this. I keep getting hangs on rampstream_out, which I *think* are unrelated.
I saw this once too, a couple of weeks ago.
Maybe it's the same issue I've been trying to find the time to work on for a while now, that is, the kernel not freezing queues of the sockets from the source instance once they switch to repair mode.
Maybe.
But it happened just once so I didn't try re-running with PCAP=1. I might, if it happens again.
v3: * Delete mypy's cache on make clean v2: * Actually understood why exetool was being deleted, and fixed it properly.
David Gibson (6): clang-tidy: Suppress redundant expression warning cppcheck: Suppress the suppression of a suppression cppcheck: Suppress a buggy cppcheck warning cppcheck: Suppress variable scope warnings in dhcpv6() test: Don't delete exetool on make clean test: Add linting of Python test scripts
I'm applying this now, even though, strictly speaking, this breaks tests because test/README.md doesn't mention one needs to install flake8 and mypy, and I don't think they're very commonly installed, so I think you should update it.
Ah, good point. Beter yet, I should skip rather than failing if the linters aren't available. I'll send a follow up for this. -- 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