12Check that all the classdef versions and class checksums are consistent to prevent accidental mismatch:
14If one forgets to increase the ClassDef but the streamer info checksum changes this will trigger a test failure. We can distuingish
161. ClassDef version changed unnecessary
172. forgot to change ClassDef
22from b2test_utils
import get_object_with_name, get_streamer_checksums
26 'Belle2::Const::DetectorSet': (1, 1222446098),
27 'Belle2::ECLCluster': (15, 835771092),
28 'Belle2::EventLevelClusteringInfo': (4, 1906636092),
29 'Belle2::EventLevelTrackingInfo': (2, 1667284927),
30 'Belle2::EventMetaData': (4, 2999207747),
31 'Belle2::FileMetaData': (11, 3436141238),
32 'Belle2::KLMCluster': (3, 1419175697),
33 'Belle2::KlId': (2, 230716330),
34 'Belle2::PIDLikelihood': (4, 4027053936),
35 'Belle2::RelationContainer': (1, 1725678837),
36 'Belle2::RelationElement': (1, 1883389510),
37 'Belle2::RelationsInterface<TObject>': (0, 3862127315),
38 'Belle2::SoftwareTriggerResult': (5, 241059817),
39 'Belle2::TRGSummary': (7, 1658421299),
40 'Belle2::Track': (6, 327743743),
41 'Belle2::TrackFitResult': (10, 1213379524),
42 'Belle2::V0': (4, 422320450),
53 "EventLevelTrackingInfo",
56 "EventLevelClusteringInfo",
60 "SoftwareTriggerResult",
63if __name__ ==
"__main__":
66 objects = [get_object_with_name(object_name)()
for object_name
in OBJECT_NAMES]
73 found = get_streamer_checksums(objects)
75 if 'TObject' in found:
79 print(
"found_checksums = {\n " +
"\n ".join(f
"{k!r}: {v!r}," for k, v
in sorted(found.items())) +
"\n}")
80 for key, (version, checksum)
in found.items():
81 if key
not in EXPECTED_CHECKSUMS:
82 problems.append(f
"There is no {key} in the checksum dictionary!")
89 expected_version, expected_checksum = EXPECTED_CHECKSUMS[key]
91 if expected_version != version
and expected_checksum == checksum:
92 problems.append(f
"The version for {key} has changed (expected={expected_version}, found={version}) "
93 f
"while the checksum has not. This probably means the ClassDef version was increased unnecessarily. "
94 f
"If this is intentional please update the expected version in this test")
95 elif expected_version == version
and expected_checksum != checksum:
96 problems.append(f
"The checksum for {key} has changed (expected={expected_checksum}, found={checksum}) "
97 f
"while the version has not. This probably means you forgot to increase the ClassDef version "
98 f
"after changing the class. Please update the ClassDef version and the expected values in this test")
99 elif expected_version != version
and expected_checksum != checksum:
100 problems.append(f
"The version and checksum for {key} have changed, (expected version={expected_version}, "
101 f
"checksum={expected_checksum}, found version={version}, checksum={checksum}). "
102 f
"Please update the expected values")
103 del EXPECTED_CHECKSUMS[key]
105 for remaining, (version, checksum)
in EXPECTED_CHECKSUMS.items():
106 problems.append(f
"Additional class expected but not needed: {remaining} (version {version}, checksum {checksum})")
109 print(
"Check finished")
111 problems =
"\n\t * ".join([
""] + problems)
112 print(
"Check failed: Most likely a mdst class has been modified and the list of expected checksums needs to be adjusted:",