The test framework supports two ways to discover tests in a suite:
In general, the test framework will search the files inside the suite directory and add a Simics test for each file matching the pattern "s-*.py", the test name will be named after the script file, with the extension stripped.
If the suite directory contains a tests.py file, the framework imports
this file as a Python module and runs the tests function defined within
in order to add tests to the suite. The signature of this function is:
def tests(suite).
The suite parameter supports the following methods:
add_test(name, function, args)
Add a Python test named name, which runs the function with the
optional tuple of arguments in args.
add_simics_test(script, timeout=120, name=None, extra_args=[], namesuffix="")
Add a Simics test which runs script. You can specify a timeout measured
in seconds with timeout. The name of the test defaults to the name of
the script, with the extension stripped, but can be overridden with
name. extra_args is a list of extra command line arguments to pass to
Simics before the script is run. namesuffix is added to the end of the
test name, this can be used to distinguish runs of the same test script
with different arguments. Simics is run in batch mode and with the
--stop-on-error, --wdeprecated and --deprecations-as-errors flags.
The test should signal test failures by raising an exception, or exiting Simics with a non zero exit code. There are support APIs for testing documented in the API Reference Manual.
add_simics_tests(pattern, timeout=120, extra_args=[], namesuffix="")
Add a Simics test for each file in the suite directory which matches
pattern. This pattern is a glob. timeout, extra_args and
namesuffix are passed to add_simics_test for each test.
set_suite_setup(setup)
set a function to be run before the tests in the suite to perform setup
actions. The function should be callable without any arguments, and its
result is ignored.
set_suite_teardown(teardown)
set a function to be run after the tests in the suite to perform cleanup
actions. The function should be callable without any arguments, and its
result is ignored.