Date: Wed, 05 Aug 2026 02:21:59 +0000 From: Alan Somers <asomers@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: c3be3a784c2b - stable/14 - ping: fix listing test cases when scapy is not installed Message-ID: <6a729e47.3bfa5.7d0e6651@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/14 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=c3be3a784c2b16b18ac8322dbf7863587f278bb9 commit c3be3a784c2b16b18ac8322dbf7863587f278bb9 Author: Alan Somers <asomers@FreeBSD.org> AuthorDate: 2026-05-01 23:06:35 +0000 Commit: Alan Somers <asomers@FreeBSD.org> CommitDate: 2026-08-05 02:18:14 +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 Reviewed by: maxim Differential Revision: https://reviews.freebsd.org/D56765 (cherry picked from commit 3e845b1090565912375c5578cf0399d27b7fa70c) --- 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 60ddd3d751bf..88164c2ab816 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?6a729e47.3bfa5.7d0e6651>
