Belle II Software  release-06-01-15
klm_tools.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 """
13 Test the klm tools.
14 """
15 
16 import os
17 import glob
18 import subprocess as sp
19 
20 import basf2
21 import b2test_utils as b2u
22 import validation_gt as vgt
23 
24 if __name__ == '__main__':
25 
26  # Test b2klm-create-dqm (it also tests b2klm-mask-dqm and b2klm-execute-masking)
27  if 'BELLE2_VALIDATION_DATA_DIR' not in os.environ:
28  # Silently skip the test, otherwise the test fails on the buildbot.
29  pass
30  else:
31  globaltags = ' '.join(vgt.get_validation_globaltags())
32  input_files = glob.glob(os.environ['BELLE2_VALIDATION_DATA_DIR'] + '/rawdata/*HLT?.*.root')
33  input_files.sort(reverse=True)
34  with b2u.clean_working_directory():
35  assert(0 == sp.call(['b2klm-create-dqm', '-i', f'{basf2.find_file(input_files[0])}', '-n', '100',
36  '--prepend_gt'] + vgt.get_validation_globaltags(), stdout=sp.DEVNULL))
37 
38  # Test b2klm-numberToIndex
39  assert(0 == sp.call(['b2klm-numberToIndex', '20', '50020']))
40 
41  # Test b2klm-indexToNumber
42  assert(0 == sp.call(['b2klm-indexToNumber', '11489', '21997']))