13 Test more or less everything.
17 import b2test_utils
as b2u
21 import subprocess
as sp
22 import multiprocessing
as mp
23 import concurrent.futures
as cf
24 import functools
as ft
29 A very simple argument parser.
31 parser = argparse.ArgumentParser(description=__doc__)
32 parser.add_argument(
'-j',
'--jobs',
35 help=
'Number of workers to be used by ProcessPoolExecutor.',
40 def steer_this(steering_file, rawdata_file):
42 Execute the steering file over the given input rawdata file.
44 if 'cosmic' in os.path.basename(rawdata_file):
45 basf2.B2INFO(f
'Running the test using {rawdata_file} as input file.')
46 return sp.call([
'basf2', steering_file, rawdata_file,
'cosmic'])
47 elif 'physics' in os.path.basename(rawdata_file):
48 basf2.B2INFO(f
'Running the test using {rawdata_file} as input file.')
49 return sp.call([
'basf2', steering_file, rawdata_file,
'physics'])
51 basf2.B2INFO(
'Not a "cosmic" neither a "physics" run, skipping it.')
55 if __name__ ==
'__main__':
57 if 'BELLE2_VALIDATION_DATA_DIR' not in os.environ:
58 b2u.skip_test(
'BELLE2_VALIDATION_DATA_DIR environment variable not set, skipping the test.')
60 args = arg_parser().parse_args()
63 num_workers = max(int(mp.cpu_count() / (1. + os.getloadavg()[1])), 1)
65 num_workers = args.jobs
66 basf2.B2INFO(f
'The test will be executed using {num_workers} workers.')
67 num_workers = max(int(mp.cpu_count() / (1. + os.getloadavg()[1])), 1)
69 steering_file = basf2.find_file(
'reconstruction/tests/reco_cdst.py_noexec')
70 rawdata_files = glob.glob(os.environ[
'BELLE2_VALIDATION_DATA_DIR'] +
'/rawdata/*HLT?.*.root')
71 with cf.ProcessPoolExecutor(max_workers=num_workers)
as pool:
72 for result
in pool.map(ft.partial(steer_this, steering_file), rawdata_files):