From b8ed4dfd586f618d73e7faec1f8c7f4af30200a2 Mon Sep 17 00:00:00 2001 From: DavidLP <pohl@physik.uni-bonn.de> Date: Mon, 16 Nov 2020 17:32:21 +0100 Subject: [PATCH] ENH: make all meta scans work --- .../test_software/scans/test_meta_scans.py | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/bdaq53/tests/test_software/scans/test_meta_scans.py b/bdaq53/tests/test_software/scans/test_meta_scans.py index 94b6aad94..1f2061c03 100644 --- a/bdaq53/tests/test_software/scans/test_meta_scans.py +++ b/bdaq53/tests/test_software/scans/test_meta_scans.py @@ -37,7 +37,7 @@ def _run_meta_scan(script): def _scan_loggers(names): loggers = [] - # Catch scan output to check for errors reported + # Catch scan output to check for reported errors for name in names: scan_logger = logging.getLogger(name) scan_log_handler = utils.MockLoggingHandler(level='DEBUG') @@ -66,6 +66,8 @@ class TestMetaScans(unittest.TestCase): # Use hardware mocks to be able to test without hardware cls.bhm = bdaq_mock.BdaqMock(n_chips=2) + # Speed up testing time drastically, by not calling mask shifting + cls.bhm.patch_function('bdaq53.chips.rd53a.RD53AMaskObject.update') cls.bhm.start() shutil.copyfile(bench_config, bench_config + '~') # store original @@ -85,13 +87,13 @@ class TestMetaScans(unittest.TestCase): @classmethod def tearDownClass(cls): cls.bhm.stop() + shutil.move(bench_config + '~', bench_config) # restore original @classmethod def tearDown(cls): # Reset messages after each test cls.analysis_log_handler.reset() shutil.rmtree('output_data', ignore_errors=True) # always delete output from previous scan - shutil.move(bench_config + '~', bench_config) # restore original def check_scan_success(self, scan_log_messages): ''' Check the log output if scan was successfull ''' @@ -102,7 +104,7 @@ class TestMetaScans(unittest.TestCase): return True def test_meta_threshold_tuning(self): - script = os.path.join(bdaq53_path, 'scans', 'scan_digital.py') # meta_tune_threshold.py + script = os.path.join(bdaq53_path, 'scans', 'meta_tune_threshold.py') loggers = _scan_loggers(names=['GDACTuning', 'TDACTuning', 'NoiseOccScan', 'StuckPixelScan', 'NoiseOccScan', 'ThresholdScan']) _run_meta_scan(script) @@ -110,6 +112,36 @@ class TestMetaScans(unittest.TestCase): print(scan_log_messages['info']) self.assertTrue(self.check_scan_success(scan_log_messages)) + def test_meta_tot_and_threshold_tuning(self): + script = os.path.join(bdaq53_path, 'scans', 'meta_tune_tot_and_threshold.py') + loggers = _scan_loggers(names=['GDACTuning', 'TDACTuning', 'TotTuning', 'NoiseOccScan', 'StuckPixelScan', 'NoiseOccScan', 'ThresholdScan']) + _run_meta_scan(script) + + for scan_log_messages in loggers: + print(scan_log_messages['info']) + self.assertTrue(self.check_scan_success(scan_log_messages)) + + def test_meta_merged_bumps(self): + script = os.path.join(bdaq53_path, 'scans', 'meta_scan_merged_bumps.py') + loggers = _scan_loggers(names=['GDACTuning', 'TDACTuning', 'MergedBumpsScan']) + _run_meta_scan(script) + + for scan_log_messages in loggers: + self.assertTrue(self.check_scan_success(scan_log_messages)) + + def test_meta_disconnected_bumps_threshold(self): + script = os.path.join(bdaq53_path, 'scans', 'meta_scan_disconnected_bumps_threshold.py') + loggers = _scan_loggers(names=['GDACTuning', 'TDACTuning', 'BumpConnThrShScan']) + + with self.assertRaises(Exception): # no periphery defined + _run_meta_scan(script) + + for i, scan_log_messages in enumerate(loggers): + if i < 2: + self.assertTrue(self.check_scan_success(scan_log_messages)) + else: # BumpConnThrShScan logger + self.assertTrue('Scan failed!' in scan_log_messages['error']) + if __name__ == '__main__': unittest.main() -- GitLab