diff --git a/.gitignore b/.gitignore index 2c30abf..d5c6496 100644 --- a/.gitignore +++ b/.gitignore @@ -201,3 +201,8 @@ FakesAssemblies/ # Visual Studio 6 workspace options file *.opt .project + +__pycache__/ +*.py[cod] +*$py.class +test-reports/ diff --git a/Makefile b/Makefile index 19c9068..1b3b814 100644 --- a/Makefile +++ b/Makefile @@ -29,3 +29,6 @@ iocBoot_DEPEND_DIRS += $(filter %App,$(DIRS)) # Add any additional dependency rules here: include $(TOP)/configure/RULES_TOP + +ioctests: + .\system_tests\run_tests.bat diff --git a/system_tests/__init__.py b/system_tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/system_tests/run_tests.bat b/system_tests/run_tests.bat new file mode 100644 index 0000000..65ab1d6 --- /dev/null +++ b/system_tests/run_tests.bat @@ -0,0 +1,10 @@ +@echo off +setlocal +REM Run this directory's tests using the IOC Testing Framework + +call "%~dp0..\..\..\..\config_env.bat" + +REM Command line arguments always passed to the test script +SET ARGS=--test_and_emulator %~dp0 +call %PYTHON3% -u "%EPICS_KIT_ROOT%\support\IocTestFramework\master\run_tests.py" %ARGS% %* +IF %ERRORLEVEL% NEQ 0 EXIT /b %ERRORLEVEL% diff --git a/system_tests/tests/__init__.py b/system_tests/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/system_tests/tests/mk3chopper.py b/system_tests/tests/mk3chopper.py new file mode 100644 index 0000000..e1bb9ec --- /dev/null +++ b/system_tests/tests/mk3chopper.py @@ -0,0 +1,50 @@ +import unittest + +from utils.channel_access import ChannelAccess +from utils.ioc_launcher import IOCRegister, get_default_ioc_dir +from utils.test_modes import TestModes +from utils.testing import skip_if_devsim + +DEVICE_PREFIX = "MK3CHOPR_01" + +IOCS = [ + { + "name": DEVICE_PREFIX, + "directory": get_default_ioc_dir("MK3CHOPR"), + "macros": { + "NUM_CHANNELS": 1 + }, + }, +] + + +TEST_MODES = [TestModes.RECSIM, TestModes.DEVSIM] + + +class Mk3chopperTests(unittest.TestCase): + + # Remote access modes + LOCAL = "LOCAL" + REMOTE = "REMOTE" + COMP_MODE_PV = "COMP:MODE" + + def setUp(self): + self._ioc = IOCRegister.get_running(DEVICE_PREFIX) + # Comp mode is on a slow 10s read. Needs a longer timeout than default + self.ca = ChannelAccess(device_prefix=DEVICE_PREFIX, default_timeout=30) + self.ca.assert_that_pv_exists(self.COMP_MODE_PV) + + def test_WHEN_ioc_is_in_remote_mode_THEN_it_has_no_alarm(self): + # In RECSIM, switch to remote explicitly. DEVSIM can only have remote mode so no switch needed + if IOCRegister.uses_rec_sim: + # Bug in CA channel. Reports invalid alarm severity if you set enum directly + self.ca.set_pv_value("SIM:{}.VAL".format(self.COMP_MODE_PV), 1) + self.ca.assert_that_pv_is(self.COMP_MODE_PV, self.REMOTE) + self.ca.assert_that_pv_alarm_is(self.COMP_MODE_PV, ChannelAccess.Alarms.NONE) + + @skip_if_devsim("Can't switch to local mode in DEVSIM") + def test_WHEN_ioc_is_in_local_mode_THEN_it_has_a_major_alarm(self): + # Bug in CA channel. Reports invalid alarm severity if you set enum directly + self.ca.set_pv_value("SIM:{}.VAL".format(self.COMP_MODE_PV), 0) + self.ca.assert_that_pv_is(self.COMP_MODE_PV, self.LOCAL) + self.ca.assert_that_pv_alarm_is(self.COMP_MODE_PV, ChannelAccess.Alarms.MAJOR)