results
- Functions and helpers for result management when working with
TMT has a ‘result:custom’ feature (in test’s main.fmf), which allows us to supply completely custom results as a YAML file, and TMT will use it as-is to represent a result from the test itself, and any results “under” it, effectively allowing a test to report more than 1 result.
Module Contents
- class results.Counter
Bases:
collections.defaultdictdict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s
(key, value) pairs
- dict(iterable) -> new dictionary initialized as if via:
d = {} for k, v in iterable:
d[k] = v
- dict(**kwargs) -> new dictionary initialized with the name=value pairs
in the keyword argument list. For example: dict(one=1, two=2)
- total()
- results.global_counts
- results.global_logs = []
- results.have_atex_api()
Return True if we can report results via ATEX Minitmt natively.
- results.have_tmt_api()
Return True if we can report results via TMT natively.
- results.report_atex(status, name=None, note=None, logs=None, *, partial=False)
- results.report_tmt(status, name=None, note=None, logs=None, *, add_output=True)
- results.report_plain(status, name=None, note=None, logs=None)
- results.report(status, name=None, note=None, logs=None, *, add_output=True)
Report a test result.
‘name’ will be appended to the currently running test name, allowing the test to report one or more sub-results. If empty, result for the test itself is reported.
‘logs’ is a list of file paths (relative to CWD) to be copied or uploaded, and associated with the new result.
‘add_output’ specifies whether to add the test’s own std* console output, as captured by TMT, to the list of logs whenever ‘name’ is empty.
Returns the final ‘status’, potentially modified by the waiving logic.
- results.add_log(*logs)
Add log file(s) to be associated with the main test result as reported by the report_and_exit() function.
The log file(s) will be processed immediately: - For ATEX: uploaded incrementally using report_atex() with partial=True - For TMT: copied to the TMT data directory and stored in global_logs for later upload - For plain: stored in global_logs for later upload
This allows logs to be added incrementally throughout the test, and ensures they’re available even if the test later fails with a traceback.
Multiple logs can be added by calling this function multiple times, or by passing multiple arguments. All accumulated logs will be included in the final report by report_and_exit() except for ATEX which handles this itself.
- results.report_and_exit(status=None, note=None, logs=None)
Report a result for the test itself and exit with 0 or 2, depending on whether there were any failures reported during execution of the test.
Any logs previously added via add_log() will be automatically included. Additional logs can still be passed via the ‘logs’ parameter.