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).
  1. tools/datamasterInit.sh
    1. This script checks the existence of the two wishbone devices needed.
    2. Then the PTP master and slave are synchronized with the host.
    3. Check that saftd runs or start saftd service.
    4. Build the lm32 firmware and upload this to all CPUs. Arguments of the script define which lm32 firmware to use.
    5. Run a simple test.
      This script is tested on ACOPC042 and fel0069.acc.gsi.de. On other hosts the script needs improvements.
  2. tools/datamasterCheck.sh
    1. This script checks the existence of the two wishbone devices needed.
    2. With eb-mon several values of the two wishbone devices are shown.
    3. Check that saftd runs.
    4. 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

  1. Files with unit tests have names starting with test_ and ending with .py.
  2. 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
  1. add schedules
  2. start pattern
  3. run dm-cmd and dm-sched
  4. snoop timing messages into csv files parallel to executing commands
  5. analyse csv files with timing messages
  6. 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.
Topic revision: r2 - 29 Feb 2024, MartinSkorsky
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback