tests: add `src.ctf.fs` single field testing framework
This patch adds a framework to test the decoding of single CTF 1.8
fields by a `src.ctf.fs` component.
Single CTF 1.8 field tests reside as moultipart documents (see
`tests/utils/python/moultipart.py`) in
`tests/data/plugins/src.ctf.fs/field/ctf-1`.
The new `test-field.sh` script does the following, for each `pass-*.mp`
file found in `tests/data/plugins/src.ctf.fs/field/ctf-1`:
1. Creates a temporary directory TD to hold a CTF 1.8 trace (`TD/trace`)
and an expectation file (`TD/expect`).
2. Runs `data_from_mp.py` on the moultipart document, also passing TD.
This script splits the moultipart document to produce `TD/trace` and
`TD/expect`. The expected parts are, in this order:
a) A TSDL field class (metadata), without any field name, for
example:
integer { size = 32; byte_order = be; }
If you need to test the decoding of an array field, you may use
`@` in this part to indicate to `data_from_mp.py` where the
field name goes, for example:
string @[23]
b) A Normand [1] text representing the exact data of an instance
of a).
c) What you expect the `sink.test-text.single` component to print
when it receives an event message containing what a `src.ctf.fs`
component decoded from `TD/trace`.
`sink.test-text.single` prints exactly the value of b) with a
YAML-like format.
3. Runs something like this, keeping the standard output text:
$ babeltrace2 -c sink.test-text.single "TD/trace"
4. Compares the result of step 3 with `TD/expect` using bt_diff().
Now it becomes easy to test regular and corner cases of our CTF 1.8
decoding by adding new files to
`tests/data/plugins/src.ctf.fs/field/ctf-1`.
As initial examples, `tests/data/plugins/src.ctf.fs/field/ctf-1`
contains a few single field tests already.
Philippe changes:
• Made some style adjustments to the original patch.
• Using `mktemp -d` instead of `mktemp --directory` because macOS
doesn't seem to know the latter.
• In `utils.sh`, changed bt_diff() to use the new bt_remove_cr_inline()
to remove CR characters from both files because this is the first time
the test generates both files.
Leaving bt_remove_cr() as is because another test uses it directly.
• In the _print_field() function of `bt_plugin_test_text.py`:
‣ Changed parts of the strategy to fix some rendering bugs.
‣ Using int() for an integer field to avoid printing enum. labels.
‣ Added the empty structure field special case.
‣ Added comments with output examples.
• In `data_from_mp.py`:
‣ Added lots of useful TSDL type aliases available to any CTF 1
single field test.
‣ Made the default Normand byte order little-endian since it's also
the default TSDL byte order in _make_ctf_1_metadata().
• In `test-field.sh`, using a hard-coded test count.
See the Gerrit discussion [2] for the rationale.
• Added more initial tests in
`tests/data/plugins/src.ctf.fs/field/ctf-1`.
[1]: https://github.com/efficios/normand
[2]: https://review.lttng.org/c/babeltrace/+/11149
Change-Id: I7539b46d49200b5e75fe3525401b47b8ff418f6c
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11149
Tested-by: jenkins <jenkins@lttng.org>
12 files changed:
This page took 0.032168 seconds and 4 git commands to generate.