From 7fdaeefa6ca8e835ec4c5753058dcca190b4d66f Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 24 Sep 2020 11:33:07 -0400 Subject: [PATCH] tests/tracing: use a base trace type YAML file This patch adds `tests/tracing/support/base.yaml` as a base YAML trace type object for test configuration files to include. `tests/tracing/conftest.py` is changed to add `tests/tracing/support` to the barectf inclusion search directories and to only consider YAML files in `tests/tracing/configs/succeed` (`tests/tracing/support/base.yaml` is not a test). Signed-off-by: Philippe Proulx --- .../succeed/dynamic-array/nested-5-uint8.yaml | 6 +--- .../succeed/dynamic-array/of-double.yaml | 6 +--- .../of-static-array-of-double.yaml | 6 +--- .../dynamic-array/of-static-array-of-str.yaml | 6 +--- .../of-static-array-of-uint8.yaml | 6 +--- .../configs/succeed/dynamic-array/of-str.yaml | 6 +--- .../dynamic-array/of-uint3-middle.yaml | 6 +--- .../succeed/dynamic-array/of-uint3.yaml | 6 +--- .../succeed/dynamic-array/of-uint8.yaml | 6 +--- .../succeed/dynamic-array/zero-len.yaml | 6 +--- .../succeed/static-array/nested-5-uint8.yaml | 6 +--- .../succeed/static-array/of-double.yaml | 6 +--- .../of-static-array-of-double.yaml | 6 +--- .../static-array/of-static-array-of-str.yaml | 6 +--- .../of-static-array-of-uint8.yaml | 6 +--- .../configs/succeed/static-array/of-str.yaml | 6 +--- .../succeed/static-array/of-uint3-middle.yaml | 6 +--- .../succeed/static-array/of-uint3.yaml | 6 +--- .../succeed/static-array/of-uint8.yaml | 6 +--- .../succeed/static-array/zero-len.yaml | 6 +--- tests/tracing/conftest.py | 36 ++++++++++--------- tests/tracing/support/base.yaml | 7 ++++ 22 files changed, 46 insertions(+), 117 deletions(-) create mode 100644 tests/tracing/support/base.yaml diff --git a/tests/tracing/configs/succeed/dynamic-array/nested-5-uint8.yaml b/tests/tracing/configs/succeed/dynamic-array/nested-5-uint8.yaml index f0a0037..808065a 100644 --- a/tests/tracing/configs/succeed/dynamic-array/nested-5-uint8.yaml +++ b/tests/tracing/configs/succeed/dynamic-array/nested-5-uint8.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdint.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/dynamic-array/of-double.yaml b/tests/tracing/configs/succeed/dynamic-array/of-double.yaml index a448732..6dc9a10 100644 --- a/tests/tracing/configs/succeed/dynamic-array/of-double.yaml +++ b/tests/tracing/configs/succeed/dynamic-array/of-double.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdreal.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/dynamic-array/of-static-array-of-double.yaml b/tests/tracing/configs/succeed/dynamic-array/of-static-array-of-double.yaml index fb4ecc0..6766e2f 100644 --- a/tests/tracing/configs/succeed/dynamic-array/of-static-array-of-double.yaml +++ b/tests/tracing/configs/succeed/dynamic-array/of-static-array-of-double.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdreal.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/dynamic-array/of-static-array-of-str.yaml b/tests/tracing/configs/succeed/dynamic-array/of-static-array-of-str.yaml index 1fb0ce4..1e84dc6 100644 --- a/tests/tracing/configs/succeed/dynamic-array/of-static-array-of-str.yaml +++ b/tests/tracing/configs/succeed/dynamic-array/of-static-array-of-str.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdmisc.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/dynamic-array/of-static-array-of-uint8.yaml b/tests/tracing/configs/succeed/dynamic-array/of-static-array-of-uint8.yaml index 8130732..59a92d8 100644 --- a/tests/tracing/configs/succeed/dynamic-array/of-static-array-of-uint8.yaml +++ b/tests/tracing/configs/succeed/dynamic-array/of-static-array-of-uint8.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdint.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/dynamic-array/of-str.yaml b/tests/tracing/configs/succeed/dynamic-array/of-str.yaml index d354bd3..06a99a7 100644 --- a/tests/tracing/configs/succeed/dynamic-array/of-str.yaml +++ b/tests/tracing/configs/succeed/dynamic-array/of-str.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdmisc.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/dynamic-array/of-uint3-middle.yaml b/tests/tracing/configs/succeed/dynamic-array/of-uint3-middle.yaml index 7aee8ab..ae630b3 100644 --- a/tests/tracing/configs/succeed/dynamic-array/of-uint3-middle.yaml +++ b/tests/tracing/configs/succeed/dynamic-array/of-uint3-middle.yaml @@ -26,15 +26,11 @@ trace: type: $include: + - base.yaml - stdint.yaml - stdmisc.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/dynamic-array/of-uint3.yaml b/tests/tracing/configs/succeed/dynamic-array/of-uint3.yaml index 5693c4b..7206dce 100644 --- a/tests/tracing/configs/succeed/dynamic-array/of-uint3.yaml +++ b/tests/tracing/configs/succeed/dynamic-array/of-uint3.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdint.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/dynamic-array/of-uint8.yaml b/tests/tracing/configs/succeed/dynamic-array/of-uint8.yaml index a0716ec..86a754f 100644 --- a/tests/tracing/configs/succeed/dynamic-array/of-uint8.yaml +++ b/tests/tracing/configs/succeed/dynamic-array/of-uint8.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdint.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/dynamic-array/zero-len.yaml b/tests/tracing/configs/succeed/dynamic-array/zero-len.yaml index 211f587..50c7039 100644 --- a/tests/tracing/configs/succeed/dynamic-array/zero-len.yaml +++ b/tests/tracing/configs/succeed/dynamic-array/zero-len.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdint.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/static-array/nested-5-uint8.yaml b/tests/tracing/configs/succeed/static-array/nested-5-uint8.yaml index b364f57..0559c32 100644 --- a/tests/tracing/configs/succeed/static-array/nested-5-uint8.yaml +++ b/tests/tracing/configs/succeed/static-array/nested-5-uint8.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdint.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/static-array/of-double.yaml b/tests/tracing/configs/succeed/static-array/of-double.yaml index a05bf48..2a6e745 100644 --- a/tests/tracing/configs/succeed/static-array/of-double.yaml +++ b/tests/tracing/configs/succeed/static-array/of-double.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdreal.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/static-array/of-static-array-of-double.yaml b/tests/tracing/configs/succeed/static-array/of-static-array-of-double.yaml index ba8dec2..b21fa86 100644 --- a/tests/tracing/configs/succeed/static-array/of-static-array-of-double.yaml +++ b/tests/tracing/configs/succeed/static-array/of-static-array-of-double.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdreal.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/static-array/of-static-array-of-str.yaml b/tests/tracing/configs/succeed/static-array/of-static-array-of-str.yaml index 3310c49..33dbaa3 100644 --- a/tests/tracing/configs/succeed/static-array/of-static-array-of-str.yaml +++ b/tests/tracing/configs/succeed/static-array/of-static-array-of-str.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdmisc.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/static-array/of-static-array-of-uint8.yaml b/tests/tracing/configs/succeed/static-array/of-static-array-of-uint8.yaml index 0371d33..90720c1 100644 --- a/tests/tracing/configs/succeed/static-array/of-static-array-of-uint8.yaml +++ b/tests/tracing/configs/succeed/static-array/of-static-array-of-uint8.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdint.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/static-array/of-str.yaml b/tests/tracing/configs/succeed/static-array/of-str.yaml index 937e51d..fb0a3bd 100644 --- a/tests/tracing/configs/succeed/static-array/of-str.yaml +++ b/tests/tracing/configs/succeed/static-array/of-str.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdmisc.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/static-array/of-uint3-middle.yaml b/tests/tracing/configs/succeed/static-array/of-uint3-middle.yaml index 1061d2a..61fcc5f 100644 --- a/tests/tracing/configs/succeed/static-array/of-uint3-middle.yaml +++ b/tests/tracing/configs/succeed/static-array/of-uint3-middle.yaml @@ -26,15 +26,11 @@ trace: type: $include: + - base.yaml - stdint.yaml - stdmisc.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/static-array/of-uint3.yaml b/tests/tracing/configs/succeed/static-array/of-uint3.yaml index 23e177b..f9a4df6 100644 --- a/tests/tracing/configs/succeed/static-array/of-uint3.yaml +++ b/tests/tracing/configs/succeed/static-array/of-uint3.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdint.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/static-array/of-uint8.yaml b/tests/tracing/configs/succeed/static-array/of-uint8.yaml index 3a85a5b..13f2fa7 100644 --- a/tests/tracing/configs/succeed/static-array/of-uint8.yaml +++ b/tests/tracing/configs/succeed/static-array/of-uint8.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdint.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/configs/succeed/static-array/zero-len.yaml b/tests/tracing/configs/succeed/static-array/zero-len.yaml index 127a97e..62fc5b0 100644 --- a/tests/tracing/configs/succeed/static-array/zero-len.yaml +++ b/tests/tracing/configs/succeed/static-array/zero-len.yaml @@ -26,14 +26,10 @@ trace: type: $include: + - base.yaml - stdint.yaml - native-byte-order: le data-stream-types: default: - $is-default: true - $features: - packet: - discarded-event-records-counter-snapshot-field-type: false event-record-types: ev: payload-field-type: diff --git a/tests/tracing/conftest.py b/tests/tracing/conftest.py index 331b39b..4477b7e 100644 --- a/tests/tracing/conftest.py +++ b/tests/tracing/conftest.py @@ -37,36 +37,38 @@ def pytest_collect_file(parent, path): # not a YAML file: cancel return - # At the end of this loop, if `path` is + # If `path` is # `/home/jo/barectf/tests/tracing/configs/succeed/static-array/of-str.yaml`, # for example, then `elems` is: # - # * `of-str.yaml` - # * `static-array` # * `succeed` + # * `static-array` + # * `of-str.yaml` path_str = str(path) - elems = [] - - while True: - elem = os.path.basename(path_str) - - if elem == 'configs': - break + elems = [os.path.basename(path_str)] + cat_dir = os.path.dirname(path_str) + elems.append(os.path.basename(cat_dir)) + succeed_dir = os.path.dirname(cat_dir) + elems.append(os.path.basename(succeed_dir)) + configs_dir = os.path.dirname(succeed_dir) + + if os.path.basename(succeed_dir) != 'succeed' or os.path.basename(configs_dir) != 'configs': + # not a YAML configuration test + return - elems.append(elem) - path_str = os.path.dirname(path_str) + elems = list(reversed(elems)) # create C source, expectation file, and support directory paths - base_dir = os.path.dirname(path_str) - base_name = elems[0].replace(yaml_ext, '') - rel_dir = os.path.join(*list(reversed(elems[1:]))) + base_dir = os.path.dirname(configs_dir) + base_name = elems[-1].replace(yaml_ext, '') + rel_dir = os.path.join(*elems[:-1]) src_path = os.path.join(*[base_dir, 'src', rel_dir, f'{base_name}.c']) data_expect_path = os.path.join(*([base_dir, 'expect', rel_dir, f'{base_name}.data.expect'])) metadata_expect_path = os.path.join(*([base_dir, 'expect', rel_dir, f'{base_name}.metadata.expect'])) support_dir_path = os.path.join(base_dir, 'support') # create a unique test name - name = f'test-{"-".join(reversed(elems))}'.replace(yaml_ext, '') + name = f'test-{"-".join(elems)}'.replace(yaml_ext, '') # create the file node return _YamlFile.from_parent(parent, fspath=path, src_path=src_path, @@ -108,7 +110,7 @@ class _YamlItem(pytest.Item): # create barectf configuration with open(self.fspath) as f: - cfg = barectf.configuration_from_file(f) + cfg = barectf.configuration_from_file(f, inclusion_directories=[self._support_dir_path]) # generate and write C code files cg = barectf.CodeGenerator(cfg) diff --git a/tests/tracing/support/base.yaml b/tests/tracing/support/base.yaml new file mode 100644 index 0000000..6c56d9e --- /dev/null +++ b/tests/tracing/support/base.yaml @@ -0,0 +1,7 @@ +native-byte-order: le +data-stream-types: + default: + $is-default: true + $features: + packet: + discarded-event-records-counter-snapshot-field-type: false -- 2.34.1