From c5d4db7a5b271f013e93540e16998beb01fd677d Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 23 Oct 2023 22:12:24 -0400 Subject: [PATCH] tests: run some Python tests with CTF 1 and CTF 2 traces The goal of this patch is to run as many Python-based tests that use CTF traces against both CTF 1 and CTF 2. I would like to minimize the amount of changes and boilerplate necessary in each individual test. I've taken the approach to add a decorator named `test_all_ctf_versions` to the test classes, inspired by the parameterized Python package [1]. Unlike the decorators, from parameterized, our decorator is hardcoded for what we need. When applied to a class, it makes two copies of all `test_*` methods of that class, suffixed with `_ctf_1` and `_ctf_2`, and removes the original method. The two new methods are in fact wrapped in a small wrapper that sets the `_ctf_version` attribute on the class (with the value 1 or 2) for the duration of the method call. The changes necessary in the test themselves are to make the test trace paths dependent on `self._ctf_version`, instead of hard-coded. [1] https://pypi.org/project/parameterized/ Change-Id: Idef27183db6287630e63260395d255e68da2a4c3 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/8737 Reviewed-by: Philippe Proulx Tested-by: jenkins Reviewed-on: https://review.lttng.org/c/babeltrace/+/12755 --- .../2/intersection/3eventsintersect/metadata | 233 ++++++++++++++++++ .../3eventsintersect/test_stream_0 | Bin 0 -> 640 bytes .../3eventsintersect/test_stream_1 | Bin 0 -> 384 bytes .../query/test_query_support_info.py | 113 ++++----- .../src.ctf.fs/query/test_query_trace_info.py | 49 +++- tests/utils/python/test_all_ctf_versions.py | 59 +++++ 6 files changed, 386 insertions(+), 68 deletions(-) create mode 100644 tests/data/ctf-traces/2/intersection/3eventsintersect/metadata create mode 100644 tests/data/ctf-traces/2/intersection/3eventsintersect/test_stream_0 create mode 100644 tests/data/ctf-traces/2/intersection/3eventsintersect/test_stream_1 create mode 100644 tests/utils/python/test_all_ctf_versions.py diff --git a/tests/data/ctf-traces/2/intersection/3eventsintersect/metadata b/tests/data/ctf-traces/2/intersection/3eventsintersect/metadata new file mode 100644 index 00000000..a223ab1b --- /dev/null +++ b/tests/data/ctf-traces/2/intersection/3eventsintersect/metadata @@ -0,0 +1,233 @@ +{ + "type": "preamble", + "uuid": [ + 122, + 254, + 143, + 190, + 121, + 184, + 79, + 106, + 187, + 199, + 208, + 199, + 130, + 231, + 221, + 175 + ], + "version": 2 +} +{ + "environment": { + "host": "sinkpad" + }, + "packet-header-field-class": { + "member-classes": [ + { + "field-class": { + "alignment": 8, + "byte-order": "big-endian", + "length": 32, + "roles": [ + "packet-magic-number" + ], + "type": "fixed-length-unsigned-integer" + }, + "name": "magic" + }, + { + "field-class": { + "length": 16, + "roles": [ + "metadata-stream-uuid" + ], + "type": "static-length-blob" + }, + "name": "uuid" + }, + { + "field-class": { + "alignment": 8, + "byte-order": "big-endian", + "length": 32, + "roles": [ + "data-stream-class-id" + ], + "type": "fixed-length-unsigned-integer" + }, + "name": "stream_id" + } + ], + "minimum-alignment": 8, + "type": "structure" + }, + "type": "trace-class", + "uid": "7afe8fbe-79b8-4f6a-bbc7-d0c782e7ddaf" +} +{ + "description": "This is a test clock", + "frequency": 1000000000, + "id": "test_clock", + "offset-from-origin": { + "cycles": 0, + "seconds": 13515309 + }, + "origin": "unix-epoch", + "precision": 10, + "type": "clock-class" +} +{ + "default-clock-class-id": "test_clock", + "event-record-header-field-class": { + "member-classes": [ + { + "field-class": { + "alignment": 8, + "byte-order": "big-endian", + "length": 32, + "roles": [ + "event-record-class-id" + ], + "type": "fixed-length-unsigned-integer" + }, + "name": "id" + }, + { + "field-class": { + "alignment": 8, + "byte-order": "big-endian", + "length": 64, + "roles": [ + "default-clock-timestamp" + ], + "type": "fixed-length-unsigned-integer" + }, + "name": "timestamp" + } + ], + "minimum-alignment": 8, + "type": "structure" + }, + "packet-context-field-class": { + "member-classes": [ + { + "field-class": { + "alignment": 8, + "byte-order": "big-endian", + "length": 64, + "roles": [ + "default-clock-timestamp" + ], + "type": "fixed-length-unsigned-integer" + }, + "name": "timestamp_begin" + }, + { + "field-class": { + "alignment": 8, + "byte-order": "big-endian", + "length": 64, + "roles": [ + "packet-end-default-clock-timestamp" + ], + "type": "fixed-length-unsigned-integer" + }, + "name": "timestamp_end" + }, + { + "field-class": { + "alignment": 8, + "byte-order": "big-endian", + "length": 64, + "roles": [ + "packet-content-length" + ], + "type": "fixed-length-unsigned-integer" + }, + "name": "content_size" + }, + { + "field-class": { + "alignment": 8, + "byte-order": "big-endian", + "length": 64, + "roles": [ + "packet-total-length" + ], + "type": "fixed-length-unsigned-integer" + }, + "name": "packet_size" + }, + { + "field-class": { + "alignment": 8, + "byte-order": "big-endian", + "length": 64, + "roles": [ + "discarded-event-record-counter-snapshot" + ], + "type": "fixed-length-unsigned-integer" + }, + "name": "events_discarded" + }, + { + "field-class": { + "byte-order": "big-endian", + "length": 64, + "roles": [ + "packet-sequence-number" + ], + "type": "fixed-length-unsigned-integer" + }, + "name": "packet_seq_num" + } + ], + "minimum-alignment": 8, + "type": "structure" + }, + "type": "data-stream-class" +} +{ + "name": "dummy_event", + "payload-field-class": { + "member-classes": [ + { + "field-class": { + "byte-order": "big-endian", + "length": 32, + "type": "fixed-length-unsigned-integer" + }, + "name": "dummy_value" + }, + { + "field-class": { + "byte-order": "big-endian", + "length": 32, + "type": "fixed-length-unsigned-integer" + }, + "name": "tracefile_id" + }, + { + "field-class": { + "byte-order": "big-endian", + "length": 32, + "type": "fixed-length-unsigned-integer" + }, + "name": "packet_begin" + }, + { + "field-class": { + "byte-order": "big-endian", + "length": 32, + "type": "fixed-length-unsigned-integer" + }, + "name": "packet_end" + } + ], + "type": "structure" + }, + "type": "event-record-class" +} diff --git a/tests/data/ctf-traces/2/intersection/3eventsintersect/test_stream_0 b/tests/data/ctf-traces/2/intersection/3eventsintersect/test_stream_0 new file mode 100644 index 0000000000000000000000000000000000000000..6a69e445f8745b2f65fd28c702565ec74067c134 GIT binary patch literal 640 zcmX^3NB&^dzy5udJN&bDAHQ(C>G|FD446O!BE+l!p;<6hAVjzjOfU$yc1rn2h{hCmvHV_)8{Y*$kY600WK1e@QFOmu*CIS0x zp-KZFG*0`Ok&N^JvSASf(ht>(qymXa!2Up}(i8}d(|(wJAZ0;7%nDJ@0MZZD3l%}5 E0H!ENZvX%Q literal 0 HcmV?d00001 diff --git a/tests/data/ctf-traces/2/intersection/3eventsintersect/test_stream_1 b/tests/data/ctf-traces/2/intersection/3eventsintersect/test_stream_1 new file mode 100644 index 0000000000000000000000000000000000000000..0cf1404de821214b7cb277b1415436e16983d28d GIT binary patch literal 384 zcmX^3NB&^dzy5udJN&bDAHQ(C>G|FD3<%%`Wkx}0W(5e%0u{zexdTO+ftV49LHeP3 zfh;WGAb$I!p<41FG*0_LcELa@kiiDTATf}Bs9qoo3m{;BK2%EugvMz<6Oz#dKsGxN OgX{