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
This commit is contained in:
@@ -12,7 +12,31 @@
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user