Revert "drsuapi_dissect_element_DsGetNCChangesCtr6TS_ctr6 dissect_krb5_PAC_NDRHEADERBLOB"
[wireshark-sm.git] / test / suite_unittests.py
blob65abf9bc072c9325f33ce6ce885dbf21eb62d45f
2 # Wireshark tests
3 # By
4 # Gerald Combs <gerald@wireshark.org>
5 # Gilbert Ramirez <gram [AT] alumni.rice.edu>
7 # Ported from a set of Bash scripts which were copyright 2005 Ulf Lamping
9 # SPDX-License-Identifier: GPL-2.0-or-later
11 '''EPAN unit tests'''
13 import subprocess
14 import pytest
17 class TestUnitTests:
18 def test_unit_exntest(self, program, base_env):
19 '''exntest'''
20 subprocess.check_call(program('exntest'), env=base_env)
22 def test_unit_oids_test(self, program, base_env):
23 '''oids_test'''
24 subprocess.check_call(program('oids_test'), env=base_env)
26 def test_unit_reassemble_test(self, program, base_env):
27 '''reassemble_test'''
28 subprocess.check_call(program('reassemble_test'), env=base_env)
30 def test_unit_tvbtest(self, program, base_env):
31 '''tvbtest'''
32 subprocess.check_call(program('tvbtest'), env=base_env)
34 def test_unit_wmem_test(self, program, base_env):
35 '''wmem_test'''
36 subprocess.check_call((program('wmem_test'),
37 '--verbose'
38 ), env=base_env)
40 def test_unit_wscbor_test(self, program, base_env):
41 '''wscbor_test'''
42 subprocess.check_call(program('wscbor_test'), env=base_env)
44 def test_unit_epan(self, program, base_env):
45 '''epan unit tests'''
46 subprocess.check_call((program('test_epan'),
47 '--verbose'
48 ), env=base_env)
50 def test_unit_wsutil(self, program, base_env):
51 '''wsutil unit tests'''
52 subprocess.check_call((program('test_wsutil'),
53 '--verbose'
54 ), env=base_env)
56 def test_unit_fieldcount(self, cmd_tshark, test_env):
57 '''fieldcount'''
58 subprocess.check_call((cmd_tshark, '-G', 'fieldcount'), env=test_env)
60 class Proto:
61 """Data for a protocol."""
62 def __init__(self, line):
63 data = line.split("\t")
64 assert len(data) == 3, "expected 3 columns in %s" % data
65 assert data[0] == "P"
66 self.name = data[1]
67 self.abbrev = data[2]
69 class Field:
70 """Data for a field."""
71 def __init__(self, line):
72 data = line.split("\t")
73 assert len(data) == 8, "expected 8 columns in %s" % data
74 assert data[0] == "F"
75 self.name = data[1]
76 self.abbrev = data[2]
77 self.ftype = data[3]
78 self.parent = data[4]
79 self.base = data[5]
80 self.bitmask = int(data[6],0)
81 self.blurb = data[7]
84 class TestUnitFtSanity:
85 def test_unit_ftsanity(self, cmd_tshark, base_env):
86 """Looks for problems in field type definitions."""
87 tshark_proc = subprocess.run((cmd_tshark, "-G", "fields"),
88 check=True, capture_output=True, encoding='utf-8', env=base_env)
90 lines = tshark_proc.stdout.splitlines()
91 # XXX We don't currently check protos.
92 protos = [Proto(x) for x in lines if x[0] == "P"]
93 fields = [Field(x) for x in lines if x[0] == "F"]
95 err_list = []
96 for field in fields:
97 if field.bitmask != 0:
98 if field.ftype.find("FT_UINT") != 0 and \
99 field.ftype.find("FT_INT") != 0 and \
100 field.ftype != "FT_BOOLEAN" and \
101 field.ftype != "FT_CHAR":
102 err_list.append("%s has a bitmask 0x%x but is type %s" % \
103 (field.abbrev, field.bitmask, field.ftype))
105 assert len(err_list) == 0, 'Found field type errors: \n' + '\n'.join(err_list)