Date: Sat, 02 May 2026 15:20:41 +0000 From: Alan Somers <asomers@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 3e845b109056 - main - ping: fix listing test cases when scapy is not installed Message-ID: <69f61649.1c022.73b2a773@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=3e845b1090565912375c5578cf0399d27b7fa70c commit 3e845b1090565912375c5578cf0399d27b7fa70c Author: Alan Somers <asomers@FreeBSD.org> AuthorDate: 2026-05-01 23:06:35 +0000 Commit: Alan Somers <asomers@FreeBSD.org> CommitDate: 2026-05-02 15:20:16 +0000 ping: fix listing test cases when scapy is not installed The ATF-python test program was attempting to list test cases that require scapy. But it attempted to import the scapy module before the test cases had been listed, resulting in an ImportError that kyua interpreted as a test program crash. Fix this behavior by handling that ImportError well enough to list test cases, but not run them. If scapy isn't present, Kyua will refuse to run the test cases. But it needs to be able to list them in order to know to skip them. Sponsored by: ConnectWise MFC after: 2 weeks Reviewed by: maxim Differential Revision: https://reviews.freebsd.org/D56765 --- sbin/ping/tests/test_ping.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/sbin/ping/tests/test_ping.py b/sbin/ping/tests/test_ping.py index 3f9a3aecf924..fdf9c875329c 100644 --- a/sbin/ping/tests/test_ping.py +++ b/sbin/ping/tests/test_ping.py @@ -12,7 +12,31 @@ from typing import List from typing import Optional logging.getLogger("scapy").setLevel(logging.CRITICAL) -import scapy.all as sc +try: + import scapy.all as sc +except ImportError as e: + # Fake scapy well enough to be able to list test cases + from types import SimpleNamespace + sc = SimpleNamespace( + scapy=SimpleNamespace( + fields=SimpleNamespace( + SourceIPField=0, + ByteEnumField=0, + MultiEnumField=0, + BitField=0, + FlagsField=0, + ByteField=0, + IPField=0, + ShortField=0, + ), + layers=SimpleNamespace( + inet=SimpleNamespace( + DestIPField=0, + ICMPTimeStampField=0, + ) + ) + ) + ) def build_response_packet(echo, ip, icmp, oip_ihl, special):home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69f61649.1c022.73b2a773>
