xref: /freebsd/sbin/ping/tests/test_ping.py (revision 5797a03fe8a7c3355a727aaaea803ee1f42d106b)
15b8af90fSJose Luis Duranimport pytest
25b8af90fSJose Luis Duran
35b8af90fSJose Luis Duranimport logging
45b8af90fSJose Luis Duranimport os
55b8af90fSJose Luis Duranimport re
65b8af90fSJose Luis Duranimport subprocess
75b8af90fSJose Luis Duran
85b8af90fSJose Luis Duranfrom atf_python.sys.net.vnet import IfaceFactory
95b8af90fSJose Luis Duranfrom atf_python.sys.net.vnet import SingleVnetTestTemplate
105b8af90fSJose Luis Duranfrom atf_python.sys.net.tools import ToolsHelper
115b8af90fSJose Luis Duranfrom typing import List
125b8af90fSJose Luis Duranfrom typing import Optional
135b8af90fSJose Luis Duran
145b8af90fSJose Luis Duranlogging.getLogger("scapy").setLevel(logging.CRITICAL)
155b8af90fSJose Luis Duranimport scapy.all as sc
165b8af90fSJose Luis Duran
175b8af90fSJose Luis Duran
185b8af90fSJose Luis Durandef build_response_packet(echo, ip, icmp, oip_ihl, special):
195b8af90fSJose Luis Duran    icmp_id_seq_types = [0, 8, 13, 14, 15, 16, 17, 18, 37, 38]
205b8af90fSJose Luis Duran    oip = echo[sc.IP]
215b8af90fSJose Luis Duran    oicmp = echo[sc.ICMP]
225b8af90fSJose Luis Duran    load = echo[sc.ICMP].payload
235b8af90fSJose Luis Duran    oip[sc.IP].remove_payload()
245b8af90fSJose Luis Duran    oicmp[sc.ICMP].remove_payload()
255b8af90fSJose Luis Duran    oicmp.type = 8
265b8af90fSJose Luis Duran
275b8af90fSJose Luis Duran    # As if the original IP packet had these set
285b8af90fSJose Luis Duran    oip.ihl = None
295b8af90fSJose Luis Duran    oip.len = None
305b8af90fSJose Luis Duran    oip.id = 1
315b8af90fSJose Luis Duran    oip.flags = ip.flags
325b8af90fSJose Luis Duran    oip.chksum = None
335b8af90fSJose Luis Duran    oip.options = ip.options
345b8af90fSJose Luis Duran
355b8af90fSJose Luis Duran    # Inner packet (oip) options
365b8af90fSJose Luis Duran    if oip_ihl:
375b8af90fSJose Luis Duran        oip.ihl = oip_ihl
385b8af90fSJose Luis Duran
395b8af90fSJose Luis Duran    # Special options
405b8af90fSJose Luis Duran    if special == "no-payload":
415b8af90fSJose Luis Duran        load = ""
425b8af90fSJose Luis Duran    if special == "tcp":
435b8af90fSJose Luis Duran        oip.proto = "tcp"
445b8af90fSJose Luis Duran        tcp = sc.TCP(sport=1234, dport=5678)
455b8af90fSJose Luis Duran        return ip / icmp / oip / tcp
465b8af90fSJose Luis Duran    if special == "udp":
475b8af90fSJose Luis Duran        oip.proto = "udp"
485b8af90fSJose Luis Duran        udp = sc.UDP(sport=1234, dport=5678)
495b8af90fSJose Luis Duran        return ip / icmp / oip / udp
505b8af90fSJose Luis Duran    if special == "warp":
515b8af90fSJose Luis Duran        # Build a package with a timestamp of INT_MAX
525b8af90fSJose Luis Duran        # (time-warped package)
535b8af90fSJose Luis Duran        payload_no_timestamp = sc.bytes_hex(load)[16:]
5424fe0cb8SJose Luis Duran        load = b"\x7f" + (b"\xff" * 7) + sc.hex_bytes(payload_no_timestamp)
555b8af90fSJose Luis Duran    if special == "wrong":
565b8af90fSJose Luis Duran        # Build a package with a wrong last byte
575b8af90fSJose Luis Duran        payload_no_last_byte = sc.bytes_hex(load)[:-2]
585b8af90fSJose Luis Duran        load = (sc.hex_bytes(payload_no_last_byte)) + b"\x00"
599fc2d858SJose Luis Duran    if special == "not-mine":
609fc2d858SJose Luis Duran        # Modify the ICMP Identifier field
619fc2d858SJose Luis Duran        oicmp.id += 1
625b8af90fSJose Luis Duran
635b8af90fSJose Luis Duran    if icmp.type in icmp_id_seq_types:
645b8af90fSJose Luis Duran        pkt = ip / icmp / load
655b8af90fSJose Luis Duran    else:
664859030eSJose Luis Duran        del ip.options
675b8af90fSJose Luis Duran        pkt = ip / icmp / oip / oicmp / load
685b8af90fSJose Luis Duran    return pkt
695b8af90fSJose Luis Duran
705b8af90fSJose Luis Duran
715b8af90fSJose Luis Durandef generate_ip_options(opts):
725b8af90fSJose Luis Duran    if not opts:
734859030eSJose Luis Duran        return []
745b8af90fSJose Luis Duran
755b8af90fSJose Luis Duran    routers = [
765b8af90fSJose Luis Duran        "192.0.2.10",
775b8af90fSJose Luis Duran        "192.0.2.20",
785b8af90fSJose Luis Duran        "192.0.2.30",
795b8af90fSJose Luis Duran        "192.0.2.40",
805b8af90fSJose Luis Duran        "192.0.2.50",
815b8af90fSJose Luis Duran        "192.0.2.60",
825b8af90fSJose Luis Duran        "192.0.2.70",
835b8af90fSJose Luis Duran        "192.0.2.80",
845b8af90fSJose Luis Duran        "192.0.2.90",
855b8af90fSJose Luis Duran    ]
865b8af90fSJose Luis Duran    routers_zero = [0, 0, 0, 0, 0, 0, 0, 0, 0]
875b8af90fSJose Luis Duran    if opts == "EOL":
882e29bf7aSJose Luis Duran        options = sc.IPOption_EOL()
895b8af90fSJose Luis Duran    elif opts == "NOP":
902e29bf7aSJose Luis Duran        options = sc.IPOption_NOP()
915b8af90fSJose Luis Duran    elif opts == "NOP-40":
922e29bf7aSJose Luis Duran        options = sc.IPOption_NOP() * 40
935b8af90fSJose Luis Duran    elif opts == "RR":
945b8af90fSJose Luis Duran        ToolsHelper.set_sysctl("net.inet.ip.process_options", 0)
955b8af90fSJose Luis Duran        options = sc.IPOption_RR(pointer=40, routers=routers)
965b8af90fSJose Luis Duran    elif opts == "RR-same":
975b8af90fSJose Luis Duran        ToolsHelper.set_sysctl("net.inet.ip.process_options", 0)
985b8af90fSJose Luis Duran        options = sc.IPOption_RR(pointer=3, routers=routers_zero)
995b8af90fSJose Luis Duran    elif opts == "RR-trunc":
1005b8af90fSJose Luis Duran        ToolsHelper.set_sysctl("net.inet.ip.process_options", 0)
1015b8af90fSJose Luis Duran        options = sc.IPOption_RR(length=7, routers=routers_zero)
1025b8af90fSJose Luis Duran    elif opts == "LSRR":
1035b8af90fSJose Luis Duran        ToolsHelper.set_sysctl("net.inet.ip.process_options", 0)
1045b8af90fSJose Luis Duran        options = sc.IPOption_LSRR(routers=routers)
1055b8af90fSJose Luis Duran    elif opts == "LSRR-trunc":
1065b8af90fSJose Luis Duran        ToolsHelper.set_sysctl("net.inet.ip.process_options", 0)
1075b8af90fSJose Luis Duran        options = sc.IPOption_LSRR(length=3, routers=routers_zero)
1085b8af90fSJose Luis Duran    elif opts == "SSRR":
1095b8af90fSJose Luis Duran        ToolsHelper.set_sysctl("net.inet.ip.process_options", 0)
1105b8af90fSJose Luis Duran        options = sc.IPOption_SSRR(routers=routers)
1115b8af90fSJose Luis Duran    elif opts == "SSRR-trunc":
1125b8af90fSJose Luis Duran        ToolsHelper.set_sysctl("net.inet.ip.process_options", 0)
1135b8af90fSJose Luis Duran        options = sc.IPOption_SSRR(length=3, routers=routers_zero)
1145b8af90fSJose Luis Duran    elif opts == "unk":
1155b8af90fSJose Luis Duran        ToolsHelper.set_sysctl("net.inet.ip.process_options", 0)
1162926c259SKristof Provost        options = b"\x9f"
1175b8af90fSJose Luis Duran    elif opts == "unk-40":
1185b8af90fSJose Luis Duran        ToolsHelper.set_sysctl("net.inet.ip.process_options", 0)
1192e29bf7aSJose Luis Duran        options = b"\x9f" * 40
1205b8af90fSJose Luis Duran    else:
1214859030eSJose Luis Duran        options = []
1225b8af90fSJose Luis Duran    return options
1235b8af90fSJose Luis Duran
1245b8af90fSJose Luis Duran
1255b8af90fSJose Luis Durandef pinger(
1265b8af90fSJose Luis Duran    # Required arguments
1275b8af90fSJose Luis Duran    # Avoid setting defaults on these arguments,
1285b8af90fSJose Luis Duran    # as we want to set them explicitly in the tests
1295b8af90fSJose Luis Duran    iface: str,
1305b8af90fSJose Luis Duran    /,
1315b8af90fSJose Luis Duran    src: sc.scapy.fields.SourceIPField,
1325b8af90fSJose Luis Duran    dst: sc.scapy.layers.inet.DestIPField,
1335b8af90fSJose Luis Duran    icmp_type: sc.scapy.fields.ByteEnumField,
1345b8af90fSJose Luis Duran    icmp_code: sc.scapy.fields.MultiEnumField,
1355b8af90fSJose Luis Duran    # IP arguments
1365b8af90fSJose Luis Duran    ihl: Optional[sc.scapy.fields.BitField] = None,
1374859030eSJose Luis Duran    flags: Optional[sc.scapy.fields.FlagsField] = 0,
1385b8af90fSJose Luis Duran    opts: Optional[str] = None,
1395b8af90fSJose Luis Duran    oip_ihl: Optional[sc.scapy.fields.BitField] = None,
1405b8af90fSJose Luis Duran    special: Optional[str] = None,
1415b8af90fSJose Luis Duran    # ICMP arguments
1425b8af90fSJose Luis Duran    # Match names with <netinet/ip_icmp.h>
1435b8af90fSJose Luis Duran    icmp_pptr: sc.scapy.fields.ByteField = 0,
1445b8af90fSJose Luis Duran    icmp_gwaddr: sc.scapy.fields.IPField = "0.0.0.0",
1455b8af90fSJose Luis Duran    icmp_nextmtu: sc.scapy.fields.ShortField = 0,
1465b8af90fSJose Luis Duran    icmp_otime: sc.scapy.layers.inet.ICMPTimeStampField = 0,
1475b8af90fSJose Luis Duran    icmp_rtime: sc.scapy.layers.inet.ICMPTimeStampField = 0,
1485b8af90fSJose Luis Duran    icmp_ttime: sc.scapy.layers.inet.ICMPTimeStampField = 0,
1495b8af90fSJose Luis Duran    icmp_mask: sc.scapy.fields.IPField = "0.0.0.0",
1505b8af90fSJose Luis Duran    request: Optional[str] = None,
1515b8af90fSJose Luis Duran    # Miscellaneous arguments
1525b8af90fSJose Luis Duran    count: int = 1,
1535b8af90fSJose Luis Duran    dup: bool = False,
1549fc2d858SJose Luis Duran    verbose: bool = True,
1555b8af90fSJose Luis Duran) -> subprocess.CompletedProcess:
1565b8af90fSJose Luis Duran    """P I N G E R
1575b8af90fSJose Luis Duran
1585b8af90fSJose Luis Duran    Echo reply faker
1595b8af90fSJose Luis Duran
1605b8af90fSJose Luis Duran    :param str iface: Interface to send packet to
1615b8af90fSJose Luis Duran    :keyword src: Source packet IP
1625b8af90fSJose Luis Duran    :type src: class:`scapy.fields.SourceIPField`
1635b8af90fSJose Luis Duran    :keyword dst: Destination packet IP
1645b8af90fSJose Luis Duran    :type dst: class:`scapy.layers.inet.DestIPField`
1655b8af90fSJose Luis Duran    :keyword icmp_type: ICMP type
1665b8af90fSJose Luis Duran    :type icmp_type: class:`scapy.fields.ByteEnumField`
1675b8af90fSJose Luis Duran    :keyword icmp_code: ICMP code
1685b8af90fSJose Luis Duran    :type icmp_code: class:`scapy.fields.MultiEnumField`
1695b8af90fSJose Luis Duran
1705b8af90fSJose Luis Duran    :keyword ihl: Internet Header Length, defaults to None
1715b8af90fSJose Luis Duran    :type ihl: class:`scapy.fields.BitField`, optional
1724859030eSJose Luis Duran    :keyword flags: IP flags - one of `DF`, `MF` or `evil`, defaults to 0
1735b8af90fSJose Luis Duran    :type flags: class:`scapy.fields.FlagsField`, optional
1745b8af90fSJose Luis Duran    :keyword opts: Include IP options - one of `EOL`, `NOP`, `NOP-40`, `unk`,
1755b8af90fSJose Luis Duran        `unk-40`, `RR`, `RR-same`, `RR-trunc`, `LSRR`, `LSRR-trunc`, `SSRR` or
1765b8af90fSJose Luis Duran        `SSRR-trunc`, defaults to None
1775b8af90fSJose Luis Duran    :type opts: str, optional
1785b8af90fSJose Luis Duran    :keyword oip_ihl: Inner packet's Internet Header Length, defaults to None
1795b8af90fSJose Luis Duran    :type oip_ihl: class:`scapy.fields.BitField`, optional
1809fc2d858SJose Luis Duran    :keyword special: Send a special packet - one of `no-payload`, `not-mine`,
1819fc2d858SJose Luis Duran        `tcp`, `udp`, `wrong` or `warp`, defaults to None
1825b8af90fSJose Luis Duran    :type special: str, optional
1835b8af90fSJose Luis Duran    :keyword icmp_pptr: ICMP pointer, defaults to 0
1845b8af90fSJose Luis Duran    :type icmp_pptr: class:`scapy.fields.ByteField`
1855b8af90fSJose Luis Duran    :keyword icmp_gwaddr: ICMP gateway IP address, defaults to "0.0.0.0"
1865b8af90fSJose Luis Duran    :type icmp_gwaddr: class:`scapy.fields.IPField`
1875b8af90fSJose Luis Duran    :keyword icmp_nextmtu: ICMP next MTU, defaults to 0
1885b8af90fSJose Luis Duran    :type icmp_nextmtu: class:`scapy.fields.ShortField`
1895b8af90fSJose Luis Duran    :keyword icmp_otime: ICMP originate timestamp, defaults to 0
1905b8af90fSJose Luis Duran    :type icmp_otime: class:`scapy.layers.inet.ICMPTimeStampField`
1915b8af90fSJose Luis Duran    :keyword icmp_rtime: ICMP receive timestamp, defaults to 0
1925b8af90fSJose Luis Duran    :type icmp_rtime: class:`scapy.layers.inet.ICMPTimeStampField`
1935b8af90fSJose Luis Duran    :keyword icmp_ttime: ICMP transmit timestamp, defaults to 0
1945b8af90fSJose Luis Duran    :type icmp_ttime: class:`scapy.layers.inet.ICMPTimeStampField`
1955b8af90fSJose Luis Duran    :keyword icmp_mask: ICMP address mask, defaults to "0.0.0.0"
1965b8af90fSJose Luis Duran    :type icmp_mask: class:`scapy.fields.IPField`
1975b8af90fSJose Luis Duran    :keyword request: Request type - one of `mask` or `timestamp`,
1985b8af90fSJose Luis Duran        defaults to None
1995b8af90fSJose Luis Duran    :type request: str, optional
2005b8af90fSJose Luis Duran    :keyword count: Number of packets to send, defaults to 1
2015b8af90fSJose Luis Duran    :type count: int
2025b8af90fSJose Luis Duran    :keyword dup: Duplicate packets, defaults to `False`
2035b8af90fSJose Luis Duran    :type dup: bool
2049fc2d858SJose Luis Duran    :keyword verbose: Turn on/off verbosity, defaults to `True`
2059fc2d858SJose Luis Duran    :type verbose: bool
2065b8af90fSJose Luis Duran
2075b8af90fSJose Luis Duran    :return: A class:`subprocess.CompletedProcess` with the output from the
2085b8af90fSJose Luis Duran        ping utility
2095b8af90fSJose Luis Duran    :rtype: class:`subprocess.CompletedProcess`
2105b8af90fSJose Luis Duran    """
2115b8af90fSJose Luis Duran    tun = sc.TunTapInterface(iface)
2125b8af90fSJose Luis Duran    subprocess.run(["ifconfig", tun.iface, "up"], check=True)
2135b8af90fSJose Luis Duran    subprocess.run(["ifconfig", tun.iface, src, dst], check=True)
2145b8af90fSJose Luis Duran    ip_opts = generate_ip_options(opts)
2155b8af90fSJose Luis Duran    ip = sc.IP(ihl=ihl, flags=flags, src=dst, dst=src, options=ip_opts)
2165b8af90fSJose Luis Duran    command = [
2175b8af90fSJose Luis Duran        "/sbin/ping",
2185b8af90fSJose Luis Duran        "-c",
2195b8af90fSJose Luis Duran        str(count),
2205b8af90fSJose Luis Duran        "-t",
2215b8af90fSJose Luis Duran        str(count),
2225b8af90fSJose Luis Duran    ]
2239fc2d858SJose Luis Duran    if verbose:
2249fc2d858SJose Luis Duran        command += ["-v"]
2255b8af90fSJose Luis Duran    if request == "mask":
2265b8af90fSJose Luis Duran        command += ["-Mm"]
2275b8af90fSJose Luis Duran    if request == "timestamp":
2285b8af90fSJose Luis Duran        command += ["-Mt"]
2295b8af90fSJose Luis Duran    if special:
2305b8af90fSJose Luis Duran        command += ["-p1"]
2315b8af90fSJose Luis Duran    if opts in [
2325b8af90fSJose Luis Duran        "RR",
2335b8af90fSJose Luis Duran        "RR-same",
2345b8af90fSJose Luis Duran        "RR-trunc",
2355b8af90fSJose Luis Duran        "LSRR",
2365b8af90fSJose Luis Duran        "LSRR-trunc",
2375b8af90fSJose Luis Duran        "SSRR",
2385b8af90fSJose Luis Duran        "SSRR-trunc",
2395b8af90fSJose Luis Duran    ]:
2405b8af90fSJose Luis Duran        command += ["-R"]
2415b8af90fSJose Luis Duran    command += [dst]
2425b8af90fSJose Luis Duran    with subprocess.Popen(
2435b8af90fSJose Luis Duran        args=command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True
2445b8af90fSJose Luis Duran    ) as ping:
2455b8af90fSJose Luis Duran        for dummy in range(count):
2465b8af90fSJose Luis Duran            echo = tun.recv()
2475b8af90fSJose Luis Duran            icmp = sc.ICMP(
2485b8af90fSJose Luis Duran                type=icmp_type,
2495b8af90fSJose Luis Duran                code=icmp_code,
2505b8af90fSJose Luis Duran                id=echo[sc.ICMP].id,
2515b8af90fSJose Luis Duran                seq=echo[sc.ICMP].seq,
2525b8af90fSJose Luis Duran                ts_ori=icmp_otime,
2535b8af90fSJose Luis Duran                ts_rx=icmp_rtime,
2545b8af90fSJose Luis Duran                ts_tx=icmp_ttime,
2555b8af90fSJose Luis Duran                gw=icmp_gwaddr,
2565b8af90fSJose Luis Duran                ptr=icmp_pptr,
2575b8af90fSJose Luis Duran                addr_mask=icmp_mask,
2585b8af90fSJose Luis Duran                nexthopmtu=icmp_nextmtu,
2595b8af90fSJose Luis Duran            )
2605b8af90fSJose Luis Duran            pkt = build_response_packet(echo, ip, icmp, oip_ihl, special)
2615b8af90fSJose Luis Duran            tun.send(pkt)
2625b8af90fSJose Luis Duran            if dup is True:
2635b8af90fSJose Luis Duran                tun.send(pkt)
2645b8af90fSJose Luis Duran        stdout, stderr = ping.communicate()
2655b8af90fSJose Luis Duran    return subprocess.CompletedProcess(
2665b8af90fSJose Luis Duran        ping.args, ping.returncode, stdout, stderr
2675b8af90fSJose Luis Duran    )
2685b8af90fSJose Luis Duran
2695b8af90fSJose Luis Duran
2705b8af90fSJose Luis Durandef redact(output):
2715b8af90fSJose Luis Duran    """Redact some elements of ping's output"""
2725b8af90fSJose Luis Duran    pattern_replacements = [
2738b13cb9dSJose Luis Duran        (r"localhost \([0-9]{1,3}(\.[0-9]{1,3}){3}\)", "localhost"),
2748b13cb9dSJose Luis Duran        (r"from [0-9]{1,3}(\.[0-9]{1,3}){3}", "from"),
2755b8af90fSJose Luis Duran        ("hlim=[0-9]*", "hlim="),
2765b8af90fSJose Luis Duran        ("ttl=[0-9]*", "ttl="),
2775b8af90fSJose Luis Duran        ("time=[0-9.-]*", "time="),
2788db2c580SJose Luis Duran        ("cp: .*", "cp: xx xx xx xx xx xx xx xx"),
2798db2c580SJose Luis Duran        ("dp: .*", "dp: xx xx xx xx xx xx xx xx"),
2808b13cb9dSJose Luis Duran        (r"\(-[0-9\.]+[0-9]+ ms\)", "(- ms)"),
2818b13cb9dSJose Luis Duran        (r"[0-9\.]+/[0-9.]+", "/"),
2825b8af90fSJose Luis Duran    ]
2835b8af90fSJose Luis Duran    for pattern, repl in pattern_replacements:
2845b8af90fSJose Luis Duran        output = re.sub(pattern, repl, output)
2855b8af90fSJose Luis Duran    return output
2865b8af90fSJose Luis Duran
2875b8af90fSJose Luis Duran
2885b8af90fSJose Luis Duranclass TestPing(SingleVnetTestTemplate):
2895b8af90fSJose Luis Duran    IPV6_PREFIXES: List[str] = ["2001:db8::1/64"]
2905b8af90fSJose Luis Duran    IPV4_PREFIXES: List[str] = ["192.0.2.1/24"]
2915b8af90fSJose Luis Duran
2925b8af90fSJose Luis Duran    # Each param in testdata contains a dictionary with the command,
2935b8af90fSJose Luis Duran    # and the expected outcome (returncode, redacted stdout, and stderr)
2945b8af90fSJose Luis Duran    testdata = [
2955b8af90fSJose Luis Duran        pytest.param(
2965b8af90fSJose Luis Duran            {
2975b8af90fSJose Luis Duran                "args": "ping -4 -c1 -s56 -t1 localhost",
2985b8af90fSJose Luis Duran                "returncode": 0,
2995b8af90fSJose Luis Duran                "stdout": """\
3005b8af90fSJose Luis DuranPING localhost: 56 data bytes
3015b8af90fSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
3025b8af90fSJose Luis Duran
3035b8af90fSJose Luis Duran--- localhost ping statistics ---
3045b8af90fSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
3055b8af90fSJose Luis Duranround-trip min/avg/max/stddev = /// ms
3065b8af90fSJose Luis Duran""",
3075b8af90fSJose Luis Duran                "stderr": "",
3085b8af90fSJose Luis Duran            },
3095b8af90fSJose Luis Duran            id="_4_c1_s56_t1_localhost",
3105b8af90fSJose Luis Duran        ),
3115b8af90fSJose Luis Duran        pytest.param(
3125b8af90fSJose Luis Duran            {
3135b8af90fSJose Luis Duran                "args": "ping -6 -c1 -s8 -t1 localhost",
3145b8af90fSJose Luis Duran                "returncode": 0,
3155b8af90fSJose Luis Duran                "stdout": """\
31603d4d1c7SJose Luis DuranPING(56=40+8+8 bytes) ::1 --> ::1
3175b8af90fSJose Luis Duran16 bytes from ::1, icmp_seq=0 hlim= time= ms
3185b8af90fSJose Luis Duran
31903d4d1c7SJose Luis Duran--- localhost ping statistics ---
3205b8af90fSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
32103d4d1c7SJose Luis Duranround-trip min/avg/max/stddev = /// ms
3225b8af90fSJose Luis Duran""",
3235b8af90fSJose Luis Duran                "stderr": "",
3245b8af90fSJose Luis Duran            },
3255b8af90fSJose Luis Duran            id="_6_c1_s8_t1_localhost",
3265b8af90fSJose Luis Duran        ),
3275b8af90fSJose Luis Duran        pytest.param(
3285b8af90fSJose Luis Duran            {
3295b8af90fSJose Luis Duran                "args": "ping -A -c1 192.0.2.1",
3305b8af90fSJose Luis Duran                "returncode": 0,
3315b8af90fSJose Luis Duran                "stdout": """\
3325b8af90fSJose Luis DuranPING 192.0.2.1 (192.0.2.1): 56 data bytes
3335b8af90fSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
3345b8af90fSJose Luis Duran
3355b8af90fSJose Luis Duran--- 192.0.2.1 ping statistics ---
3365b8af90fSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
3375b8af90fSJose Luis Duranround-trip min/avg/max/stddev = /// ms
3385b8af90fSJose Luis Duran""",
3395b8af90fSJose Luis Duran                "stderr": "",
3405b8af90fSJose Luis Duran            },
3415b8af90fSJose Luis Duran            id="_A_c1_192_0_2_1",
3425b8af90fSJose Luis Duran        ),
3435b8af90fSJose Luis Duran        pytest.param(
3445b8af90fSJose Luis Duran            {
3455b8af90fSJose Luis Duran                "args": "ping -A -c1 192.0.2.2",
3465b8af90fSJose Luis Duran                "returncode": 2,
3475b8af90fSJose Luis Duran                "stdout": """\
3485b8af90fSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
3495b8af90fSJose Luis Duran
3505b8af90fSJose Luis Duran--- 192.0.2.2 ping statistics ---
3515b8af90fSJose Luis Duran1 packets transmitted, 0 packets received, 100.0% packet loss
3525b8af90fSJose Luis Duran""",
3535b8af90fSJose Luis Duran                "stderr": "",
3545b8af90fSJose Luis Duran            },
3555b8af90fSJose Luis Duran            id="_A_c1_192_0_2_2",
3565b8af90fSJose Luis Duran        ),
3575b8af90fSJose Luis Duran        pytest.param(
3585b8af90fSJose Luis Duran            {
3595b8af90fSJose Luis Duran                "args": "ping -A -c1 2001:db8::1",
3605b8af90fSJose Luis Duran                "returncode": 0,
3615b8af90fSJose Luis Duran                "stdout": """\
36203d4d1c7SJose Luis DuranPING(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::1
3635b8af90fSJose Luis Duran16 bytes from 2001:db8::1, icmp_seq=0 hlim= time= ms
3645b8af90fSJose Luis Duran
36503d4d1c7SJose Luis Duran--- 2001:db8::1 ping statistics ---
3665b8af90fSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
36703d4d1c7SJose Luis Duranround-trip min/avg/max/stddev = /// ms
3685b8af90fSJose Luis Duran""",
3695b8af90fSJose Luis Duran                "stderr": "",
3705b8af90fSJose Luis Duran            },
3715b8af90fSJose Luis Duran            id="_A_c1_2001_db8__1",
3725b8af90fSJose Luis Duran        ),
3735b8af90fSJose Luis Duran        pytest.param(
3745b8af90fSJose Luis Duran            {
3755b8af90fSJose Luis Duran                "args": "ping -A -c1 2001:db8::2",
3765b8af90fSJose Luis Duran                "returncode": 2,
3775b8af90fSJose Luis Duran                "stdout": """\
37803d4d1c7SJose Luis DuranPING(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::2
3795b8af90fSJose Luis Duran
38003d4d1c7SJose Luis Duran--- 2001:db8::2 ping statistics ---
3815b8af90fSJose Luis Duran1 packets transmitted, 0 packets received, 100.0% packet loss
3825b8af90fSJose Luis Duran""",
3835b8af90fSJose Luis Duran                "stderr": "",
3845b8af90fSJose Luis Duran            },
3855b8af90fSJose Luis Duran            id="_A_c1_2001_db8__2",
3865b8af90fSJose Luis Duran        ),
3875b8af90fSJose Luis Duran        pytest.param(
3885b8af90fSJose Luis Duran            {
3895b8af90fSJose Luis Duran                "args": "ping -A -c3 192.0.2.1",
3905b8af90fSJose Luis Duran                "returncode": 0,
3915b8af90fSJose Luis Duran                "stdout": """\
3925b8af90fSJose Luis DuranPING 192.0.2.1 (192.0.2.1): 56 data bytes
3935b8af90fSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
3945b8af90fSJose Luis Duran64 bytes from: icmp_seq=1 ttl= time= ms
3955b8af90fSJose Luis Duran64 bytes from: icmp_seq=2 ttl= time= ms
3965b8af90fSJose Luis Duran
3975b8af90fSJose Luis Duran--- 192.0.2.1 ping statistics ---
3985b8af90fSJose Luis Duran3 packets transmitted, 3 packets received, 0.0% packet loss
3995b8af90fSJose Luis Duranround-trip min/avg/max/stddev = /// ms
4005b8af90fSJose Luis Duran""",
4015b8af90fSJose Luis Duran                "stderr": "",
4025b8af90fSJose Luis Duran            },
4035b8af90fSJose Luis Duran            id="_A_3_192_0.2.1",
4045b8af90fSJose Luis Duran        ),
4055b8af90fSJose Luis Duran        pytest.param(
4065b8af90fSJose Luis Duran            {
4075b8af90fSJose Luis Duran                "args": "ping -A -c3 192.0.2.2",
4085b8af90fSJose Luis Duran                "returncode": 2,
4095b8af90fSJose Luis Duran                "stdout": """\
4105b8af90fSJose Luis Duran\x07\x07PING 192.0.2.2 (192.0.2.2): 56 data bytes
4115b8af90fSJose Luis Duran
4125b8af90fSJose Luis Duran--- 192.0.2.2 ping statistics ---
4135b8af90fSJose Luis Duran3 packets transmitted, 0 packets received, 100.0% packet loss
4145b8af90fSJose Luis Duran""",
4155b8af90fSJose Luis Duran                "stderr": "",
4165b8af90fSJose Luis Duran            },
4175b8af90fSJose Luis Duran            id="_A_c3_192_0_2_2",
4185b8af90fSJose Luis Duran        ),
4195b8af90fSJose Luis Duran        pytest.param(
4205b8af90fSJose Luis Duran            {
4215b8af90fSJose Luis Duran                "args": "ping -A -c3 2001:db8::1",
4225b8af90fSJose Luis Duran                "returncode": 0,
4235b8af90fSJose Luis Duran                "stdout": """\
42403d4d1c7SJose Luis DuranPING(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::1
4255b8af90fSJose Luis Duran16 bytes from 2001:db8::1, icmp_seq=0 hlim= time= ms
4265b8af90fSJose Luis Duran16 bytes from 2001:db8::1, icmp_seq=1 hlim= time= ms
4275b8af90fSJose Luis Duran16 bytes from 2001:db8::1, icmp_seq=2 hlim= time= ms
4285b8af90fSJose Luis Duran
42903d4d1c7SJose Luis Duran--- 2001:db8::1 ping statistics ---
4305b8af90fSJose Luis Duran3 packets transmitted, 3 packets received, 0.0% packet loss
43103d4d1c7SJose Luis Duranround-trip min/avg/max/stddev = /// ms
4325b8af90fSJose Luis Duran""",
4335b8af90fSJose Luis Duran                "stderr": "",
4345b8af90fSJose Luis Duran            },
4355b8af90fSJose Luis Duran            id="_A_c3_2001_db8__1",
4365b8af90fSJose Luis Duran        ),
4375b8af90fSJose Luis Duran        pytest.param(
4385b8af90fSJose Luis Duran            {
4395b8af90fSJose Luis Duran                "args": "ping -A -c3 2001:db8::2",
4405b8af90fSJose Luis Duran                "returncode": 2,
4415b8af90fSJose Luis Duran                "stdout": """\
44203d4d1c7SJose Luis Duran\x07\x07PING(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::2
4435b8af90fSJose Luis Duran
44403d4d1c7SJose Luis Duran--- 2001:db8::2 ping statistics ---
4455b8af90fSJose Luis Duran3 packets transmitted, 0 packets received, 100.0% packet loss
4465b8af90fSJose Luis Duran""",
4475b8af90fSJose Luis Duran                "stderr": "",
4485b8af90fSJose Luis Duran            },
4495b8af90fSJose Luis Duran            id="_A_c3_2001_db8__2",
4505b8af90fSJose Luis Duran        ),
4515b8af90fSJose Luis Duran        pytest.param(
4525b8af90fSJose Luis Duran            {
4535b8af90fSJose Luis Duran                "args": "ping -c1 192.0.2.1",
4545b8af90fSJose Luis Duran                "returncode": 0,
4555b8af90fSJose Luis Duran                "stdout": """\
4565b8af90fSJose Luis DuranPING 192.0.2.1 (192.0.2.1): 56 data bytes
4575b8af90fSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
4585b8af90fSJose Luis Duran
4595b8af90fSJose Luis Duran--- 192.0.2.1 ping statistics ---
4605b8af90fSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
4615b8af90fSJose Luis Duranround-trip min/avg/max/stddev = /// ms
4625b8af90fSJose Luis Duran""",
4635b8af90fSJose Luis Duran                "stderr": "",
4645b8af90fSJose Luis Duran            },
4655b8af90fSJose Luis Duran            id="_c1_192_0_2_1",
4665b8af90fSJose Luis Duran        ),
4675b8af90fSJose Luis Duran        pytest.param(
4685b8af90fSJose Luis Duran            {
4695b8af90fSJose Luis Duran                "args": "ping -c1 192.0.2.2",
4705b8af90fSJose Luis Duran                "returncode": 2,
4715b8af90fSJose Luis Duran                "stdout": """\
4725b8af90fSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
4735b8af90fSJose Luis Duran
4745b8af90fSJose Luis Duran--- 192.0.2.2 ping statistics ---
4755b8af90fSJose Luis Duran1 packets transmitted, 0 packets received, 100.0% packet loss
4765b8af90fSJose Luis Duran""",
4775b8af90fSJose Luis Duran                "stderr": "",
4785b8af90fSJose Luis Duran            },
4795b8af90fSJose Luis Duran            id="_c1_192_0_2_2",
4805b8af90fSJose Luis Duran        ),
4815b8af90fSJose Luis Duran        pytest.param(
4825b8af90fSJose Luis Duran            {
4835b8af90fSJose Luis Duran                "args": "ping -c1 2001:db8::1",
4845b8af90fSJose Luis Duran                "returncode": 0,
4855b8af90fSJose Luis Duran                "stdout": """\
48603d4d1c7SJose Luis DuranPING(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::1
4875b8af90fSJose Luis Duran16 bytes from 2001:db8::1, icmp_seq=0 hlim= time= ms
4885b8af90fSJose Luis Duran
48903d4d1c7SJose Luis Duran--- 2001:db8::1 ping statistics ---
4905b8af90fSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
49103d4d1c7SJose Luis Duranround-trip min/avg/max/stddev = /// ms
4925b8af90fSJose Luis Duran""",
4935b8af90fSJose Luis Duran                "stderr": "",
4945b8af90fSJose Luis Duran            },
4955b8af90fSJose Luis Duran            id="_c1_2001_db8__1",
4965b8af90fSJose Luis Duran        ),
4975b8af90fSJose Luis Duran        pytest.param(
4985b8af90fSJose Luis Duran            {
4995b8af90fSJose Luis Duran                "args": "ping -c1 2001:db8::2",
5005b8af90fSJose Luis Duran                "returncode": 2,
5015b8af90fSJose Luis Duran                "stdout": """\
50203d4d1c7SJose Luis DuranPING(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::2
5035b8af90fSJose Luis Duran
50403d4d1c7SJose Luis Duran--- 2001:db8::2 ping statistics ---
5055b8af90fSJose Luis Duran1 packets transmitted, 0 packets received, 100.0% packet loss
5065b8af90fSJose Luis Duran""",
5075b8af90fSJose Luis Duran                "stderr": "",
5085b8af90fSJose Luis Duran            },
5095b8af90fSJose Luis Duran            id="_c1_2001_db8__2",
5105b8af90fSJose Luis Duran        ),
5115b8af90fSJose Luis Duran        pytest.param(
5125b8af90fSJose Luis Duran            {
5135b8af90fSJose Luis Duran                "args": "ping -c1 -S127.0.0.1 -s56 -t1 localhost",
5145b8af90fSJose Luis Duran                "returncode": 0,
5155b8af90fSJose Luis Duran                "stdout": """\
5165b8af90fSJose Luis DuranPING localhost from: 56 data bytes
5175b8af90fSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
5185b8af90fSJose Luis Duran
5195b8af90fSJose Luis Duran--- localhost ping statistics ---
5205b8af90fSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
5215b8af90fSJose Luis Duranround-trip min/avg/max/stddev = /// ms
5225b8af90fSJose Luis Duran""",
5235b8af90fSJose Luis Duran                "stderr": "",
5245b8af90fSJose Luis Duran            },
5255b8af90fSJose Luis Duran            id="_c1_S127_0_0_1_s56_t1_localhost",
5265b8af90fSJose Luis Duran        ),
5275b8af90fSJose Luis Duran        pytest.param(
5285b8af90fSJose Luis Duran            {
5295b8af90fSJose Luis Duran                "args": "ping -c1 -S::1 -s8 -t1 localhost",
5305b8af90fSJose Luis Duran                "returncode": 0,
5315b8af90fSJose Luis Duran                "stdout": """\
53203d4d1c7SJose Luis DuranPING(56=40+8+8 bytes) ::1 --> ::1
5335b8af90fSJose Luis Duran16 bytes from ::1, icmp_seq=0 hlim= time= ms
5345b8af90fSJose Luis Duran
53503d4d1c7SJose Luis Duran--- localhost ping statistics ---
5365b8af90fSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
53703d4d1c7SJose Luis Duranround-trip min/avg/max/stddev = /// ms
5385b8af90fSJose Luis Duran""",
5395b8af90fSJose Luis Duran                "stderr": "",
5405b8af90fSJose Luis Duran            },
5415b8af90fSJose Luis Duran            id="_c1_S__1_s8_t1_localhost",
5425b8af90fSJose Luis Duran        ),
5435b8af90fSJose Luis Duran        pytest.param(
5445b8af90fSJose Luis Duran            {
5455b8af90fSJose Luis Duran                "args": "ping -c3 192.0.2.1",
5465b8af90fSJose Luis Duran                "returncode": 0,
5475b8af90fSJose Luis Duran                "stdout": """\
5485b8af90fSJose Luis DuranPING 192.0.2.1 (192.0.2.1): 56 data bytes
5495b8af90fSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
5505b8af90fSJose Luis Duran64 bytes from: icmp_seq=1 ttl= time= ms
5515b8af90fSJose Luis Duran64 bytes from: icmp_seq=2 ttl= time= ms
5525b8af90fSJose Luis Duran
5535b8af90fSJose Luis Duran--- 192.0.2.1 ping statistics ---
5545b8af90fSJose Luis Duran3 packets transmitted, 3 packets received, 0.0% packet loss
5555b8af90fSJose Luis Duranround-trip min/avg/max/stddev = /// ms
5565b8af90fSJose Luis Duran""",
5575b8af90fSJose Luis Duran                "stderr": "",
5585b8af90fSJose Luis Duran            },
5595b8af90fSJose Luis Duran            id="_c3_192_0_2_1",
5605b8af90fSJose Luis Duran        ),
5615b8af90fSJose Luis Duran        pytest.param(
5625b8af90fSJose Luis Duran            {
5635b8af90fSJose Luis Duran                "args": "ping -c3 192.0.2.2",
5645b8af90fSJose Luis Duran                "returncode": 2,
5655b8af90fSJose Luis Duran                "stdout": """\
5665b8af90fSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
5675b8af90fSJose Luis Duran
5685b8af90fSJose Luis Duran--- 192.0.2.2 ping statistics ---
5695b8af90fSJose Luis Duran3 packets transmitted, 0 packets received, 100.0% packet loss
5705b8af90fSJose Luis Duran""",
5715b8af90fSJose Luis Duran                "stderr": "",
5725b8af90fSJose Luis Duran            },
5735b8af90fSJose Luis Duran            id="_c3_192_0_2_2",
5745b8af90fSJose Luis Duran        ),
5755b8af90fSJose Luis Duran        pytest.param(
5765b8af90fSJose Luis Duran            {
5775b8af90fSJose Luis Duran                "args": "ping -c3 2001:db8::1",
5785b8af90fSJose Luis Duran                "returncode": 0,
5795b8af90fSJose Luis Duran                "stdout": """\
58003d4d1c7SJose Luis DuranPING(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::1
5815b8af90fSJose Luis Duran16 bytes from 2001:db8::1, icmp_seq=0 hlim= time= ms
5825b8af90fSJose Luis Duran16 bytes from 2001:db8::1, icmp_seq=1 hlim= time= ms
5835b8af90fSJose Luis Duran16 bytes from 2001:db8::1, icmp_seq=2 hlim= time= ms
5845b8af90fSJose Luis Duran
58503d4d1c7SJose Luis Duran--- 2001:db8::1 ping statistics ---
5865b8af90fSJose Luis Duran3 packets transmitted, 3 packets received, 0.0% packet loss
58703d4d1c7SJose Luis Duranround-trip min/avg/max/stddev = /// ms
5885b8af90fSJose Luis Duran""",
5895b8af90fSJose Luis Duran                "stderr": "",
5905b8af90fSJose Luis Duran            },
5915b8af90fSJose Luis Duran            id="_c3_2001_db8__1",
5925b8af90fSJose Luis Duran        ),
5935b8af90fSJose Luis Duran        pytest.param(
5945b8af90fSJose Luis Duran            {
5955b8af90fSJose Luis Duran                "args": "ping -c3 2001:db8::2",
5965b8af90fSJose Luis Duran                "returncode": 2,
5975b8af90fSJose Luis Duran                "stdout": """\
59803d4d1c7SJose Luis DuranPING(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::2
5995b8af90fSJose Luis Duran
60003d4d1c7SJose Luis Duran--- 2001:db8::2 ping statistics ---
6015b8af90fSJose Luis Duran3 packets transmitted, 0 packets received, 100.0% packet loss
6025b8af90fSJose Luis Duran""",
6035b8af90fSJose Luis Duran                "stderr": "",
6045b8af90fSJose Luis Duran            },
6055b8af90fSJose Luis Duran            id="_c3_2001_db8__2",
6065b8af90fSJose Luis Duran        ),
6075b8af90fSJose Luis Duran        pytest.param(
6085b8af90fSJose Luis Duran            {
6095b8af90fSJose Luis Duran                "args": "ping -q -c1 192.0.2.1",
6105b8af90fSJose Luis Duran                "returncode": 0,
6115b8af90fSJose Luis Duran                "stdout": """\
6125b8af90fSJose Luis DuranPING 192.0.2.1 (192.0.2.1): 56 data bytes
6135b8af90fSJose Luis Duran
6145b8af90fSJose Luis Duran--- 192.0.2.1 ping statistics ---
6155b8af90fSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
6165b8af90fSJose Luis Duranround-trip min/avg/max/stddev = /// ms
6175b8af90fSJose Luis Duran""",
6185b8af90fSJose Luis Duran                "stderr": "",
6195b8af90fSJose Luis Duran            },
6205b8af90fSJose Luis Duran            id="_q_c1_192_0_2_1",
6215b8af90fSJose Luis Duran        ),
6225b8af90fSJose Luis Duran        pytest.param(
6235b8af90fSJose Luis Duran            {
6245b8af90fSJose Luis Duran                "args": "ping -q -c1 192.0.2.2",
6255b8af90fSJose Luis Duran                "returncode": 2,
6265b8af90fSJose Luis Duran                "stdout": """\
6275b8af90fSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
6285b8af90fSJose Luis Duran
6295b8af90fSJose Luis Duran--- 192.0.2.2 ping statistics ---
6305b8af90fSJose Luis Duran1 packets transmitted, 0 packets received, 100.0% packet loss
6315b8af90fSJose Luis Duran""",
6325b8af90fSJose Luis Duran                "stderr": "",
6335b8af90fSJose Luis Duran            },
6345b8af90fSJose Luis Duran            id="_q_c1_192_0_2_2",
6355b8af90fSJose Luis Duran        ),
6365b8af90fSJose Luis Duran        pytest.param(
6375b8af90fSJose Luis Duran            {
6385b8af90fSJose Luis Duran                "args": "ping -q -c1 2001:db8::1",
6395b8af90fSJose Luis Duran                "returncode": 0,
6405b8af90fSJose Luis Duran                "stdout": """\
64103d4d1c7SJose Luis DuranPING(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::1
6425b8af90fSJose Luis Duran
64303d4d1c7SJose Luis Duran--- 2001:db8::1 ping statistics ---
6445b8af90fSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
64503d4d1c7SJose Luis Duranround-trip min/avg/max/stddev = /// ms
6465b8af90fSJose Luis Duran""",
6475b8af90fSJose Luis Duran                "stderr": "",
6485b8af90fSJose Luis Duran            },
6495b8af90fSJose Luis Duran            id="_q_c1_2001_db8__1",
6505b8af90fSJose Luis Duran        ),
6515b8af90fSJose Luis Duran        pytest.param(
6525b8af90fSJose Luis Duran            {
6535b8af90fSJose Luis Duran                "args": "ping -q -c1 2001:db8::2",
6545b8af90fSJose Luis Duran                "returncode": 2,
6555b8af90fSJose Luis Duran                "stdout": """\
65603d4d1c7SJose Luis DuranPING(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::2
6575b8af90fSJose Luis Duran
65803d4d1c7SJose Luis Duran--- 2001:db8::2 ping statistics ---
6595b8af90fSJose Luis Duran1 packets transmitted, 0 packets received, 100.0% packet loss
6605b8af90fSJose Luis Duran""",
6615b8af90fSJose Luis Duran                "stderr": "",
6625b8af90fSJose Luis Duran            },
6635b8af90fSJose Luis Duran            id="_q_c1_2001_db8__2",
6645b8af90fSJose Luis Duran        ),
6655b8af90fSJose Luis Duran        pytest.param(
6665b8af90fSJose Luis Duran            {
6675b8af90fSJose Luis Duran                "args": "ping -q -c3 192.0.2.1",
6685b8af90fSJose Luis Duran                "returncode": 0,
6695b8af90fSJose Luis Duran                "stdout": """\
6705b8af90fSJose Luis DuranPING 192.0.2.1 (192.0.2.1): 56 data bytes
6715b8af90fSJose Luis Duran
6725b8af90fSJose Luis Duran--- 192.0.2.1 ping statistics ---
6735b8af90fSJose Luis Duran3 packets transmitted, 3 packets received, 0.0% packet loss
6745b8af90fSJose Luis Duranround-trip min/avg/max/stddev = /// ms
6755b8af90fSJose Luis Duran""",
6765b8af90fSJose Luis Duran                "stderr": "",
6775b8af90fSJose Luis Duran            },
6785b8af90fSJose Luis Duran            id="_q_c3_192_0_2_1",
6795b8af90fSJose Luis Duran        ),
6805b8af90fSJose Luis Duran        pytest.param(
6815b8af90fSJose Luis Duran            {
6825b8af90fSJose Luis Duran                "args": "ping -q -c3 192.0.2.2",
6835b8af90fSJose Luis Duran                "returncode": 2,
6845b8af90fSJose Luis Duran                "stdout": """\
6855b8af90fSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
6865b8af90fSJose Luis Duran
6875b8af90fSJose Luis Duran--- 192.0.2.2 ping statistics ---
6885b8af90fSJose Luis Duran3 packets transmitted, 0 packets received, 100.0% packet loss
6895b8af90fSJose Luis Duran""",
6905b8af90fSJose Luis Duran                "stderr": "",
6915b8af90fSJose Luis Duran            },
6925b8af90fSJose Luis Duran            id="_q_c3_192_0_2_2",
6935b8af90fSJose Luis Duran        ),
6945b8af90fSJose Luis Duran        pytest.param(
6955b8af90fSJose Luis Duran            {
6965b8af90fSJose Luis Duran                "args": "ping -q -c3 2001:db8::1",
6975b8af90fSJose Luis Duran                "returncode": 0,
6985b8af90fSJose Luis Duran                "stdout": """\
69903d4d1c7SJose Luis DuranPING(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::1
7005b8af90fSJose Luis Duran
70103d4d1c7SJose Luis Duran--- 2001:db8::1 ping statistics ---
7025b8af90fSJose Luis Duran3 packets transmitted, 3 packets received, 0.0% packet loss
70303d4d1c7SJose Luis Duranround-trip min/avg/max/stddev = /// ms
7045b8af90fSJose Luis Duran""",
7055b8af90fSJose Luis Duran                "stderr": "",
7065b8af90fSJose Luis Duran            },
7075b8af90fSJose Luis Duran            id="_q_c3_2001_db8__1",
7085b8af90fSJose Luis Duran        ),
7095b8af90fSJose Luis Duran        pytest.param(
7105b8af90fSJose Luis Duran            {
7115b8af90fSJose Luis Duran                "args": "ping -q -c3 2001:db8::2",
7125b8af90fSJose Luis Duran                "returncode": 2,
7135b8af90fSJose Luis Duran                "stdout": """\
71403d4d1c7SJose Luis DuranPING(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::2
7155b8af90fSJose Luis Duran
71603d4d1c7SJose Luis Duran--- 2001:db8::2 ping statistics ---
7175b8af90fSJose Luis Duran3 packets transmitted, 0 packets received, 100.0% packet loss
7185b8af90fSJose Luis Duran""",
7195b8af90fSJose Luis Duran                "stderr": "",
7205b8af90fSJose Luis Duran            },
7215b8af90fSJose Luis Duran            id="_q_c3_2001_db8__2",
7225b8af90fSJose Luis Duran        ),
7235b8af90fSJose Luis Duran    ]
7245b8af90fSJose Luis Duran
7255b8af90fSJose Luis Duran    @pytest.mark.parametrize("expected", testdata)
7264efaf43cSJose Luis Duran    @pytest.mark.require_user("root")
727*5797a03fSJose Luis Duran    @pytest.mark.require_user("unprivileged")
7285b8af90fSJose Luis Duran    def test_ping(self, expected):
7295b8af90fSJose Luis Duran        """Test ping"""
7305b8af90fSJose Luis Duran        ping = subprocess.run(
7315b8af90fSJose Luis Duran            expected["args"].split(),
7325b8af90fSJose Luis Duran            capture_output=True,
7335b8af90fSJose Luis Duran            timeout=15,
7345b8af90fSJose Luis Duran            text=True,
7355b8af90fSJose Luis Duran        )
7365b8af90fSJose Luis Duran        assert ping.returncode == expected["returncode"]
7375b8af90fSJose Luis Duran        assert redact(ping.stdout) == expected["stdout"]
7385b8af90fSJose Luis Duran        assert ping.stderr == expected["stderr"]
7395b8af90fSJose Luis Duran
7405b8af90fSJose Luis Duran    # Each param in ping46_testdata contains a dictionary with the arguments
7415b8af90fSJose Luis Duran    # and the expected outcome (returncode, redacted stdout, and stderr)
7425b8af90fSJose Luis Duran    # common to `ping -4` and `ping -6`
7435b8af90fSJose Luis Duran    ping46_testdata = [
7445b8af90fSJose Luis Duran        pytest.param(
7455b8af90fSJose Luis Duran            {
7465b8af90fSJose Luis Duran                "args": "-Wx localhost",
7475b8af90fSJose Luis Duran                "returncode": os.EX_USAGE,
7485b8af90fSJose Luis Duran                "stdout": "",
7495b8af90fSJose Luis Duran                "stderr": "ping: invalid timing interval: `x'\n",
7505b8af90fSJose Luis Duran            },
7515b8af90fSJose Luis Duran            id="_Wx_localhost",
7525b8af90fSJose Luis Duran        ),
7535b8af90fSJose Luis Duran    ]
7545b8af90fSJose Luis Duran
7555b8af90fSJose Luis Duran    @pytest.mark.parametrize("expected", ping46_testdata)
7564efaf43cSJose Luis Duran    @pytest.mark.require_user("root")
757*5797a03fSJose Luis Duran    @pytest.mark.require_user("unprivileged")
7585b8af90fSJose Luis Duran    def test_ping_46(self, expected):
7595b8af90fSJose Luis Duran        """Test ping -4/ping -6"""
7605b8af90fSJose Luis Duran        for version in [4, 6]:
7615b8af90fSJose Luis Duran            ping = subprocess.run(
7625b8af90fSJose Luis Duran                ["ping", f"-{version}"] + expected["args"].split(),
7635b8af90fSJose Luis Duran                capture_output=True,
7645b8af90fSJose Luis Duran                timeout=15,
7655b8af90fSJose Luis Duran                text=True,
7665b8af90fSJose Luis Duran            )
7675b8af90fSJose Luis Duran            assert ping.returncode == expected["returncode"]
7685b8af90fSJose Luis Duran            assert redact(ping.stdout) == expected["stdout"]
7695b8af90fSJose Luis Duran            assert ping.stderr == expected["stderr"]
7705b8af90fSJose Luis Duran
7715b8af90fSJose Luis Duran    # Each param in pinger_testdata contains a dictionary with the keywords to
7725b8af90fSJose Luis Duran    # `pinger()` and a dictionary with the expected outcome (returncode,
7735b8af90fSJose Luis Duran    # stdout, stderr, and if ping's output is redacted)
7745b8af90fSJose Luis Duran    pinger_testdata = [
7755b8af90fSJose Luis Duran        pytest.param(
7765b8af90fSJose Luis Duran            {
7775b8af90fSJose Luis Duran                "src": "192.0.2.1",
7785b8af90fSJose Luis Duran                "dst": "192.0.2.2",
7795b8af90fSJose Luis Duran                "icmp_type": 0,
7805b8af90fSJose Luis Duran                "icmp_code": 0,
7815b8af90fSJose Luis Duran            },
7825b8af90fSJose Luis Duran            {
7835b8af90fSJose Luis Duran                "returncode": 0,
7845b8af90fSJose Luis Duran                "stdout": """\
7855b8af90fSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
7865b8af90fSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
7875b8af90fSJose Luis Duran
7885b8af90fSJose Luis Duran--- 192.0.2.2 ping statistics ---
7895b8af90fSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
7905b8af90fSJose Luis Duranround-trip min/avg/max/stddev = /// ms
7915b8af90fSJose Luis Duran""",
7925b8af90fSJose Luis Duran                "stderr": "",
7935b8af90fSJose Luis Duran                "redacted": True,
7945b8af90fSJose Luis Duran            },
7955b8af90fSJose Luis Duran            id="_0_0",
7965b8af90fSJose Luis Duran        ),
7975b8af90fSJose Luis Duran        pytest.param(
7985b8af90fSJose Luis Duran            {
7995b8af90fSJose Luis Duran                "src": "192.0.2.1",
8005b8af90fSJose Luis Duran                "dst": "192.0.2.2",
8015b8af90fSJose Luis Duran                "icmp_type": 0,
8025b8af90fSJose Luis Duran                "icmp_code": 0,
803076b718dSJose Luis Duran                "opts": "EOL",
804076b718dSJose Luis Duran            },
805076b718dSJose Luis Duran            {
806076b718dSJose Luis Duran                "returncode": 0,
807076b718dSJose Luis Duran                "stdout": """\
808076b718dSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
809076b718dSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
810076b718dSJose Luis Duranwrong total length 88 instead of 84
811076b718dSJose Luis Duran
812076b718dSJose Luis Duran--- 192.0.2.2 ping statistics ---
813076b718dSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
814076b718dSJose Luis Duranround-trip min/avg/max/stddev = /// ms
815076b718dSJose Luis Duran""",
816076b718dSJose Luis Duran                "stderr": "",
817076b718dSJose Luis Duran                "redacted": True,
818076b718dSJose Luis Duran            },
819076b718dSJose Luis Duran            id="_0_0_opts_EOL",
820076b718dSJose Luis Duran        ),
821076b718dSJose Luis Duran        pytest.param(
822076b718dSJose Luis Duran            {
823076b718dSJose Luis Duran                "src": "192.0.2.1",
824076b718dSJose Luis Duran                "dst": "192.0.2.2",
825076b718dSJose Luis Duran                "icmp_type": 0,
826076b718dSJose Luis Duran                "icmp_code": 0,
827076b718dSJose Luis Duran                "opts": "LSRR",
828076b718dSJose Luis Duran            },
829076b718dSJose Luis Duran            {
830076b718dSJose Luis Duran                "returncode": 0,
831076b718dSJose Luis Duran                "stdout": """\
832076b718dSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
833076b718dSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
834076b718dSJose Luis DuranLSRR: 	192.0.2.10
835076b718dSJose Luis Duran	192.0.2.20
836076b718dSJose Luis Duran	192.0.2.30
837076b718dSJose Luis Duran	192.0.2.40
838076b718dSJose Luis Duran	192.0.2.50
839076b718dSJose Luis Duran	192.0.2.60
840076b718dSJose Luis Duran	192.0.2.70
841076b718dSJose Luis Duran	192.0.2.80
842076b718dSJose Luis Duran	192.0.2.90
843076b718dSJose Luis Duran
844076b718dSJose Luis Duran--- 192.0.2.2 ping statistics ---
845076b718dSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
846076b718dSJose Luis Duranround-trip min/avg/max/stddev = /// ms
847076b718dSJose Luis Duran""",
848076b718dSJose Luis Duran                "stderr": "",
849076b718dSJose Luis Duran                "redacted": True,
850076b718dSJose Luis Duran            },
851076b718dSJose Luis Duran            id="_0_0_opts_LSRR",
852076b718dSJose Luis Duran        ),
853076b718dSJose Luis Duran        pytest.param(
854076b718dSJose Luis Duran            {
855076b718dSJose Luis Duran                "src": "192.0.2.1",
856076b718dSJose Luis Duran                "dst": "192.0.2.2",
857076b718dSJose Luis Duran                "icmp_type": 0,
858076b718dSJose Luis Duran                "icmp_code": 0,
859076b718dSJose Luis Duran                "opts": "LSRR-trunc",
860076b718dSJose Luis Duran            },
861076b718dSJose Luis Duran            {
862076b718dSJose Luis Duran                "returncode": 0,
863076b718dSJose Luis Duran                "stdout": """\
864076b718dSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
865076b718dSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
866076b718dSJose Luis DuranLSRR: 	(truncated route)
867076b718dSJose Luis Duran
868076b718dSJose Luis Duran--- 192.0.2.2 ping statistics ---
869076b718dSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
870076b718dSJose Luis Duranround-trip min/avg/max/stddev = /// ms
871076b718dSJose Luis Duran""",
872076b718dSJose Luis Duran                "stderr": "",
873076b718dSJose Luis Duran                "redacted": True,
874076b718dSJose Luis Duran            },
875076b718dSJose Luis Duran            id="_0_0_opts_LSRR_trunc",
876076b718dSJose Luis Duran        ),
877076b718dSJose Luis Duran        pytest.param(
878076b718dSJose Luis Duran            {
879076b718dSJose Luis Duran                "src": "192.0.2.1",
880076b718dSJose Luis Duran                "dst": "192.0.2.2",
881076b718dSJose Luis Duran                "icmp_type": 0,
882076b718dSJose Luis Duran                "icmp_code": 0,
883076b718dSJose Luis Duran                "opts": "SSRR",
884076b718dSJose Luis Duran            },
885076b718dSJose Luis Duran            {
886076b718dSJose Luis Duran                "returncode": 0,
887076b718dSJose Luis Duran                "stdout": """\
888076b718dSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
889076b718dSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
890076b718dSJose Luis DuranSSRR: 	192.0.2.10
891076b718dSJose Luis Duran	192.0.2.20
892076b718dSJose Luis Duran	192.0.2.30
893076b718dSJose Luis Duran	192.0.2.40
894076b718dSJose Luis Duran	192.0.2.50
895076b718dSJose Luis Duran	192.0.2.60
896076b718dSJose Luis Duran	192.0.2.70
897076b718dSJose Luis Duran	192.0.2.80
898076b718dSJose Luis Duran	192.0.2.90
899076b718dSJose Luis Duran
900076b718dSJose Luis Duran--- 192.0.2.2 ping statistics ---
901076b718dSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
902076b718dSJose Luis Duranround-trip min/avg/max/stddev = /// ms
903076b718dSJose Luis Duran""",
904076b718dSJose Luis Duran                "stderr": "",
905076b718dSJose Luis Duran                "redacted": True,
906076b718dSJose Luis Duran            },
907076b718dSJose Luis Duran            id="_0_0_opts_SSRR",
908076b718dSJose Luis Duran        ),
909076b718dSJose Luis Duran        pytest.param(
910076b718dSJose Luis Duran            {
911076b718dSJose Luis Duran                "src": "192.0.2.1",
912076b718dSJose Luis Duran                "dst": "192.0.2.2",
913076b718dSJose Luis Duran                "icmp_type": 0,
914076b718dSJose Luis Duran                "icmp_code": 0,
915076b718dSJose Luis Duran                "opts": "SSRR-trunc",
916076b718dSJose Luis Duran            },
917076b718dSJose Luis Duran            {
918076b718dSJose Luis Duran                "returncode": 0,
919076b718dSJose Luis Duran                "stdout": """\
920076b718dSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
921076b718dSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
922076b718dSJose Luis DuranSSRR: 	(truncated route)
923076b718dSJose Luis Duran
924076b718dSJose Luis Duran--- 192.0.2.2 ping statistics ---
925076b718dSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
926076b718dSJose Luis Duranround-trip min/avg/max/stddev = /// ms
927076b718dSJose Luis Duran""",
928076b718dSJose Luis Duran                "stderr": "",
929076b718dSJose Luis Duran                "redacted": True,
930076b718dSJose Luis Duran            },
931076b718dSJose Luis Duran            id="_0_0_opts_SSRR_trunc",
932076b718dSJose Luis Duran        ),
933076b718dSJose Luis Duran        pytest.param(
934076b718dSJose Luis Duran            {
935076b718dSJose Luis Duran                "src": "192.0.2.1",
936076b718dSJose Luis Duran                "dst": "192.0.2.2",
937076b718dSJose Luis Duran                "icmp_type": 0,
938076b718dSJose Luis Duran                "icmp_code": 0,
939076b718dSJose Luis Duran                "opts": "RR",
940076b718dSJose Luis Duran            },
941076b718dSJose Luis Duran            {
942076b718dSJose Luis Duran                "returncode": 0,
943076b718dSJose Luis Duran                "stdout": """\
944076b718dSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
945076b718dSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
946076b718dSJose Luis DuranRR: 	192.0.2.10
947076b718dSJose Luis Duran	192.0.2.20
948076b718dSJose Luis Duran	192.0.2.30
949076b718dSJose Luis Duran	192.0.2.40
950076b718dSJose Luis Duran	192.0.2.50
951076b718dSJose Luis Duran	192.0.2.60
952076b718dSJose Luis Duran	192.0.2.70
953076b718dSJose Luis Duran	192.0.2.80
954076b718dSJose Luis Duran	192.0.2.90
955076b718dSJose Luis Duran
956076b718dSJose Luis Duran--- 192.0.2.2 ping statistics ---
957076b718dSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
958076b718dSJose Luis Duranround-trip min/avg/max/stddev = /// ms
959076b718dSJose Luis Duran""",
960076b718dSJose Luis Duran                "stderr": "",
961076b718dSJose Luis Duran                "redacted": True,
962076b718dSJose Luis Duran            },
963076b718dSJose Luis Duran            id="_0_0_opts_RR",
964076b718dSJose Luis Duran        ),
965076b718dSJose Luis Duran        pytest.param(
966076b718dSJose Luis Duran            {
967076b718dSJose Luis Duran                "src": "192.0.2.1",
968076b718dSJose Luis Duran                "dst": "192.0.2.2",
969076b718dSJose Luis Duran                "icmp_type": 0,
970076b718dSJose Luis Duran                "icmp_code": 0,
971076b718dSJose Luis Duran                "opts": "RR-same",
972076b718dSJose Luis Duran            },
973076b718dSJose Luis Duran            {
974076b718dSJose Luis Duran                "returncode": 0,
975076b718dSJose Luis Duran                "stdout": """\
976076b718dSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
977076b718dSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms	(same route)
978076b718dSJose Luis Duran
979076b718dSJose Luis Duran--- 192.0.2.2 ping statistics ---
980076b718dSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
981076b718dSJose Luis Duranround-trip min/avg/max/stddev = /// ms
982076b718dSJose Luis Duran""",
983076b718dSJose Luis Duran                "stderr": "",
984076b718dSJose Luis Duran                "redacted": True,
985076b718dSJose Luis Duran            },
986076b718dSJose Luis Duran            id="_0_0_opts_RR_same",
987076b718dSJose Luis Duran        ),
988076b718dSJose Luis Duran        pytest.param(
989076b718dSJose Luis Duran            {
990076b718dSJose Luis Duran                "src": "192.0.2.1",
991076b718dSJose Luis Duran                "dst": "192.0.2.2",
992076b718dSJose Luis Duran                "icmp_type": 0,
993076b718dSJose Luis Duran                "icmp_code": 0,
994076b718dSJose Luis Duran                "opts": "RR-trunc",
995076b718dSJose Luis Duran            },
996076b718dSJose Luis Duran            {
997076b718dSJose Luis Duran                "returncode": 0,
998076b718dSJose Luis Duran                "stdout": """\
999076b718dSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
1000076b718dSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
1001076b718dSJose Luis DuranRR: 	(truncated route)
1002076b718dSJose Luis Duran
1003076b718dSJose Luis Duran--- 192.0.2.2 ping statistics ---
1004076b718dSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
1005076b718dSJose Luis Duranround-trip min/avg/max/stddev = /// ms
1006076b718dSJose Luis Duran""",
1007076b718dSJose Luis Duran                "stderr": "",
1008076b718dSJose Luis Duran                "redacted": True,
1009076b718dSJose Luis Duran            },
1010076b718dSJose Luis Duran            id="_0_0_opts_RR_trunc",
1011076b718dSJose Luis Duran        ),
1012076b718dSJose Luis Duran        pytest.param(
1013076b718dSJose Luis Duran            {
1014076b718dSJose Luis Duran                "src": "192.0.2.1",
1015076b718dSJose Luis Duran                "dst": "192.0.2.2",
1016076b718dSJose Luis Duran                "icmp_type": 0,
1017076b718dSJose Luis Duran                "icmp_code": 0,
1018076b718dSJose Luis Duran                "opts": "NOP",
1019076b718dSJose Luis Duran            },
1020076b718dSJose Luis Duran            {
1021076b718dSJose Luis Duran                "returncode": 0,
1022076b718dSJose Luis Duran                "stdout": """\
1023076b718dSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
1024076b718dSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
1025076b718dSJose Luis Duranwrong total length 88 instead of 84
1026076b718dSJose Luis DuranNOP
1027076b718dSJose Luis Duran
1028076b718dSJose Luis Duran--- 192.0.2.2 ping statistics ---
1029076b718dSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
1030076b718dSJose Luis Duranround-trip min/avg/max/stddev = /// ms
1031076b718dSJose Luis Duran""",
1032076b718dSJose Luis Duran                "stderr": "",
1033076b718dSJose Luis Duran                "redacted": True,
1034076b718dSJose Luis Duran            },
1035076b718dSJose Luis Duran            id="_0_0_opts_NOP",
1036076b718dSJose Luis Duran        ),
1037076b718dSJose Luis Duran        pytest.param(
1038076b718dSJose Luis Duran            {
1039076b718dSJose Luis Duran                "src": "192.0.2.1",
1040076b718dSJose Luis Duran                "dst": "192.0.2.2",
104120012a3aSJose Luis Duran                "icmp_type": 3,
104220012a3aSJose Luis Duran                "icmp_code": 1,
104320012a3aSJose Luis Duran                "ihl": 0x4,
104420012a3aSJose Luis Duran            },
104520012a3aSJose Luis Duran            {
104620012a3aSJose Luis Duran                "returncode": 2,
104720012a3aSJose Luis Duran                "stdout": """\
104820012a3aSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
104920012a3aSJose Luis Duran
105020012a3aSJose Luis Duran--- 192.0.2.2 ping statistics ---
105120012a3aSJose Luis Duran1 packets transmitted, 0 packets received, 100.0% packet loss
105220012a3aSJose Luis Duran""",
105320012a3aSJose Luis Duran                "stderr": "",  # "IHL too short" message not shown
105420012a3aSJose Luis Duran                "redacted": False,
105520012a3aSJose Luis Duran            },
105620012a3aSJose Luis Duran            id="_IHL_too_short",
105720012a3aSJose Luis Duran        ),
105820012a3aSJose Luis Duran        pytest.param(
105920012a3aSJose Luis Duran            {
106020012a3aSJose Luis Duran                "src": "192.0.2.1",
106120012a3aSJose Luis Duran                "dst": "192.0.2.2",
106220012a3aSJose Luis Duran                "icmp_type": 3,
106320012a3aSJose Luis Duran                "icmp_code": 1,
106420012a3aSJose Luis Duran                "special": "no-payload",
106520012a3aSJose Luis Duran            },
106620012a3aSJose Luis Duran            {
106720012a3aSJose Luis Duran                "returncode": 2,
106820012a3aSJose Luis Duran                "stdout": """\
106920012a3aSJose Luis DuranPATTERN: 0x01
107020012a3aSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
107120012a3aSJose Luis Duran
107220012a3aSJose Luis Duran--- 192.0.2.2 ping statistics ---
107320012a3aSJose Luis Duran1 packets transmitted, 0 packets received, 100.0% packet loss
107420012a3aSJose Luis Duran""",
107520012a3aSJose Luis Duran                "stderr": """\
107620012a3aSJose Luis Duranping: quoted data too short (28 bytes) from 192.0.2.2
107720012a3aSJose Luis Duran""",
107820012a3aSJose Luis Duran                "redacted": False,
107920012a3aSJose Luis Duran            },
108020012a3aSJose Luis Duran            id="_quoted_data_too_short",
108120012a3aSJose Luis Duran        ),
108220012a3aSJose Luis Duran        pytest.param(
108320012a3aSJose Luis Duran            {
108420012a3aSJose Luis Duran                "src": "192.0.2.1",
108520012a3aSJose Luis Duran                "dst": "192.0.2.2",
108620012a3aSJose Luis Duran                "icmp_type": 3,
108720012a3aSJose Luis Duran                "icmp_code": 1,
108820012a3aSJose Luis Duran                "oip_ihl": 0x4,
108920012a3aSJose Luis Duran            },
109020012a3aSJose Luis Duran            {
109120012a3aSJose Luis Duran                "returncode": 2,
109220012a3aSJose Luis Duran                "stdout": """\
109320012a3aSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
109420012a3aSJose Luis Duran
109520012a3aSJose Luis Duran--- 192.0.2.2 ping statistics ---
109620012a3aSJose Luis Duran1 packets transmitted, 0 packets received, 100.0% packet loss
109720012a3aSJose Luis Duran""",
109820012a3aSJose Luis Duran                "stderr": "",  # "inner IHL too short" message not shown
109920012a3aSJose Luis Duran                "redacted": False,
110020012a3aSJose Luis Duran            },
110120012a3aSJose Luis Duran            id="_inner_IHL_too_short",
110220012a3aSJose Luis Duran        ),
110320012a3aSJose Luis Duran        pytest.param(
110420012a3aSJose Luis Duran            {
110520012a3aSJose Luis Duran                "src": "192.0.2.1",
110620012a3aSJose Luis Duran                "dst": "192.0.2.2",
110720012a3aSJose Luis Duran                "icmp_type": 3,
110820012a3aSJose Luis Duran                "icmp_code": 1,
110920012a3aSJose Luis Duran                "oip_ihl": 0xF,
111020012a3aSJose Luis Duran            },
111120012a3aSJose Luis Duran            {
111220012a3aSJose Luis Duran                "returncode": 2,
111320012a3aSJose Luis Duran                "stdout": """\
111420012a3aSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
111520012a3aSJose Luis Duran
111620012a3aSJose Luis Duran--- 192.0.2.2 ping statistics ---
111720012a3aSJose Luis Duran1 packets transmitted, 0 packets received, 100.0% packet loss
111820012a3aSJose Luis Duran""",
111920012a3aSJose Luis Duran                "stderr": """\
112020012a3aSJose Luis Duranping: inner packet too short (84 bytes) from 192.0.2.2
112120012a3aSJose Luis Duran""",
112220012a3aSJose Luis Duran                "redacted": False,
112320012a3aSJose Luis Duran            },
112420012a3aSJose Luis Duran            id="_inner_packet_too_short",
112520012a3aSJose Luis Duran        ),
112620012a3aSJose Luis Duran        pytest.param(
112720012a3aSJose Luis Duran            {
112820012a3aSJose Luis Duran                "src": "192.0.2.1",
112920012a3aSJose Luis Duran                "dst": "192.0.2.2",
113020012a3aSJose Luis Duran                "icmp_type": 3,
113120012a3aSJose Luis Duran                "icmp_code": 1,
113220012a3aSJose Luis Duran                "oip_ihl": 0xF,
113320012a3aSJose Luis Duran                "special": "no-payload",
113420012a3aSJose Luis Duran            },
113520012a3aSJose Luis Duran            {
113620012a3aSJose Luis Duran                "returncode": 2,
113720012a3aSJose Luis Duran                "stdout": """\
113820012a3aSJose Luis DuranPATTERN: 0x01
113920012a3aSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
114020012a3aSJose Luis Duran
114120012a3aSJose Luis Duran--- 192.0.2.2 ping statistics ---
114220012a3aSJose Luis Duran1 packets transmitted, 0 packets received, 100.0% packet loss
114320012a3aSJose Luis Duran""",
114420012a3aSJose Luis Duran                "stderr": "",
114520012a3aSJose Luis Duran                "redacted": False,
114620012a3aSJose Luis Duran            },
114720012a3aSJose Luis Duran            id="_max_inner_packet_ihl_without_payload",
114820012a3aSJose Luis Duran        ),
114920012a3aSJose Luis Duran        pytest.param(
115020012a3aSJose Luis Duran            {
115120012a3aSJose Luis Duran                "src": "192.0.2.1",
115220012a3aSJose Luis Duran                "dst": "192.0.2.2",
1153076b718dSJose Luis Duran                "icmp_type": 0,
1154076b718dSJose Luis Duran                "icmp_code": 0,
11555b8af90fSJose Luis Duran                "opts": "NOP-40",
11565b8af90fSJose Luis Duran            },
11575b8af90fSJose Luis Duran            {
11585b8af90fSJose Luis Duran                "returncode": 0,
11595b8af90fSJose Luis Duran                "stdout": """\
11605b8af90fSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
11615b8af90fSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
11625b8af90fSJose Luis Duranwrong total length 124 instead of 84
11635b8af90fSJose Luis DuranNOP
11645b8af90fSJose Luis DuranNOP
11655b8af90fSJose Luis DuranNOP
11665b8af90fSJose Luis DuranNOP
11675b8af90fSJose Luis DuranNOP
11685b8af90fSJose Luis DuranNOP
11695b8af90fSJose Luis DuranNOP
11705b8af90fSJose Luis DuranNOP
11715b8af90fSJose Luis DuranNOP
11725b8af90fSJose Luis DuranNOP
11735b8af90fSJose Luis DuranNOP
11745b8af90fSJose Luis DuranNOP
11755b8af90fSJose Luis DuranNOP
11765b8af90fSJose Luis DuranNOP
11775b8af90fSJose Luis DuranNOP
11785b8af90fSJose Luis DuranNOP
11795b8af90fSJose Luis DuranNOP
11805b8af90fSJose Luis DuranNOP
11815b8af90fSJose Luis DuranNOP
11825b8af90fSJose Luis DuranNOP
11835b8af90fSJose Luis DuranNOP
11845b8af90fSJose Luis DuranNOP
11855b8af90fSJose Luis DuranNOP
11865b8af90fSJose Luis DuranNOP
11875b8af90fSJose Luis DuranNOP
11885b8af90fSJose Luis DuranNOP
11895b8af90fSJose Luis DuranNOP
11905b8af90fSJose Luis DuranNOP
11915b8af90fSJose Luis DuranNOP
11925b8af90fSJose Luis DuranNOP
11935b8af90fSJose Luis DuranNOP
11945b8af90fSJose Luis DuranNOP
11955b8af90fSJose Luis DuranNOP
11965b8af90fSJose Luis DuranNOP
11975b8af90fSJose Luis DuranNOP
11985b8af90fSJose Luis DuranNOP
11995b8af90fSJose Luis DuranNOP
12005b8af90fSJose Luis DuranNOP
12015b8af90fSJose Luis DuranNOP
12025b8af90fSJose Luis DuranNOP
12035b8af90fSJose Luis Duran
12045b8af90fSJose Luis Duran--- 192.0.2.2 ping statistics ---
12055b8af90fSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
12065b8af90fSJose Luis Duranround-trip min/avg/max/stddev = /// ms
12075b8af90fSJose Luis Duran""",
12085b8af90fSJose Luis Duran                "stderr": "",
12095b8af90fSJose Luis Duran                "redacted": True,
12105b8af90fSJose Luis Duran            },
12115b8af90fSJose Luis Duran            id="_0_0_opts_NOP_40",
12125b8af90fSJose Luis Duran        ),
12135b8af90fSJose Luis Duran        pytest.param(
12145b8af90fSJose Luis Duran            {
12155b8af90fSJose Luis Duran                "src": "192.0.2.1",
12165b8af90fSJose Luis Duran                "dst": "192.0.2.2",
12175b8af90fSJose Luis Duran                "icmp_type": 0,
12185b8af90fSJose Luis Duran                "icmp_code": 0,
12195b8af90fSJose Luis Duran                "opts": "unk",
12205b8af90fSJose Luis Duran            },
12215b8af90fSJose Luis Duran            {
12225b8af90fSJose Luis Duran                "returncode": 0,
12235b8af90fSJose Luis Duran                "stdout": """\
12245b8af90fSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
12255b8af90fSJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
12265b8af90fSJose Luis Duranwrong total length 88 instead of 84
12275b8af90fSJose Luis Duranunknown option 9f
12285b8af90fSJose Luis Duran
12295b8af90fSJose Luis Duran--- 192.0.2.2 ping statistics ---
12305b8af90fSJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
12315b8af90fSJose Luis Duranround-trip min/avg/max/stddev = /// ms
12325b8af90fSJose Luis Duran""",
12335b8af90fSJose Luis Duran                "stderr": "",
12345b8af90fSJose Luis Duran                "redacted": True,
12355b8af90fSJose Luis Duran            },
12365b8af90fSJose Luis Duran            id="_0_0_opts_unk",
12375b8af90fSJose Luis Duran        ),
12385b8af90fSJose Luis Duran        pytest.param(
12395b8af90fSJose Luis Duran            {
12405b8af90fSJose Luis Duran                "src": "192.0.2.1",
12415b8af90fSJose Luis Duran                "dst": "192.0.2.2",
12425b8af90fSJose Luis Duran                "icmp_type": 3,
12435b8af90fSJose Luis Duran                "icmp_code": 1,
12445b8af90fSJose Luis Duran                "opts": "NOP-40",
12455b8af90fSJose Luis Duran            },
12465b8af90fSJose Luis Duran            {
12475b8af90fSJose Luis Duran                "returncode": 2,
12485b8af90fSJose Luis Duran                "stdout": """\
12495b8af90fSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
12505b8af90fSJose Luis Duran132 bytes from 192.0.2.2: Destination Host Unreachable
1251b86e4812SJose Luis DuranVr HL TOS  Len   ID Flg  off TTL Pro  cks       Src       Dst Opts
12525b8af90fSJose Luis Duran 4  f  00 007c 0001   0 0000  40  01 d868 192.0.2.1 192.0.2.2 01010101010101010101010101010101010101010101010101010101010101010101010101010101
12535b8af90fSJose Luis Duran
12545b8af90fSJose Luis Duran
12555b8af90fSJose Luis Duran--- 192.0.2.2 ping statistics ---
12565b8af90fSJose Luis Duran1 packets transmitted, 0 packets received, 100.0% packet loss
12575b8af90fSJose Luis Duran""",
12585b8af90fSJose Luis Duran                "stderr": "",
12595b8af90fSJose Luis Duran                "redacted": False,
12605b8af90fSJose Luis Duran            },
12615b8af90fSJose Luis Duran            id="_3_1_opts_NOP_40",
12625b8af90fSJose Luis Duran        ),
12635b8af90fSJose Luis Duran        pytest.param(
12645b8af90fSJose Luis Duran            {
12655b8af90fSJose Luis Duran                "src": "192.0.2.1",
12665b8af90fSJose Luis Duran                "dst": "192.0.2.2",
12675b8af90fSJose Luis Duran                "icmp_type": 3,
12685b8af90fSJose Luis Duran                "icmp_code": 1,
12695b8af90fSJose Luis Duran                "flags": "DF",
12705b8af90fSJose Luis Duran            },
12715b8af90fSJose Luis Duran            {
12725b8af90fSJose Luis Duran                "returncode": 2,
12735b8af90fSJose Luis Duran                "stdout": """\
12745b8af90fSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
12755b8af90fSJose Luis Duran92 bytes from 192.0.2.2: Destination Host Unreachable
12765b8af90fSJose Luis DuranVr HL TOS  Len   ID Flg  off TTL Pro  cks       Src       Dst
12775b8af90fSJose Luis Duran 4  5  00 0054 0001   2 0000  40  01 b6a4 192.0.2.1 192.0.2.2
12785b8af90fSJose Luis Duran
12795b8af90fSJose Luis Duran
12805b8af90fSJose Luis Duran--- 192.0.2.2 ping statistics ---
12815b8af90fSJose Luis Duran1 packets transmitted, 0 packets received, 100.0% packet loss
12825b8af90fSJose Luis Duran""",
12835b8af90fSJose Luis Duran                "stderr": "",
12845b8af90fSJose Luis Duran                "redacted": False,
12855b8af90fSJose Luis Duran            },
12865b8af90fSJose Luis Duran            id="_3_1_flags_DF",
12875b8af90fSJose Luis Duran        ),
12881dc1f6bdSJose Luis Duran        pytest.param(
12891dc1f6bdSJose Luis Duran            {
12901dc1f6bdSJose Luis Duran                "src": "192.0.2.1",
12911dc1f6bdSJose Luis Duran                "dst": "192.0.2.2",
12921dc1f6bdSJose Luis Duran                "icmp_type": 3,
12931dc1f6bdSJose Luis Duran                "icmp_code": 1,
12941dc1f6bdSJose Luis Duran                "special": "tcp",
12951dc1f6bdSJose Luis Duran            },
12961dc1f6bdSJose Luis Duran            {
12971dc1f6bdSJose Luis Duran                "returncode": 2,
12981dc1f6bdSJose Luis Duran                "stdout": """\
12991dc1f6bdSJose Luis DuranPATTERN: 0x01
13001dc1f6bdSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
13011dc1f6bdSJose Luis Duran
13021dc1f6bdSJose Luis Duran--- 192.0.2.2 ping statistics ---
13031dc1f6bdSJose Luis Duran1 packets transmitted, 0 packets received, 100.0% packet loss
13041dc1f6bdSJose Luis Duran""",
13051dc1f6bdSJose Luis Duran                "stderr": """\
13061dc1f6bdSJose Luis Duranping: quoted data too short (40 bytes) from 192.0.2.2
13071dc1f6bdSJose Luis Duran""",
13081dc1f6bdSJose Luis Duran                "redacted": False,
13091dc1f6bdSJose Luis Duran            },
13101dc1f6bdSJose Luis Duran            id="_3_1_special_tcp",
13111dc1f6bdSJose Luis Duran        ),
13121dc1f6bdSJose Luis Duran        pytest.param(
13131dc1f6bdSJose Luis Duran            {
13141dc1f6bdSJose Luis Duran                "src": "192.0.2.1",
13151dc1f6bdSJose Luis Duran                "dst": "192.0.2.2",
13161dc1f6bdSJose Luis Duran                "icmp_type": 3,
13171dc1f6bdSJose Luis Duran                "icmp_code": 1,
13181dc1f6bdSJose Luis Duran                "special": "udp",
13191dc1f6bdSJose Luis Duran            },
13201dc1f6bdSJose Luis Duran            {
13211dc1f6bdSJose Luis Duran                "returncode": 2,
13221dc1f6bdSJose Luis Duran                "stdout": """\
13231dc1f6bdSJose Luis DuranPATTERN: 0x01
13241dc1f6bdSJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
13251dc1f6bdSJose Luis Duran
13261dc1f6bdSJose Luis Duran--- 192.0.2.2 ping statistics ---
13271dc1f6bdSJose Luis Duran1 packets transmitted, 0 packets received, 100.0% packet loss
13281dc1f6bdSJose Luis Duran""",
13291dc1f6bdSJose Luis Duran                "stderr": """\
13301dc1f6bdSJose Luis Duranping: quoted data too short (28 bytes) from 192.0.2.2
13311dc1f6bdSJose Luis Duran""",
13321dc1f6bdSJose Luis Duran                "redacted": False,
13331dc1f6bdSJose Luis Duran            },
13341dc1f6bdSJose Luis Duran            id="_3_1_special_udp",
13351dc1f6bdSJose Luis Duran        ),
1336ea6d1692SJose Luis Duran        pytest.param(
1337ea6d1692SJose Luis Duran            {
1338ea6d1692SJose Luis Duran                "src": "192.0.2.1",
1339ea6d1692SJose Luis Duran                "dst": "192.0.2.2",
13409fc2d858SJose Luis Duran                "icmp_type": 3,
13419fc2d858SJose Luis Duran                "icmp_code": 1,
13429fc2d858SJose Luis Duran                "verbose": False,
13439fc2d858SJose Luis Duran            },
13449fc2d858SJose Luis Duran            {
13459fc2d858SJose Luis Duran                "returncode": 2,
13469fc2d858SJose Luis Duran                "stdout": """\
13479fc2d858SJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
13489fc2d858SJose Luis Duran92 bytes from 192.0.2.2: Destination Host Unreachable
13499fc2d858SJose Luis DuranVr HL TOS  Len   ID Flg  off TTL Pro  cks       Src       Dst
13509fc2d858SJose Luis Duran 4  5  00 0054 0001   0 0000  40  01 f6a4 192.0.2.1 192.0.2.2
13519fc2d858SJose Luis Duran
13529fc2d858SJose Luis Duran
13539fc2d858SJose Luis Duran--- 192.0.2.2 ping statistics ---
13549fc2d858SJose Luis Duran1 packets transmitted, 0 packets received, 100.0% packet loss
13559fc2d858SJose Luis Duran""",
13569fc2d858SJose Luis Duran                "stderr": "",
13579fc2d858SJose Luis Duran                "redacted": False,
13589fc2d858SJose Luis Duran            },
13599fc2d858SJose Luis Duran            id="_3_1_verbose_false",
13609fc2d858SJose Luis Duran        ),
13619fc2d858SJose Luis Duran        pytest.param(
13629fc2d858SJose Luis Duran            {
13639fc2d858SJose Luis Duran                "src": "192.0.2.1",
13649fc2d858SJose Luis Duran                "dst": "192.0.2.2",
13659fc2d858SJose Luis Duran                "icmp_type": 3,
13669fc2d858SJose Luis Duran                "icmp_code": 1,
13679fc2d858SJose Luis Duran                "special": "not-mine",
13689fc2d858SJose Luis Duran                "verbose": False,
13699fc2d858SJose Luis Duran            },
13709fc2d858SJose Luis Duran            {
13719fc2d858SJose Luis Duran                "returncode": 2,
13729fc2d858SJose Luis Duran                "stdout": """\
13739fc2d858SJose Luis DuranPATTERN: 0x01
13749fc2d858SJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
13759fc2d858SJose Luis Duran
13769fc2d858SJose Luis Duran--- 192.0.2.2 ping statistics ---
13779fc2d858SJose Luis Duran1 packets transmitted, 0 packets received, 100.0% packet loss
13789fc2d858SJose Luis Duran""",
13799fc2d858SJose Luis Duran                "stderr": "",
13809fc2d858SJose Luis Duran                "redacted": False,
13819fc2d858SJose Luis Duran            },
13829fc2d858SJose Luis Duran            id="_3_1_special_not_mine_verbose_false",
13839fc2d858SJose Luis Duran        ),
13849fc2d858SJose Luis Duran        pytest.param(
13859fc2d858SJose Luis Duran            {
13869fc2d858SJose Luis Duran                "src": "192.0.2.1",
13879fc2d858SJose Luis Duran                "dst": "192.0.2.2",
1388ea6d1692SJose Luis Duran                "icmp_type": 0,
1389ea6d1692SJose Luis Duran                "icmp_code": 0,
1390ea6d1692SJose Luis Duran                "special": "warp",
1391ea6d1692SJose Luis Duran            },
1392ea6d1692SJose Luis Duran            {
1393ea6d1692SJose Luis Duran                "returncode": 0,
1394ea6d1692SJose Luis Duran                "stdout": """\
1395ea6d1692SJose Luis DuranPATTERN: 0x01
1396ea6d1692SJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
1397ea6d1692SJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
1398ea6d1692SJose Luis Duran
1399ea6d1692SJose Luis Duran--- 192.0.2.2 ping statistics ---
1400ea6d1692SJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
1401ea6d1692SJose Luis Duranround-trip min/avg/max/stddev = /// ms
1402ea6d1692SJose Luis Duran""",
1403ea6d1692SJose Luis Duran                "stderr": """\
1404ea6d1692SJose Luis Duranping: time of day goes back (- ms), clamping time to 0
1405ea6d1692SJose Luis Duran""",
1406ea6d1692SJose Luis Duran                "redacted": True,
1407ea6d1692SJose Luis Duran            },
1408ea6d1692SJose Luis Duran            id="_0_0_special_warp",
1409ea6d1692SJose Luis Duran        ),
14108db2c580SJose Luis Duran        pytest.param(
14118db2c580SJose Luis Duran            {
14128db2c580SJose Luis Duran                "src": "192.0.2.1",
14138db2c580SJose Luis Duran                "dst": "192.0.2.2",
14148db2c580SJose Luis Duran                "icmp_type": 0,
14158db2c580SJose Luis Duran                "icmp_code": 0,
14168db2c580SJose Luis Duran                "special": "wrong",
14178db2c580SJose Luis Duran            },
14188db2c580SJose Luis Duran            {
14198db2c580SJose Luis Duran                "returncode": 0,
14208db2c580SJose Luis Duran                "stdout": """\
14218db2c580SJose Luis DuranPATTERN: 0x01
14228db2c580SJose Luis DuranPING 192.0.2.2 (192.0.2.2): 56 data bytes
14238db2c580SJose Luis Duran64 bytes from: icmp_seq=0 ttl= time= ms
14248db2c580SJose Luis Duranwrong data byte #55 should be 0x1 but was 0x0
14258db2c580SJose Luis Durancp: xx xx xx xx xx xx xx xx
14268db2c580SJose Luis Duran	  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
14278db2c580SJose Luis Duran	  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
14288db2c580SJose Luis Duran	  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  0
14298db2c580SJose Luis Durandp: xx xx xx xx xx xx xx xx
14308db2c580SJose Luis Duran	  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
14318db2c580SJose Luis Duran	  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
14328db2c580SJose Luis Duran	  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
14338db2c580SJose Luis Duran
14348db2c580SJose Luis Duran--- 192.0.2.2 ping statistics ---
14358db2c580SJose Luis Duran1 packets transmitted, 1 packets received, 0.0% packet loss
14368db2c580SJose Luis Duranround-trip min/avg/max/stddev = /// ms
14378db2c580SJose Luis Duran""",
14388db2c580SJose Luis Duran                "stderr": "",
14398db2c580SJose Luis Duran                "redacted": True,
14408db2c580SJose Luis Duran            },
14418db2c580SJose Luis Duran            id="_0_0_special_wrong",
14428db2c580SJose Luis Duran        ),
14435b8af90fSJose Luis Duran    ]
14445b8af90fSJose Luis Duran
14455b8af90fSJose Luis Duran    @pytest.mark.parametrize("pinger_kargs, expected", pinger_testdata)
14465b8af90fSJose Luis Duran    @pytest.mark.require_progs(["scapy"])
14475b8af90fSJose Luis Duran    @pytest.mark.require_user("root")
14485b8af90fSJose Luis Duran    def test_pinger(self, pinger_kargs, expected):
14495b8af90fSJose Luis Duran        """Test ping using pinger(), a reply faker"""
14505b8af90fSJose Luis Duran        iface = IfaceFactory().create_iface("", "tun")[0].name
14515b8af90fSJose Luis Duran        ping = pinger(iface, **pinger_kargs)
14525b8af90fSJose Luis Duran        assert ping.returncode == expected["returncode"]
14535b8af90fSJose Luis Duran        if expected["redacted"]:
14545b8af90fSJose Luis Duran            assert redact(ping.stdout) == expected["stdout"]
1455ea6d1692SJose Luis Duran            assert redact(ping.stderr) == expected["stderr"]
14565b8af90fSJose Luis Duran        else:
14575b8af90fSJose Luis Duran            assert ping.stdout == expected["stdout"]
14585b8af90fSJose Luis Duran            assert ping.stderr == expected["stderr"]
1459