TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags
[wireshark-sm.git] / test / suite_extcaps.py
blobd71d8e4039b1a9c5a07e0bb508c8d684264f6a17
2 # Wireshark tests
3 # By Gerald Combs <gerald@wireshark.org>
5 # Copyright (c) 2019 Dario Lombardo <lomato@gmail.com>
7 # SPDX-License-Identifier: GPL-2.0-or-later
9 '''extcap tests'''
11 import subprocess
12 import re
13 import os
14 import sys
15 import pytest
18 @pytest.fixture
19 def check_extcap_execution(cmd_extcap, program_path, base_env):
20 def check_extcap_interface_execution(extcap_name, interface, stratoshark_extcap):
21 ''' Check if an extcap runs flawlessly for interface configuration. '''
23 subprocess.check_call([cmd_extcap(extcap_name, stratoshark_extcap), '--extcap-interface',
24 interface, '--extcap-dlts'], cwd=program_path, env=base_env)
25 subprocess.check_call([cmd_extcap(extcap_name, stratoshark_extcap), '--extcap-interface',
26 interface, '--extcap-config'], cwd=program_path, env=base_env)
28 def extcap_get_interfaces(extcap_output):
29 ''' Extract the interface name from extcap. '''
30 parser = re.compile("{value=(.*?)}")
31 interfaces = []
32 for line in extcap_output.splitlines():
33 if line.startswith('interface '):
34 interfaces.append(parser.findall(line)[0])
35 return interfaces
37 def check_extcap_execution_real(extcap_name, stratoshark_extcap=False, always_present=True):
38 '''
39 Check if an extcap runs flawlessly.
40 always_present: at least one interface is always offered by the extcap.
41 '''
43 subprocess.check_call([cmd_extcap(extcap_name, stratoshark_extcap), '--help'], cwd=program_path, env=base_env)
44 extcap_stdout = subprocess.check_output(
45 [cmd_extcap(extcap_name, stratoshark_extcap), '--extcap-interfaces'], cwd=program_path, encoding='utf-8', env=base_env)
46 interfaces = extcap_get_interfaces(extcap_stdout)
47 if always_present:
48 assert len(interfaces) > 0
49 for interface in interfaces:
50 check_extcap_interface_execution(extcap_name, interface, stratoshark_extcap)
52 return check_extcap_execution_real
55 class TestExtcaps:
56 def test_androiddump(self, check_extcap_execution):
57 ''' extcap interface tests for androiddump '''
58 check_extcap_execution("androiddump", always_present=False)
60 def test_ciscodump(self, check_extcap_execution):
61 ''' extcap interface tests for ciscodump '''
62 check_extcap_execution("ciscodump")
64 def test_dpauxmon(self, check_extcap_execution):
65 ''' extcap interface tests for dpauxmon '''
66 if not sys.platform.startswith('linux'):
67 pytest.skip('dpauxmon available on Linux only')
68 check_extcap_execution("dpauxmon")
70 # def test_falcodump(self, check_extcap_execution):
71 # ''' extcap interface tests for falcodump '''
72 # check_extcap_execution("falcodump", stratoshark_extcap=True)
74 def test_randpktdump(self, check_extcap_execution):
75 ''' extcap interface tests for randpktdump '''
76 check_extcap_execution("randpktdump")
78 def test_sdjournal(self, check_extcap_execution):
79 ''' extcap interface tests for sdjournal '''
80 if not sys.platform.startswith('linux'):
81 pytest.skip('sdjournal is available on Linux only')
82 check_extcap_execution("sdjournal")
84 def test_sshdig(self, check_extcap_execution):
85 ''' extcap interface tests for sshdig '''
86 check_extcap_execution("sshdig", stratoshark_extcap=True)
88 def test_sshdump(self, check_extcap_execution):
89 ''' extcap interface tests for sshdump '''
90 check_extcap_execution("sshdump")
92 def test_wifidump(self, check_extcap_execution):
93 ''' extcap interface tests for wifidump '''
94 check_extcap_execution("wifidump")
96 def test_udpdump(self, check_extcap_execution):
97 ''' extcap interface tests for udpdump '''
98 check_extcap_execution("udpdump")