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
18 def test_unit_exntest(self
, program
, base_env
):
20 subprocess
.check_call(program('exntest'), env
=base_env
)
22 def test_unit_oids_test(self
, program
, base_env
):
24 subprocess
.check_call(program('oids_test'), env
=base_env
)
26 def test_unit_reassemble_test(self
, program
, base_env
):
28 subprocess
.check_call(program('reassemble_test'), env
=base_env
)
30 def test_unit_tvbtest(self
, program
, base_env
):
32 subprocess
.check_call(program('tvbtest'), env
=base_env
)
34 def test_unit_wmem_test(self
, program
, base_env
):
36 subprocess
.check_call((program('wmem_test'),
40 def test_unit_wscbor_test(self
, program
, base_env
):
42 subprocess
.check_call(program('wscbor_test'), env
=base_env
)
44 def test_unit_epan(self
, program
, base_env
):
46 subprocess
.check_call((program('test_epan'),
50 def test_unit_wsutil(self
, program
, base_env
):
51 '''wsutil unit tests'''
52 subprocess
.check_call((program('test_wsutil'),
56 def test_unit_fieldcount(self
, cmd_tshark
, test_env
):
58 subprocess
.check_call((cmd_tshark
, '-G', 'fieldcount'), env
=test_env
)
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
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
80 self
.bitmask
= int(data
[6],0)
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"]
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
)