mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 04:43:53 +00:00
ping: Fix the spacing between the time stamp and cp/dp
When an echo reply packet is received, the data is compared with the sent data. When a wrong byte is detected the command displays a report with the differences. The first row (the first 8-bytes of data after the ICMP header) should include the time stamp (if data is at least 8-bytes), this value is not taken into consideration for the comparison. The remaining rows represent the data (padded pattern) received/sent, with each byte being compared for differences. Print the space before (not after), to add an extra space after cp:/dp: for better readability when the first time stamp octet is not zero-padded, and to remove trailing spaces in the output. Before: cp:99 0 0 c 1 5 c 0␣ ab cd ab cd ab cd ab cd ab cd ab cd ab cd ab cd␣ ... After: cp: 99 0 0 c 1 5 c 0 ab cd ab cd ab cd ab cd ab cd ab cd ab cd ab cd ... Reviewed by: markj MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/863 Differential Revision: https://reviews.freebsd.org/D39492
This commit is contained in:
parent
03d4d1c778
commit
8db2c5802a
|
@ -275,6 +275,8 @@ def redact(output):
|
|||
("hlim=[0-9]*", "hlim="),
|
||||
("ttl=[0-9]*", "ttl="),
|
||||
("time=[0-9.-]*", "time="),
|
||||
("cp: .*", "cp: xx xx xx xx xx xx xx xx"),
|
||||
("dp: .*", "dp: xx xx xx xx xx xx xx xx"),
|
||||
("\(-[0-9\.]+[0-9]+ ms\)", "(- ms)"),
|
||||
("[0-9\.]+/[0-9.]+", "/"),
|
||||
]
|
||||
|
@ -1401,6 +1403,39 @@ def test_ping_46(self, expected):
|
|||
},
|
||||
id="_0_0_special_warp",
|
||||
),
|
||||
pytest.param(
|
||||
{
|
||||
"src": "192.0.2.1",
|
||||
"dst": "192.0.2.2",
|
||||
"icmp_type": 0,
|
||||
"icmp_code": 0,
|
||||
"special": "wrong",
|
||||
},
|
||||
{
|
||||
"returncode": 0,
|
||||
"stdout": """\
|
||||
PATTERN: 0x01
|
||||
PING 192.0.2.2 (192.0.2.2): 56 data bytes
|
||||
64 bytes from: icmp_seq=0 ttl= time= ms
|
||||
wrong data byte #55 should be 0x1 but was 0x0
|
||||
cp: xx xx xx xx xx xx xx xx
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
|
||||
dp: xx xx xx xx xx xx xx xx
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
|
||||
|
||||
--- 192.0.2.2 ping statistics ---
|
||||
1 packets transmitted, 1 packets received, 0.0% packet loss
|
||||
round-trip min/avg/max/stddev = /// ms
|
||||
""",
|
||||
"stderr": "",
|
||||
"redacted": True,
|
||||
},
|
||||
id="_0_0_special_wrong",
|
||||
),
|
||||
]
|
||||
|
||||
@pytest.mark.parametrize("pinger_kargs, expected", pinger_testdata)
|
||||
|
|
Loading…
Reference in a new issue