tests/tracing: use a base trace type YAML file
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 24 Sep 2020 15:33:07 +0000 (11:33 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 24 Sep 2020 15:33:07 +0000 (11:33 -0400)
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 <eeppeliteloop@gmail.com>
22 files changed:
tests/tracing/configs/succeed/dynamic-array/nested-5-uint8.yaml
tests/tracing/configs/succeed/dynamic-array/of-double.yaml
tests/tracing/configs/succeed/dynamic-array/of-static-array-of-double.yaml
tests/tracing/configs/succeed/dynamic-array/of-static-array-of-str.yaml
tests/tracing/configs/succeed/dynamic-array/of-static-array-of-uint8.yaml
tests/tracing/configs/succeed/dynamic-array/of-str.yaml
tests/tracing/configs/succeed/dynamic-array/of-uint3-middle.yaml
tests/tracing/configs/succeed/dynamic-array/of-uint3.yaml
tests/tracing/configs/succeed/dynamic-array/of-uint8.yaml
tests/tracing/configs/succeed/dynamic-array/zero-len.yaml
tests/tracing/configs/succeed/static-array/nested-5-uint8.yaml
tests/tracing/configs/succeed/static-array/of-double.yaml
tests/tracing/configs/succeed/static-array/of-static-array-of-double.yaml
tests/tracing/configs/succeed/static-array/of-static-array-of-str.yaml
tests/tracing/configs/succeed/static-array/of-static-array-of-uint8.yaml
tests/tracing/configs/succeed/static-array/of-str.yaml
tests/tracing/configs/succeed/static-array/of-uint3-middle.yaml
tests/tracing/configs/succeed/static-array/of-uint3.yaml
tests/tracing/configs/succeed/static-array/of-uint8.yaml
tests/tracing/configs/succeed/static-array/zero-len.yaml
tests/tracing/conftest.py
tests/tracing/support/base.yaml [new file with mode: 0644]

index f0a003704845b9bb9c407bdb6c1ba84cdac8c69a..808065a288eee261bdca5ac016825d7ed8fbc757 100644 (file)
 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:
index a448732bf8651e93d1735f185f5c49f3d2ad1e3a..6dc9a10e834c9b12b8b8172804fb4ba73b0ec23d 100644 (file)
 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:
index fb4ecc0cec5622f1a9ea13870fa52a51a305f168..6766e2f777fc1d5089af4876e025d7accd9fbe3c 100644 (file)
 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:
index 1fb0ce43945548549c10b03b153eff4873b4f700..1e84dc6e614dcbf39ffbc061fdc2718611e75a0a 100644 (file)
 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:
index 81307325a7f1d6955e5ee0ec763f930f2ea23ad5..59a92d8774e7520d9230a156ac395b66f7723916 100644 (file)
 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:
index d354bd31742972999d78896dac7aed43bd7c3e8e..06a99a7cb59c4db63422f68dd880ee127779ce89 100644 (file)
 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:
index 7aee8abdc283fcdb56366d2a5e9e09263373aa51..ae630b319f8afacc18f6b6ea1ec2df961aa36d09 100644 (file)
 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:
index 5693c4bef9e5e58ef727a02d48fb87f7e763db5f..7206dce9217dcd7b0470a431dd041182e0bdd016 100644 (file)
 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:
index a0716ec9bccc7a570b91505cae4e15f381db8018..86a754f86a7368ed74c461ac9017e11724157e47 100644 (file)
 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:
index 211f587af881421e625fee344d6d91907f2e84b2..50c7039be23e8682382e77a4c0fcb14d07396b95 100644 (file)
 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:
index b364f570d48e05c8c96ebfbe576f4cc2c7aed2ee..0559c32beaf94c1b8ef3bc959effdcaa7366692f 100644 (file)
 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:
index a05bf482ca944f3e675d5c0fd3004c20da1735f2..2a6e74536eaa8cb81970186b70925cee0f5bbb4e 100644 (file)
 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:
index ba8dec2ff73c23c4919052510c36d88bd9f7828b..b21fa86785ae314359992c0077e61f8f0f39f69c 100644 (file)
 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:
index 3310c49b3a6ba40c8150a1328089ad0f0ff254eb..33dbaa3b4e7c6082c711e0a8922332953a0d3bac 100644 (file)
 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:
index 0371d335a08672642e9d399abf09648bdf3c07a6..90720c1785b305d4485ebb2ef5fa70f8b298e451 100644 (file)
 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:
index 937e51d308a5c31282413d9c2ae351445d64f4b5..fb0a3bd16cf34ab7584a77cfa78d9b125b3fe687 100644 (file)
 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:
index 1061d2afa924325cdead18cf27ca3b780785f3aa..61fcc5fbe765144cea5a9a1d0e2c42246f718b2b 100644 (file)
 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:
index 23e177b3e6f884d4545a97cf1cde6594d84e2b03..f9a4df6ee5378f9ba2ab9f572c03597f2f1761b6 100644 (file)
 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:
index 3a85a5bca58bb9f969b6e67de7481d4c47cba01f..13f2fa72ad174c78e9260b3ef90fcc251d11a518 100644 (file)
 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:
index 127a97e6c14e6e0ddc7dbb29c8d31f5d336970bb..62fc5b0f4ab64a2b0a0d885dd595bdf180007660 100644 (file)
 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:
index 331b39b724b13ae02d64f26ce31c054bdaaa3a3e..4477b7ed644929bcc6a314b60e6a408c22d06a6d 100644 (file)
@@ -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 (file)
index 0000000..6c56d9e
--- /dev/null
@@ -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
This page took 0.035073 seconds and 4 git commands to generate.