diff --git a/bdaq53/tests/test_software/base/test_scan_state_machine.py b/bdaq53/tests/test_software/base/test_scan_state_machine.py index 5903f206ffb558af062ab82660e67ac78795b416..d385ad6bf55c27a1c936c518ed22114fcccf1018 100644 --- a/bdaq53/tests/test_software/base/test_scan_state_machine.py +++ b/bdaq53/tests/test_software/base/test_scan_state_machine.py @@ -1,17 +1,23 @@ -''' Script to check that the scan API - follows the intended behavior. +''' Script to check that the scan base state mashine follows the intended behavior. ''' +import copy +import os import shutil import unittest +import yaml from mock import MagicMock import numpy as np import tables as tb +import bdaq53 from bdaq53.tests import bdaq_mock +bdaq53_path = os.path.dirname(bdaq53.__file__) +bench_config = os.path.abspath(os.path.join(bdaq53_path, 'testbench.yaml')) + scan_configuration = { 'start_column': 100, 'stop_column': 400, @@ -63,6 +69,10 @@ class TestScanStateMachine(unittest.TestCase): cls.TestScanParallel = create_test_scan(parallel=True) cls.TestScanMasking = create_test_scan(mask_shifts=True) + # Load standard bench config to change in test cases + with open(bench_config) as f: + cls.bench_config = yaml.full_load(f) + @classmethod def tearDownClass(cls): cls.bhm.stop() @@ -168,8 +178,17 @@ class TestScanStateMachine(unittest.TestCase): ''' Test that exceptions during scan steps are raised but always call close() https://gitlab.cern.ch/silab/bdaq53/-/issues/391 + + Use double chip module. ''' + bench_config = copy.deepcopy(self.bench_config) + # Add additional chip to module 0 + bench_config['modules']['module_0']['chip_1'] = copy.deepcopy(bench_config['modules']['module_0']['chip_0']) + bench_config['modules']['module_0']['chip_1']['chip_sn'] = '0x0002' + bench_config['modules']['module_0']['chip_1']['receiver'] = "rx1" + bench_config['modules']['module_0']['chip_1']['send_data'] = "tcp://127.0.0.1:5501" + class CustomError(Exception): pass @@ -178,7 +197,7 @@ class TestScanStateMachine(unittest.TestCase): # Test exception handling during configure step with self.assertRaises(CustomError): - scan = self.TestScan(scan_config=scan_configuration) + scan = self.TestScan(bench_config=bench_config, scan_config=scan_configuration) scan.close_orig = scan.close # store original close scan.close = MagicMock(wraps=scan.close_orig) scan._configure = raise_exception # create exception during configure @@ -188,7 +207,7 @@ class TestScanStateMachine(unittest.TestCase): # Test exception handling during scan step with self.assertRaises(CustomError): - scan = self.TestScan(scan_config=scan_configuration) + scan = self.TestScan(bench_config=bench_config, scan_config=scan_configuration) scan.close_orig = scan.close # store original close scan.close = MagicMock(wraps=scan.close_orig) scan._scan = raise_exception # create exception during scan @@ -199,7 +218,7 @@ class TestScanStateMachine(unittest.TestCase): # Test exception handling during analyze step with self.assertRaises(CustomError): - scan = self.TestScan(scan_config=scan_configuration) + scan = self.TestScan(bench_config=bench_config, scan_config=scan_configuration) scan.close_orig = scan.close # store original close scan.close = MagicMock(wraps=scan.close_orig) scan._analyze = raise_exception # create exception during analysis