tap2pcap_test.py
Go to the documentation of this file.
1 """Tests for tap2pcap."""
2 from __future__ import print_function
3 
4 import os
5 import subprocess as sp
6 import sys
7 
8 import tap2pcap
9 
10 # Validate that the tapped trace when run through tap2cap | tshark matches
11 # a golden output file for the tshark dump. Since we run tap2pcap in a
12 # subshell with a limited environment, the inferred time zone should be UTC.
13 if __name__ == '__main__':
14  srcdir = os.path.join(os.getenv('TEST_SRCDIR'), 'envoy_api')
15  tap_path = os.path.join(srcdir, 'tools/data/tap2pcap_h2_ipv4.pb_text')
16  expected_path = os.path.join(srcdir, 'tools/data/tap2pcap_h2_ipv4.txt')
17  pcap_path = os.path.join(os.getenv('TEST_TMPDIR'), 'generated.pcap')
18 
19  tap2pcap.tap2pcap(tap_path, pcap_path)
20  actual_output = sp.check_output(
21  ['tshark', '-r', pcap_path, '-d', 'tcp.port==10000,http2', '-P'])
22  with open(expected_path, 'rb') as f:
23  expected_output = f.read()
24  if actual_output != expected_output:
25  print('Mismatch')
26  print('Expected: %s' % expected_output)
27  print('Actual: %s' % actual_output)
28  sys.exit(1)
open
#define open
Definition: test-fs.c:46
tap2pcap.tap2pcap
def tap2pcap(tap_path, pcap_path)
Definition: tap2pcap.py:46


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:29