How to run and develop tests for the Datamaster
Run Tests with pytest
The folder
modules/ftm/tests
has a
Makefile
. The important targets are:
all, remote, prepare
. The target
all
runs tests with pytest against a datamaster $DM and a timing receiver $TR0.
Usually these are local. Target
remote
runs tests with pytest against a datamaster
tcp/fel0069.acc.gsi.de
and a timing receiver
dev/wbm1
on
fel0069.acc.gsi.de
. Target
prepare
runs
make
for all the prerequisites in module
ftm
for the tests.
Important: The tests need exclusive access to the datamaster and the timing receiver. Otherwise the schedules and timing messages may be not the ones to test.
Examples:
OPTIONS='--runslow' make
Run all tests against the local datamaster, even those marked with
--runslow
. These test take longer than usual tests.
OPTIONS='--runslow -k test_threadsStartStop' make
Run tests with
test_threadsStartStop
in the file name, the class name or the test method name. In this case it is a file name.
Initialize and Test Status of a Datamaster
There are two bash scripts to initialize and to test a datamaster in a development environment. Development environment
means: the datamaster runs in a separate network (no BOTP, no local PTP master).
-
tools/datamasterInit.sh
- This script checks the existence of the two wishbone devices needed.
- Then the PTP master and slave are synchronized with the host.
- Check that saftd runs or start saftd service.
- Build the lm32 firmware and upload this to all CPUs. Arguments of the script define which lm32 firmware to use.
- Run a simple test.
This script is tested on ACOPC042 and fel0069.acc.gsi.de. On other hosts the script needs improvements.
-
tools/datamasterCheck.sh
- This script checks the existence of the two wishbone devices needed.
- With
eb-mon
several values of the two wishbone devices are shown.
- Check that saftd runs.
- Run a simple test.
This script is tested on ACOPC042 and fel0069.acc.gsi.de. On other hosts the script needs improvements.
Develop Tests with Python and pytest
Naming convention
- Files with unit tests have names starting with test_ and ending with .py.
- Unit tests are in a test method. The name starts with test and is member of a class derived from class DmTestbench in module
dm_testbench
.
Module dm_testbench
The module
dm_testbench
contains methods to
- add schedules
- start pattern
- run dm-cmd and dm-sched
- snoop timing messages into csv files parallel to executing commands
- analyse csv files with timing messages
- analyse the output of
dm-cmd $DM -v
for number of messages per thread
The detailed documentation of the module is in
datamaster-tests.pdf, last section.