Skip to content

Commit 5945ea9

Browse files
shancock884tridge
authored andcommitted
WLua: Only truncate hex dump lines for test case output checks
1 parent cc7395f commit 5945ea9

2 files changed

Lines changed: 55 additions & 52 deletions

File tree

tests/snapshottests/__snapshots__/test_wlua.ambr

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
'returncode': 0,
55
'stderr': '',
66
'stdout': '''
7-
Frame 1: 101 bytes on wire (808 bits), 101 bytes captured (808 bits) on
7+
Frame 1: 101 bytes on wire (808 bits), 101 bytes captured (808 bits) on interface lo0, id 0
88
Null/Loopback
99
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
10-
Transmission Control Protocol, Src Port: 62025, Dst Port: 5760, Seq: 1,
10+
Transmission Control Protocol, Src Port: 62025, Dst Port: 5760, Seq: 1, Ack: 1, Len: 45
1111
MAVLink Protocol (45)
1212
Header
1313
Magic value / version: MAVLink 2.0 (0xfd)
@@ -32,10 +32,10 @@
3232
param7 (float): 0
3333
Message CRC: 0xdb93
3434

35-
Frame 2: 138 bytes on wire (1104 bits), 138 bytes captured (1104 bits) o
35+
Frame 2: 138 bytes on wire (1104 bits), 138 bytes captured (1104 bits) on interface lo0, id 0
3636
Null/Loopback
3737
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
38-
Transmission Control Protocol, Src Port: 5760, Dst Port: 62025, Seq: 1,
38+
Transmission Control Protocol, Src Port: 5760, Dst Port: 62025, Seq: 1, Ack: 46, Len: 82
3939
MAVLink Protocol (82)
4040
Header
4141
Magic value / version: MAVLink 2.0 (0xfd)
@@ -65,10 +65,10 @@
6565
text (char): Mode change to LOITER failed: requires position
6666
Message CRC: 0x647a
6767

68-
Frame 3: 101 bytes on wire (808 bits), 101 bytes captured (808 bits) on
68+
Frame 3: 101 bytes on wire (808 bits), 101 bytes captured (808 bits) on interface lo0, id 0
6969
Null/Loopback
7070
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
71-
Transmission Control Protocol, Src Port: 62025, Dst Port: 5760, Seq: 706
71+
Transmission Control Protocol, Src Port: 62025, Dst Port: 5760, Seq: 706, Ack: 12611, Len: 45
7272
MAVLink Protocol (45)
7373
Header
7474
Magic value / version: MAVLink 2.0 (0xfd)
@@ -93,10 +93,10 @@
9393
param7 (float): 0
9494
Message CRC: 0xf9df
9595

96-
Frame 4: 144 bytes on wire (1152 bits), 144 bytes captured (1152 bits) o
96+
Frame 4: 144 bytes on wire (1152 bits), 144 bytes captured (1152 bits) on interface lo0, id 0
9797
Null/Loopback
9898
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
99-
Transmission Control Protocol, Src Port: 5760, Dst Port: 62025, Seq: 126
99+
Transmission Control Protocol, Src Port: 5760, Dst Port: 62025, Seq: 12611, Ack: 751, Len: 88
100100
MAVLink Protocol (88)
101101
Header
102102
Magic value / version: MAVLink 2.0 (0xfd)
@@ -152,10 +152,10 @@
152152
'returncode': 0,
153153
'stderr': '',
154154
'stdout': '''
155-
Frame 1: 101 bytes on wire (808 bits), 101 bytes captured (808 bits) on
155+
Frame 1: 101 bytes on wire (808 bits), 101 bytes captured (808 bits) on interface lo0, id 0
156156
Null/Loopback
157157
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
158-
Transmission Control Protocol, Src Port: 62025, Dst Port: 5760, Seq: 1,
158+
Transmission Control Protocol, Src Port: 62025, Dst Port: 5760, Seq: 1, Ack: 1, Len: 45
159159
MAVLink Protocol (45)
160160
Header
161161
Magic value / version: MAVLink 2.0 (0xfd)
@@ -180,10 +180,10 @@
180180
param7 (float): 0
181181
Message CRC: 0xdb93
182182

183-
Frame 2: 138 bytes on wire (1104 bits), 138 bytes captured (1104 bits) o
183+
Frame 2: 138 bytes on wire (1104 bits), 138 bytes captured (1104 bits) on interface lo0, id 0
184184
Null/Loopback
185185
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
186-
Transmission Control Protocol, Src Port: 5760, Dst Port: 62025, Seq: 1,
186+
Transmission Control Protocol, Src Port: 5760, Dst Port: 62025, Seq: 1, Ack: 46, Len: 82
187187
MAVLink Protocol (82)
188188
Header
189189
Magic value / version: MAVLink 2.0 (0xfd)
@@ -213,10 +213,10 @@
213213
text (char): Mode change to LOITER failed: requires position
214214
Message CRC: 0x647a
215215

216-
Frame 3: 101 bytes on wire (808 bits), 101 bytes captured (808 bits) on
216+
Frame 3: 101 bytes on wire (808 bits), 101 bytes captured (808 bits) on interface lo0, id 0
217217
Null/Loopback
218218
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
219-
Transmission Control Protocol, Src Port: 62025, Dst Port: 5760, Seq: 706
219+
Transmission Control Protocol, Src Port: 62025, Dst Port: 5760, Seq: 706, Ack: 12611, Len: 45
220220
MAVLink Protocol (45)
221221
Header
222222
Magic value / version: MAVLink 2.0 (0xfd)
@@ -241,10 +241,10 @@
241241
param7 (float): 0
242242
Message CRC: 0xf9df
243243

244-
Frame 4: 144 bytes on wire (1152 bits), 144 bytes captured (1152 bits) o
244+
Frame 4: 144 bytes on wire (1152 bits), 144 bytes captured (1152 bits) on interface lo0, id 0
245245
Null/Loopback
246246
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
247-
Transmission Control Protocol, Src Port: 5760, Dst Port: 62025, Seq: 126
247+
Transmission Control Protocol, Src Port: 5760, Dst Port: 62025, Seq: 12611, Ack: 751, Len: 88
248248
MAVLink Protocol (88)
249249
Header
250250
Magic value / version: MAVLink 2.0 (0xfd)
@@ -300,10 +300,10 @@
300300
'returncode': 0,
301301
'stderr': '',
302302
'stdout': '''
303-
Frame 1: 101 bytes on wire (808 bits), 101 bytes captured (808 bits) on
303+
Frame 1: 101 bytes on wire (808 bits), 101 bytes captured (808 bits) on interface lo0, id 0
304304
Null/Loopback
305305
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
306-
Transmission Control Protocol, Src Port: 62025, Dst Port: 5760, Seq: 1,
306+
Transmission Control Protocol, Src Port: 62025, Dst Port: 5760, Seq: 1, Ack: 1, Len: 45
307307
MAVLink Protocol (45)
308308
Header
309309
Magic value / version: MAVLink 2.0 (0xfd)
@@ -321,10 +321,10 @@
321321
Unparsable payload: 0000803f0000a04000000000000000000000000000000000
322322
Message CRC: 0xdb93
323323

324-
Frame 2: 138 bytes on wire (1104 bits), 138 bytes captured (1104 bits) o
324+
Frame 2: 138 bytes on wire (1104 bits), 138 bytes captured (1104 bits) on interface lo0, id 0
325325
Null/Loopback
326326
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
327-
Transmission Control Protocol, Src Port: 5760, Dst Port: 62025, Seq: 1,
327+
Transmission Control Protocol, Src Port: 5760, Dst Port: 62025, Seq: 1, Ack: 46, Len: 82
328328
MAVLink Protocol (82)
329329
Header
330330
Magic value / version: MAVLink 2.0 (0xfd)
@@ -342,10 +342,10 @@
342342
Unparsable payload: b000040000000000fafa9276fd300000db0101fd0000044d
343343
Message CRC: 0x647a
344344

345-
Frame 3: 101 bytes on wire (808 bits), 101 bytes captured (808 bits) on
345+
Frame 3: 101 bytes on wire (808 bits), 101 bytes captured (808 bits) on interface lo0, id 0
346346
Null/Loopback
347347
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
348-
Transmission Control Protocol, Src Port: 62025, Dst Port: 5760, Seq: 706
348+
Transmission Control Protocol, Src Port: 62025, Dst Port: 5760, Seq: 706, Ack: 12611, Len: 45
349349
MAVLink Protocol (45)
350350
Header
351351
Magic value / version: MAVLink 2.0 (0xfd)
@@ -363,10 +363,10 @@
363363
Unparsable payload: 000000000000000000000000000000000000000000000000
364364
Message CRC: 0xf9df
365365

366-
Frame 4: 144 bytes on wire (1152 bits), 144 bytes captured (1152 bits) o
366+
Frame 4: 144 bytes on wire (1152 bits), 144 bytes captured (1152 bits) on interface lo0, id 0
367367
Null/Loopback
368368
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
369-
Transmission Control Protocol, Src Port: 5760, Dst Port: 62025, Seq: 126
369+
Transmission Control Protocol, Src Port: 5760, Dst Port: 62025, Seq: 12611, Ack: 751, Len: 88
370370
MAVLink Protocol (88)
371371
Header
372372
Magic value / version: MAVLink 2.0 (0xfd)
@@ -393,7 +393,7 @@
393393
'returncode': 0,
394394
'stderr': '',
395395
'stdout': '''
396-
Frame 1: 131 bytes on wire (1048 bits), 131 bytes captured (1048 bits) o
396+
Frame 1: 131 bytes on wire (1048 bits), 131 bytes captured (1048 bits) on interface lo, id 0
397397
Ethernet II, Src: 00:00:00:00:00:00, Dst: 00:00:00:00:00:00
398398
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
399399
User Datagram Protocol, Src Port: 34942, Dst Port: 18570
@@ -408,25 +408,25 @@
408408
Component id: MAV_COMP_ID_AUTOPILOT1 (1)
409409
Message id: AUTOPILOT_VERSION (148)
410410
Payload: AUTOPILOT_VERSION (148)
411-
capabilities (MAV_PROTOCOL_CAPABILITY): 0x000000000000f36f (6231
412-
.... .... .... .... ...1 = MAV_PROTOCOL_CAPABILITY_MISSION_F
413-
.... .... .... .... ..1. = MAV_PROTOCOL_CAPABILITY_PARAM_FLO
414-
.... .... .... .... .1.. = MAV_PROTOCOL_CAPABILITY_MISSION_I
415-
.... .... .... .... 1... = MAV_PROTOCOL_CAPABILITY_COMMAND_I
416-
.... .... .... ...0 .... = MAV_PROTOCOL_CAPABILITY_PARAM_ENC
411+
capabilities (MAV_PROTOCOL_CAPABILITY): 0x000000000000f36f (62319)
412+
.... .... .... .... ...1 = MAV_PROTOCOL_CAPABILITY_MISSION_FLOAT: True
413+
.... .... .... .... ..1. = MAV_PROTOCOL_CAPABILITY_PARAM_FLOAT: True
414+
.... .... .... .... .1.. = MAV_PROTOCOL_CAPABILITY_MISSION_INT: True
415+
.... .... .... .... 1... = MAV_PROTOCOL_CAPABILITY_COMMAND_INT: True
416+
.... .... .... ...0 .... = MAV_PROTOCOL_CAPABILITY_PARAM_ENCODE_BYTEWISE: False
417417
.... .... .... ..1. .... = MAV_PROTOCOL_CAPABILITY_FTP: True
418-
.... .... .... .1.. .... = MAV_PROTOCOL_CAPABILITY_SET_ATTIT
419-
.... .... .... 0... .... = MAV_PROTOCOL_CAPABILITY_SET_POSIT
420-
.... .... ...1 .... .... = MAV_PROTOCOL_CAPABILITY_SET_POSIT
421-
.... .... ..1. .... .... = MAV_PROTOCOL_CAPABILITY_TERRAIN:
422-
.... .... .0.. .... .... = MAV_PROTOCOL_CAPABILITY_SET_ACTUA
423-
.... .... 0... .... .... = MAV_PROTOCOL_CAPABILITY_FLIGHT_TE
424-
.... ...1 .... .... .... = MAV_PROTOCOL_CAPABILITY_COMPASS_C
425-
.... ..1. .... .... .... = MAV_PROTOCOL_CAPABILITY_MAVLINK2:
426-
.... .1.. .... .... .... = MAV_PROTOCOL_CAPABILITY_MISSION_F
427-
.... 1... .... .... .... = MAV_PROTOCOL_CAPABILITY_MISSION_R
428-
...0 .... .... .... .... = MAV_PROTOCOL_CAPABILITY_RESERVED2
429-
..0. .... .... .... .... = MAV_PROTOCOL_CAPABILITY_PARAM_ENC
418+
.... .... .... .1.. .... = MAV_PROTOCOL_CAPABILITY_SET_ATTITUDE_TARGET: True
419+
.... .... .... 0... .... = MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_LOCAL_NED: False
420+
.... .... ...1 .... .... = MAV_PROTOCOL_CAPABILITY_SET_POSITION_TARGET_GLOBAL_INT: True
421+
.... .... ..1. .... .... = MAV_PROTOCOL_CAPABILITY_TERRAIN: True
422+
.... .... .0.. .... .... = MAV_PROTOCOL_CAPABILITY_SET_ACTUATOR_TARGET: False
423+
.... .... 0... .... .... = MAV_PROTOCOL_CAPABILITY_FLIGHT_TERMINATION: False
424+
.... ...1 .... .... .... = MAV_PROTOCOL_CAPABILITY_COMPASS_CALIBRATION: True
425+
.... ..1. .... .... .... = MAV_PROTOCOL_CAPABILITY_MAVLINK2: True
426+
.... .1.. .... .... .... = MAV_PROTOCOL_CAPABILITY_MISSION_FENCE: True
427+
.... 1... .... .... .... = MAV_PROTOCOL_CAPABILITY_MISSION_RALLY: True
428+
...0 .... .... .... .... = MAV_PROTOCOL_CAPABILITY_RESERVED2: False
429+
..0. .... .... .... .... = MAV_PROTOCOL_CAPABILITY_PARAM_ENCODE_C_CAST: False
430430
flight_sw_version (uint32_t): 67307007
431431
middleware_sw_version (uint32_t): 0
432432
os_sw_version (uint32_t): 0
@@ -469,7 +469,7 @@
469469
'returncode': 0,
470470
'stderr': '',
471471
'stdout': '''
472-
Frame 1: 70 bytes on wire (560 bits), 70 bytes captured (560 bits) on in
472+
Frame 1: 70 bytes on wire (560 bits), 70 bytes captured (560 bits) on interface lo, id 0
473473
Ethernet II, Src: 00:00:00:00:00:00, Dst: 00:00:00:00:00:00
474474
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
475475
User Datagram Protocol, Src Port: 57304, Dst Port: 14550
@@ -498,10 +498,10 @@
498498
'returncode': 0,
499499
'stderr': '',
500500
'stdout': '''
501-
Frame 1: 115 bytes on wire (920 bits), 115 bytes captured (920 bits) on
501+
Frame 1: 115 bytes on wire (920 bits), 115 bytes captured (920 bits) on interface lo, id 0
502502
Ethernet II, Src: 00:00:00:00:00:00, Dst: 00:00:00:00:00:00
503503
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
504-
Transmission Control Protocol, Src Port: 54026, Dst Port: 5760, Seq: 1,
504+
Transmission Control Protocol, Src Port: 54026, Dst Port: 5760, Seq: 1, Ack: 1, Len: 49
505505
MAVLink Protocol (49)
506506
Header
507507
Magic value / version: MAVLink 2.0 (0xfd)
@@ -520,7 +520,7 @@
520520
command (MAV_CMD): MAV_CMD_NAV_VTOL_LAND (85)
521521
current (uint8_t): 0
522522
autocontinue (uint8_t): 1
523-
param1: Land Options (NAV_VTOL_LAND_OPTIONS): NAV_VTOL_LAND_OPTI
523+
param1: Land Options (NAV_VTOL_LAND_OPTIONS): NAV_VTOL_LAND_OPTIONS_DEFAULT (0)
524524
param2 (float): 0
525525
param3: Approach Altitude (float) m: 0
526526
param4: Yaw (float) deg: 0
@@ -538,7 +538,7 @@
538538
'returncode': 0,
539539
'stderr': '',
540540
'stdout': '''
541-
Frame 1: 97 bytes on wire (776 bits), 97 bytes captured (776 bits) on in
541+
Frame 1: 97 bytes on wire (776 bits), 97 bytes captured (776 bits) on interface lo, id 0
542542
Ethernet II, Src: 00:00:00:00:00:00, Dst: 00:00:00:00:00:00
543543
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
544544
User Datagram Protocol, Src Port: 52752, Dst Port: 14550
@@ -574,7 +574,7 @@
574574
'returncode': 0,
575575
'stderr': '',
576576
'stdout': '''
577-
Frame 1: 139 bytes on wire (1112 bits), 139 bytes captured (1112 bits) o
577+
Frame 1: 139 bytes on wire (1112 bits), 139 bytes captured (1112 bits) on interface \Device\NPF_Loopback, id 0
578578
Null/Loopback
579579
Internet Protocol Version 4, Src: 127.0.0.1, Dst: 127.0.0.1
580580
User Datagram Protocol, Src Port: 50261, Dst Port: 14550

tests/snapshottests/test_wlua.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
Test that the wlua generator works in Wireshark
55
"""
6-
import os
6+
import os, re
77
import shutil
88
import subprocess
99

@@ -94,8 +94,11 @@ def test_wlua(request, tmp_path, snapshot, mdef, pcap):
9494
# note that, with text output, tshark truncates hex dump lines at 80-ish or 100-ish characters.
9595
# Truncate them preemptively so this isn't reflected in the diff.
9696
# This doesn't lose any info we really care about.
97-
truncated_stdout = ''.join([line[:72]+"\n" for line in actual.stdout.splitlines()])
98-
97+
stdout_lines = actual.stdout.splitlines()
98+
for i in range(len(stdout_lines)):
99+
if re.search(r"[0-9a-f]{60}", stdout_lines[i]):
100+
stdout_lines[i] = stdout_lines[i][:72]
101+
truncated_stdout = '\n'.join(stdout_lines) + '\n'
99102
props_to_match = {
100103
"stdout": truncated_stdout,
101104
"stderr": actual.stderr,

0 commit comments

Comments
 (0)