Add static array tracing tests
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 9 Sep 2020 23:35:11 +0000 (19:35 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 10 Sep 2020 01:30:23 +0000 (21:30 -0400)
This patch adds static array tracing tests, also adding the testing
infrastructure for other such tests.

In `tests/tracing`, the test functions of `test_succeed_static_array.py`
use the tracing_succeed_test() fixture as found in
`tests/tracing/conftest.py`.

tracing_succeed_test() does the following:

 1. Creates a temporary directory with the tmpdir() fixture.

 2. Automatically finds the paths, based on the test's module and
    function names, of:

    * A YAML configuration file.

    * A test-specific C source file.

    * Two expectation files (one for the metadata stream and one for the
      data stream).

 3. Creates a barectf configuration from the YAML file found in 2.

 4. Generates the C code files using the barectf configuration of 3.,
    writing the files to the temporary directory of 1.

 5. Generates the metadata stream using the barectf configuration of 3.,
    stripping some variable version and generation date lines.

    This step does not write any file to the file system.

 6. Copies the files in the `tests/tracing/support` directory to the
    temporary directory of 1.

    `test-platform.c` and `test-platform.h` form the barectf platform
    for all the tracing tests.

 7. Copies the test-specific C source file found in 2. as `test.c` to
    the temporary directory of 1.

 8. Executes `make` in the temporary directory of 1.

 9. Executes `./test` in the temporary directory of 1.

10. Reads the produced data stream file (`stream` in the temporary
    directory of 1.) and compares it with the data stream expectation
    file found in 2.

11. Compares the metadata stream contents of 5. with the metadata stream
    expectation file found in 2.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
45 files changed:
tests/tracing/configs/succeed/static-array/nested-5-uint8.yaml [new file with mode: 0644]
tests/tracing/configs/succeed/static-array/of-double.yaml [new file with mode: 0644]
tests/tracing/configs/succeed/static-array/of-static-array-of-double.yaml [new file with mode: 0644]
tests/tracing/configs/succeed/static-array/of-static-array-of-str.yaml [new file with mode: 0644]
tests/tracing/configs/succeed/static-array/of-static-array-of-uint8.yaml [new file with mode: 0644]
tests/tracing/configs/succeed/static-array/of-str.yaml [new file with mode: 0644]
tests/tracing/configs/succeed/static-array/of-uint3-middle.yaml [new file with mode: 0644]
tests/tracing/configs/succeed/static-array/of-uint3.yaml [new file with mode: 0644]
tests/tracing/configs/succeed/static-array/of-uint8.yaml [new file with mode: 0644]
tests/tracing/configs/succeed/static-array/zero-len.yaml [new file with mode: 0644]
tests/tracing/conftest.py [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/nested-5-uint8.data.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/nested-5-uint8.metadata.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/of-double.data.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/of-double.metadata.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/of-static-array-of-double.data.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/of-static-array-of-double.metadata.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/of-static-array-of-str.data.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/of-static-array-of-str.metadata.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/of-static-array-of-uint8.data.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/of-static-array-of-uint8.metadata.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/of-str.data.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/of-str.metadata.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/of-uint3-middle.data.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/of-uint3-middle.metadata.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/of-uint3.data.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/of-uint3.metadata.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/of-uint8.data.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/of-uint8.metadata.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/zero-len.data.expect [new file with mode: 0644]
tests/tracing/expect/succeed/static-array/zero-len.metadata.expect [new file with mode: 0644]
tests/tracing/src/succeed/static-array/nested-5-uint8.c [new file with mode: 0644]
tests/tracing/src/succeed/static-array/of-double.c [new file with mode: 0644]
tests/tracing/src/succeed/static-array/of-static-array-of-double.c [new file with mode: 0644]
tests/tracing/src/succeed/static-array/of-static-array-of-str.c [new file with mode: 0644]
tests/tracing/src/succeed/static-array/of-static-array-of-uint8.c [new file with mode: 0644]
tests/tracing/src/succeed/static-array/of-str.c [new file with mode: 0644]
tests/tracing/src/succeed/static-array/of-uint3-middle.c [new file with mode: 0644]
tests/tracing/src/succeed/static-array/of-uint3.c [new file with mode: 0644]
tests/tracing/src/succeed/static-array/of-uint8.c [new file with mode: 0644]
tests/tracing/src/succeed/static-array/zero-len.c [new file with mode: 0644]
tests/tracing/support/Makefile [new file with mode: 0644]
tests/tracing/support/test-platform.c [new file with mode: 0644]
tests/tracing/support/test-platform.h [new file with mode: 0644]
tests/tracing/test_succeed_static_array.py [new file with mode: 0644]

diff --git a/tests/tracing/configs/succeed/static-array/nested-5-uint8.yaml b/tests/tracing/configs/succeed/static-array/nested-5-uint8.yaml
new file mode 100644 (file)
index 0000000..85c3d0f
--- /dev/null
@@ -0,0 +1,54 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+--- !<tag:barectf.org,2020/3/config>
+target-byte-order: le
+trace:
+  type:
+    $include:
+      - stdint.yaml
+    stream-types:
+      default:
+        $is-default: yes
+        event-types:
+          ev:
+            payload-field-type:
+              class: struct
+              members:
+                - array:
+                    field-type:
+                      class: static-array
+                      length: 2
+                      element-field-type:
+                        class: static-array
+                        length: 2
+                        element-field-type:
+                          class: static-array
+                          length: 2
+                          element-field-type:
+                            class: static-array
+                            length: 2
+                            element-field-type:
+                              class: static-array
+                              length: 2
+                              element-field-type: uint8
+...
diff --git a/tests/tracing/configs/succeed/static-array/of-double.yaml b/tests/tracing/configs/succeed/static-array/of-double.yaml
new file mode 100644 (file)
index 0000000..d382847
--- /dev/null
@@ -0,0 +1,42 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+--- !<tag:barectf.org,2020/3/config>
+target-byte-order: le
+trace:
+  type:
+    $include:
+      - stdreal.yaml
+    stream-types:
+      default:
+        $is-default: yes
+        event-types:
+          ev:
+            payload-field-type:
+              class: struct
+              members:
+                - array:
+                    field-type:
+                      class: static-array
+                      length: 4
+                      element-field-type: double
+...
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
new file mode 100644 (file)
index 0000000..7dcf80e
--- /dev/null
@@ -0,0 +1,45 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+--- !<tag:barectf.org,2020/3/config>
+target-byte-order: le
+trace:
+  type:
+    $include:
+      - stdreal.yaml
+    stream-types:
+      default:
+        $is-default: yes
+        event-types:
+          ev:
+            payload-field-type:
+              class: struct
+              members:
+                - array:
+                    field-type:
+                      class: static-array
+                      length: 2
+                      element-field-type:
+                        class: static-array
+                        length: 3
+                        element-field-type: double
+...
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
new file mode 100644 (file)
index 0000000..124828a
--- /dev/null
@@ -0,0 +1,45 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+--- !<tag:barectf.org,2020/3/config>
+target-byte-order: le
+trace:
+  type:
+    $include:
+      - stdmisc.yaml
+    stream-types:
+      default:
+        $is-default: yes
+        event-types:
+          ev:
+            payload-field-type:
+              class: struct
+              members:
+                - array:
+                    field-type:
+                      class: static-array
+                      length: 2
+                      element-field-type:
+                        class: static-array
+                        length: 3
+                        element-field-type: str
+...
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
new file mode 100644 (file)
index 0000000..daf11f6
--- /dev/null
@@ -0,0 +1,45 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+--- !<tag:barectf.org,2020/3/config>
+target-byte-order: le
+trace:
+  type:
+    $include:
+      - stdint.yaml
+    stream-types:
+      default:
+        $is-default: yes
+        event-types:
+          ev:
+            payload-field-type:
+              class: struct
+              members:
+                - array:
+                    field-type:
+                      class: static-array
+                      length: 2
+                      element-field-type:
+                        class: static-array
+                        length: 3
+                        element-field-type: uint8
+...
diff --git a/tests/tracing/configs/succeed/static-array/of-str.yaml b/tests/tracing/configs/succeed/static-array/of-str.yaml
new file mode 100644 (file)
index 0000000..8257add
--- /dev/null
@@ -0,0 +1,42 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+--- !<tag:barectf.org,2020/3/config>
+target-byte-order: le
+trace:
+  type:
+    $include:
+      - stdmisc.yaml
+    stream-types:
+      default:
+        $is-default: yes
+        event-types:
+          ev:
+            payload-field-type:
+              class: struct
+              members:
+                - array:
+                    field-type:
+                      class: static-array
+                      length: 3
+                      element-field-type: str
+...
diff --git a/tests/tracing/configs/succeed/static-array/of-uint3-middle.yaml b/tests/tracing/configs/succeed/static-array/of-uint3-middle.yaml
new file mode 100644 (file)
index 0000000..2a03030
--- /dev/null
@@ -0,0 +1,47 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+--- !<tag:barectf.org,2020/3/config>
+target-byte-order: le
+trace:
+  type:
+    $include:
+      - stdint.yaml
+      - stdmisc.yaml
+    stream-types:
+      default:
+        $is-default: yes
+        event-types:
+          ev:
+            payload-field-type:
+              class: struct
+              members:
+                - before: uint32
+                - array:
+                    field-type:
+                      class: static-array
+                      length: 5
+                      element-field-type:
+                        class: uint
+                        size: 3
+                - after: str
+...
diff --git a/tests/tracing/configs/succeed/static-array/of-uint3.yaml b/tests/tracing/configs/succeed/static-array/of-uint3.yaml
new file mode 100644 (file)
index 0000000..5859a61
--- /dev/null
@@ -0,0 +1,44 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+--- !<tag:barectf.org,2020/3/config>
+target-byte-order: le
+trace:
+  type:
+    $include:
+      - stdint.yaml
+    stream-types:
+      default:
+        $is-default: yes
+        event-types:
+          ev:
+            payload-field-type:
+              class: struct
+              members:
+                - array:
+                    field-type:
+                      class: static-array
+                      length: 5
+                      element-field-type:
+                        class: uint
+                        size: 3
+...
diff --git a/tests/tracing/configs/succeed/static-array/of-uint8.yaml b/tests/tracing/configs/succeed/static-array/of-uint8.yaml
new file mode 100644 (file)
index 0000000..31c8b2f
--- /dev/null
@@ -0,0 +1,42 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+--- !<tag:barectf.org,2020/3/config>
+target-byte-order: le
+trace:
+  type:
+    $include:
+      - stdint.yaml
+    stream-types:
+      default:
+        $is-default: yes
+        event-types:
+          ev:
+            payload-field-type:
+              class: struct
+              members:
+                - array:
+                    field-type:
+                      class: static-array
+                      length: 7
+                      element-field-type: uint8
+...
diff --git a/tests/tracing/configs/succeed/static-array/zero-len.yaml b/tests/tracing/configs/succeed/static-array/zero-len.yaml
new file mode 100644 (file)
index 0000000..92b34a1
--- /dev/null
@@ -0,0 +1,47 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+--- !<tag:barectf.org,2020/3/config>
+target-byte-order: le
+trace:
+  type:
+    $include:
+      - stdint.yaml
+    stream-types:
+      default:
+        $is-default: yes
+        event-types:
+          ev:
+            payload-field-type:
+              class: struct
+              members:
+                - before: uint8
+                - array:
+                    field-type:
+                      class: static-array
+                      length: 0
+                      element-field-type:
+                        class: uint
+                        size: 8
+                        alignment: 64
+                - after: uint8
+...
diff --git a/tests/tracing/conftest.py b/tests/tracing/conftest.py
new file mode 100644 (file)
index 0000000..2c3366b
--- /dev/null
@@ -0,0 +1,163 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+import pytest
+import os
+import os.path
+import barectf
+import shutil
+import subprocess
+
+
+@pytest.fixture
+def tracing_succeed_test(yaml_cfg_path, request, tmpdir):
+    def func():
+        test_dir = os.path.dirname(request.fspath)
+
+        # Use the test's module and function names to automatically find
+        # the test-specific expectation files.
+        #
+        # For:
+        #
+        # Test module name:
+        #     `test_succeed_hello_there.py`
+        #
+        # Test function name:
+        #     `test_how_are_you`
+        #
+        # The corresponding base expectation file path is
+        # `expect/succeed/hello-there/how-are-you'.
+        elems = [test_dir, 'expect']
+        mod = request.module.__name__
+        mod = mod.replace('test_', '')
+        mod = mod.replace('_', '-')
+        parts = mod.split('-')
+        elems.append(parts[0])
+        elems.append('-'.join(parts[1:]))
+        func = request.function.__name__
+        func = func.replace('test_', '')
+        func = func.replace('_', '-')
+        elems.append(func)
+        expect_base_path = os.path.join(*elems)
+
+        # Use the test's module and function names to automatically find
+        # the test-specific C source file.
+        #
+        # For:
+        #
+        # Test module name:
+        #     `test_succeed_hello_there.py`
+        #
+        # Test function name:
+        #     `test_how_are_you`
+        #
+        # The corresponding expectation file path is
+        # `src/succeed/hello-there/how-are-you.c'.
+        elems = [test_dir, 'src']
+        mod = request.module.__name__
+        mod = mod.replace('test_', '')
+        mod = mod.replace('_', '-')
+        parts = mod.split('-')
+        elems.append(parts[0])
+        elems.append('-'.join(parts[1:]))
+        func = request.function.__name__
+        func = func.replace('test_', '')
+        func = func.replace('_', '-')
+        elems.append(f'{func}.c')
+        src_path = os.path.join(*elems)
+
+        # create barectf configuration
+        with open(yaml_cfg_path) as f:
+            cfg = barectf.configuration_from_file(f)
+
+        # generate and write C code files
+        cg = barectf.CodeGenerator(cfg)
+        files = cg.generate_c_headers()
+        files += cg.generate_c_sources()
+
+        for file in files:
+            with open(os.path.join(tmpdir, file.name), 'w') as f:
+                f.write(file.contents)
+
+        # generate metadata stream, stripping the version and date
+        file = cg.generate_metadata_stream()
+        lines = file.contents.split('\n')
+        new_lines = []
+        discard_patterns = [
+            'Copyright (c)',
+            'The following code was generated',
+            '* on ',
+            'barectf_gen_date =',
+            'tracer_major =',
+            'tracer_minor =',
+            'tracer_patch =',
+        ]
+
+        for line in lines:
+            skip = False
+
+            for pattern in discard_patterns:
+                if pattern in line:
+                    skip = True
+
+            if skip:
+                continue
+
+            new_lines.append(line)
+
+        actual_metadata = '\n'.join(new_lines)
+
+        # copy Makefile to build directory
+        support_dir = os.path.join(test_dir, 'support')
+        shutil.copy(os.path.join(support_dir, 'Makefile'), tmpdir)
+
+        # copy platform files to build directory
+        shutil.copy(os.path.join(support_dir, 'test-platform.c'), tmpdir)
+        shutil.copy(os.path.join(support_dir, 'test-platform.h'), tmpdir)
+
+        # copy specific source code file to build directory
+        shutil.copy(src_path, os.path.join(tmpdir, 'test.c'))
+
+        # build the test
+        subprocess.check_output(['make'], cwd=tmpdir)
+
+        # run the test (produce the data stream)
+        subprocess.check_output(['./test'], cwd=tmpdir)
+
+        # read actual stream
+        with open(os.path.join(tmpdir, 'stream'), 'rb') as f:
+            actual_stream = f.read()
+
+        # read data stream expectation file
+        with open(f'{expect_base_path}.data.expect', 'rb') as f:
+            expected_stream = f.read()
+
+        # read metadata stream expectation file
+        with open(f'{expect_base_path}.metadata.expect', 'r') as f:
+            expected_metadata = f.read()
+
+        # validate streams
+        assert actual_metadata == expected_metadata
+        assert actual_stream == expected_stream
+
+    return func
diff --git a/tests/tracing/expect/succeed/static-array/nested-5-uint8.data.expect b/tests/tracing/expect/succeed/static-array/nested-5-uint8.data.expect
new file mode 100644 (file)
index 0000000..f5709c9
Binary files /dev/null and b/tests/tracing/expect/succeed/static-array/nested-5-uint8.data.expect differ
diff --git a/tests/tracing/expect/succeed/static-array/nested-5-uint8.metadata.expect b/tests/tracing/expect/succeed/static-array/nested-5-uint8.metadata.expect
new file mode 100644 (file)
index 0000000..a60e1a6
--- /dev/null
@@ -0,0 +1,103 @@
+/* CTF 1.8 */
+
+/*
+ * The MIT License (MIT)
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ *
+ *
+ * For more details, see <https://barectf.org/>.
+ */
+
+trace {
+       major = 1;
+       minor = 8;
+       byte_order = le;
+       packet.header := struct {
+               integer {
+                       signed = false;
+                       size = 32;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } magic;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } stream_id;
+       } align(8);
+};
+
+env {
+       domain = "bare";
+       tracer_name = "barectf";
+};
+
+/* Stream type `default` */
+stream {
+       id = 0;
+       packet.context := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } packet_size;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } content_size;
+       } align(8);
+       event.header := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } id;
+       } align(8);
+};
+
+event {
+       stream_id = 0;
+       id = 0;
+       name = "ev";
+       fields := struct {
+               integer {
+                       signed = false;
+                       size = 8;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } array[2][2][2][2][2];
+       } align(1);
+};
diff --git a/tests/tracing/expect/succeed/static-array/of-double.data.expect b/tests/tracing/expect/succeed/static-array/of-double.data.expect
new file mode 100644 (file)
index 0000000..fb88dff
Binary files /dev/null and b/tests/tracing/expect/succeed/static-array/of-double.data.expect differ
diff --git a/tests/tracing/expect/succeed/static-array/of-double.metadata.expect b/tests/tracing/expect/succeed/static-array/of-double.metadata.expect
new file mode 100644 (file)
index 0000000..59e206d
--- /dev/null
@@ -0,0 +1,102 @@
+/* CTF 1.8 */
+
+/*
+ * The MIT License (MIT)
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ *
+ *
+ * For more details, see <https://barectf.org/>.
+ */
+
+trace {
+       major = 1;
+       minor = 8;
+       byte_order = le;
+       packet.header := struct {
+               integer {
+                       signed = false;
+                       size = 32;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } magic;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } stream_id;
+       } align(8);
+};
+
+env {
+       domain = "bare";
+       tracer_name = "barectf";
+};
+
+/* Stream type `default` */
+stream {
+       id = 0;
+       packet.context := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } packet_size;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } content_size;
+       } align(8);
+       event.header := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } id;
+       } align(8);
+};
+
+event {
+       stream_id = 0;
+       id = 0;
+       name = "ev";
+       fields := struct {
+               floating_point {
+                       mant_dig = 53;
+                       exp_dig = 11;
+                       align = 64;
+                       byte_order = native;
+               } array[4];
+       } align(1);
+};
diff --git a/tests/tracing/expect/succeed/static-array/of-static-array-of-double.data.expect b/tests/tracing/expect/succeed/static-array/of-static-array-of-double.data.expect
new file mode 100644 (file)
index 0000000..ca0b3b6
Binary files /dev/null and b/tests/tracing/expect/succeed/static-array/of-static-array-of-double.data.expect differ
diff --git a/tests/tracing/expect/succeed/static-array/of-static-array-of-double.metadata.expect b/tests/tracing/expect/succeed/static-array/of-static-array-of-double.metadata.expect
new file mode 100644 (file)
index 0000000..79d17b9
--- /dev/null
@@ -0,0 +1,102 @@
+/* CTF 1.8 */
+
+/*
+ * The MIT License (MIT)
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ *
+ *
+ * For more details, see <https://barectf.org/>.
+ */
+
+trace {
+       major = 1;
+       minor = 8;
+       byte_order = le;
+       packet.header := struct {
+               integer {
+                       signed = false;
+                       size = 32;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } magic;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } stream_id;
+       } align(8);
+};
+
+env {
+       domain = "bare";
+       tracer_name = "barectf";
+};
+
+/* Stream type `default` */
+stream {
+       id = 0;
+       packet.context := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } packet_size;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } content_size;
+       } align(8);
+       event.header := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } id;
+       } align(8);
+};
+
+event {
+       stream_id = 0;
+       id = 0;
+       name = "ev";
+       fields := struct {
+               floating_point {
+                       mant_dig = 53;
+                       exp_dig = 11;
+                       align = 64;
+                       byte_order = native;
+               } array[2][3];
+       } align(1);
+};
diff --git a/tests/tracing/expect/succeed/static-array/of-static-array-of-str.data.expect b/tests/tracing/expect/succeed/static-array/of-static-array-of-str.data.expect
new file mode 100644 (file)
index 0000000..b697fed
Binary files /dev/null and b/tests/tracing/expect/succeed/static-array/of-static-array-of-str.data.expect differ
diff --git a/tests/tracing/expect/succeed/static-array/of-static-array-of-str.metadata.expect b/tests/tracing/expect/succeed/static-array/of-static-array-of-str.metadata.expect
new file mode 100644 (file)
index 0000000..d12e863
--- /dev/null
@@ -0,0 +1,99 @@
+/* CTF 1.8 */
+
+/*
+ * The MIT License (MIT)
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ *
+ *
+ * For more details, see <https://barectf.org/>.
+ */
+
+trace {
+       major = 1;
+       minor = 8;
+       byte_order = le;
+       packet.header := struct {
+               integer {
+                       signed = false;
+                       size = 32;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } magic;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } stream_id;
+       } align(8);
+};
+
+env {
+       domain = "bare";
+       tracer_name = "barectf";
+};
+
+/* Stream type `default` */
+stream {
+       id = 0;
+       packet.context := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } packet_size;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } content_size;
+       } align(8);
+       event.header := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } id;
+       } align(8);
+};
+
+event {
+       stream_id = 0;
+       id = 0;
+       name = "ev";
+       fields := struct {
+               string {
+                       encoding = UTF8;
+               } array[2][3];
+       } align(1);
+};
diff --git a/tests/tracing/expect/succeed/static-array/of-static-array-of-uint8.data.expect b/tests/tracing/expect/succeed/static-array/of-static-array-of-uint8.data.expect
new file mode 100644 (file)
index 0000000..c1f475d
Binary files /dev/null and b/tests/tracing/expect/succeed/static-array/of-static-array-of-uint8.data.expect differ
diff --git a/tests/tracing/expect/succeed/static-array/of-static-array-of-uint8.metadata.expect b/tests/tracing/expect/succeed/static-array/of-static-array-of-uint8.metadata.expect
new file mode 100644 (file)
index 0000000..64db479
--- /dev/null
@@ -0,0 +1,103 @@
+/* CTF 1.8 */
+
+/*
+ * The MIT License (MIT)
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ *
+ *
+ * For more details, see <https://barectf.org/>.
+ */
+
+trace {
+       major = 1;
+       minor = 8;
+       byte_order = le;
+       packet.header := struct {
+               integer {
+                       signed = false;
+                       size = 32;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } magic;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } stream_id;
+       } align(8);
+};
+
+env {
+       domain = "bare";
+       tracer_name = "barectf";
+};
+
+/* Stream type `default` */
+stream {
+       id = 0;
+       packet.context := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } packet_size;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } content_size;
+       } align(8);
+       event.header := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } id;
+       } align(8);
+};
+
+event {
+       stream_id = 0;
+       id = 0;
+       name = "ev";
+       fields := struct {
+               integer {
+                       signed = false;
+                       size = 8;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } array[2][3];
+       } align(1);
+};
diff --git a/tests/tracing/expect/succeed/static-array/of-str.data.expect b/tests/tracing/expect/succeed/static-array/of-str.data.expect
new file mode 100644 (file)
index 0000000..4628e39
Binary files /dev/null and b/tests/tracing/expect/succeed/static-array/of-str.data.expect differ
diff --git a/tests/tracing/expect/succeed/static-array/of-str.metadata.expect b/tests/tracing/expect/succeed/static-array/of-str.metadata.expect
new file mode 100644 (file)
index 0000000..e924729
--- /dev/null
@@ -0,0 +1,99 @@
+/* CTF 1.8 */
+
+/*
+ * The MIT License (MIT)
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ *
+ *
+ * For more details, see <https://barectf.org/>.
+ */
+
+trace {
+       major = 1;
+       minor = 8;
+       byte_order = le;
+       packet.header := struct {
+               integer {
+                       signed = false;
+                       size = 32;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } magic;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } stream_id;
+       } align(8);
+};
+
+env {
+       domain = "bare";
+       tracer_name = "barectf";
+};
+
+/* Stream type `default` */
+stream {
+       id = 0;
+       packet.context := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } packet_size;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } content_size;
+       } align(8);
+       event.header := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } id;
+       } align(8);
+};
+
+event {
+       stream_id = 0;
+       id = 0;
+       name = "ev";
+       fields := struct {
+               string {
+                       encoding = UTF8;
+               } array[3];
+       } align(1);
+};
diff --git a/tests/tracing/expect/succeed/static-array/of-uint3-middle.data.expect b/tests/tracing/expect/succeed/static-array/of-uint3-middle.data.expect
new file mode 100644 (file)
index 0000000..2174552
Binary files /dev/null and b/tests/tracing/expect/succeed/static-array/of-uint3-middle.data.expect differ
diff --git a/tests/tracing/expect/succeed/static-array/of-uint3-middle.metadata.expect b/tests/tracing/expect/succeed/static-array/of-uint3-middle.metadata.expect
new file mode 100644 (file)
index 0000000..282a2f0
--- /dev/null
@@ -0,0 +1,113 @@
+/* CTF 1.8 */
+
+/*
+ * The MIT License (MIT)
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ *
+ *
+ * For more details, see <https://barectf.org/>.
+ */
+
+trace {
+       major = 1;
+       minor = 8;
+       byte_order = le;
+       packet.header := struct {
+               integer {
+                       signed = false;
+                       size = 32;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } magic;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } stream_id;
+       } align(8);
+};
+
+env {
+       domain = "bare";
+       tracer_name = "barectf";
+};
+
+/* Stream type `default` */
+stream {
+       id = 0;
+       packet.context := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } packet_size;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } content_size;
+       } align(8);
+       event.header := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } id;
+       } align(8);
+};
+
+event {
+       stream_id = 0;
+       id = 0;
+       name = "ev";
+       fields := struct {
+               integer {
+                       signed = false;
+                       size = 32;
+                       align = 32;
+                       byte_order = native;
+                       base = 10;
+               } before;
+               integer {
+                       signed = false;
+                       size = 3;
+                       align = 1;
+                       byte_order = native;
+                       base = 10;
+               } array[5];
+               string {
+                       encoding = UTF8;
+               } after;
+       } align(1);
+};
diff --git a/tests/tracing/expect/succeed/static-array/of-uint3.data.expect b/tests/tracing/expect/succeed/static-array/of-uint3.data.expect
new file mode 100644 (file)
index 0000000..38032a8
Binary files /dev/null and b/tests/tracing/expect/succeed/static-array/of-uint3.data.expect differ
diff --git a/tests/tracing/expect/succeed/static-array/of-uint3.metadata.expect b/tests/tracing/expect/succeed/static-array/of-uint3.metadata.expect
new file mode 100644 (file)
index 0000000..618f6e5
--- /dev/null
@@ -0,0 +1,103 @@
+/* CTF 1.8 */
+
+/*
+ * The MIT License (MIT)
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ *
+ *
+ * For more details, see <https://barectf.org/>.
+ */
+
+trace {
+       major = 1;
+       minor = 8;
+       byte_order = le;
+       packet.header := struct {
+               integer {
+                       signed = false;
+                       size = 32;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } magic;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } stream_id;
+       } align(8);
+};
+
+env {
+       domain = "bare";
+       tracer_name = "barectf";
+};
+
+/* Stream type `default` */
+stream {
+       id = 0;
+       packet.context := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } packet_size;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } content_size;
+       } align(8);
+       event.header := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } id;
+       } align(8);
+};
+
+event {
+       stream_id = 0;
+       id = 0;
+       name = "ev";
+       fields := struct {
+               integer {
+                       signed = false;
+                       size = 3;
+                       align = 1;
+                       byte_order = native;
+                       base = 10;
+               } array[5];
+       } align(1);
+};
diff --git a/tests/tracing/expect/succeed/static-array/of-uint8.data.expect b/tests/tracing/expect/succeed/static-array/of-uint8.data.expect
new file mode 100644 (file)
index 0000000..846d841
Binary files /dev/null and b/tests/tracing/expect/succeed/static-array/of-uint8.data.expect differ
diff --git a/tests/tracing/expect/succeed/static-array/of-uint8.metadata.expect b/tests/tracing/expect/succeed/static-array/of-uint8.metadata.expect
new file mode 100644 (file)
index 0000000..50f30da
--- /dev/null
@@ -0,0 +1,103 @@
+/* CTF 1.8 */
+
+/*
+ * The MIT License (MIT)
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ *
+ *
+ * For more details, see <https://barectf.org/>.
+ */
+
+trace {
+       major = 1;
+       minor = 8;
+       byte_order = le;
+       packet.header := struct {
+               integer {
+                       signed = false;
+                       size = 32;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } magic;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } stream_id;
+       } align(8);
+};
+
+env {
+       domain = "bare";
+       tracer_name = "barectf";
+};
+
+/* Stream type `default` */
+stream {
+       id = 0;
+       packet.context := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } packet_size;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } content_size;
+       } align(8);
+       event.header := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } id;
+       } align(8);
+};
+
+event {
+       stream_id = 0;
+       id = 0;
+       name = "ev";
+       fields := struct {
+               integer {
+                       signed = false;
+                       size = 8;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } array[7];
+       } align(1);
+};
diff --git a/tests/tracing/expect/succeed/static-array/zero-len.data.expect b/tests/tracing/expect/succeed/static-array/zero-len.data.expect
new file mode 100644 (file)
index 0000000..338d48c
Binary files /dev/null and b/tests/tracing/expect/succeed/static-array/zero-len.data.expect differ
diff --git a/tests/tracing/expect/succeed/static-array/zero-len.metadata.expect b/tests/tracing/expect/succeed/static-array/zero-len.metadata.expect
new file mode 100644 (file)
index 0000000..20c2970
--- /dev/null
@@ -0,0 +1,117 @@
+/* CTF 1.8 */
+
+/*
+ * The MIT License (MIT)
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ *
+ *
+ * For more details, see <https://barectf.org/>.
+ */
+
+trace {
+       major = 1;
+       minor = 8;
+       byte_order = le;
+       packet.header := struct {
+               integer {
+                       signed = false;
+                       size = 32;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } magic;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } stream_id;
+       } align(8);
+};
+
+env {
+       domain = "bare";
+       tracer_name = "barectf";
+};
+
+/* Stream type `default` */
+stream {
+       id = 0;
+       packet.context := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } packet_size;
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } content_size;
+       } align(8);
+       event.header := struct {
+               integer {
+                       signed = false;
+                       size = 64;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } id;
+       } align(8);
+};
+
+event {
+       stream_id = 0;
+       id = 0;
+       name = "ev";
+       fields := struct {
+               integer {
+                       signed = false;
+                       size = 8;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } before;
+               integer {
+                       signed = false;
+                       size = 8;
+                       align = 64;
+                       byte_order = native;
+                       base = 10;
+               } array[0];
+               integer {
+                       signed = false;
+                       size = 8;
+                       align = 8;
+                       byte_order = native;
+                       base = 10;
+               } after;
+       } align(1);
+};
diff --git a/tests/tracing/src/succeed/static-array/nested-5-uint8.c b/tests/tracing/src/succeed/static-array/nested-5-uint8.c
new file mode 100644 (file)
index 0000000..f4a7635
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "test-platform.h"
+#include "barectf.h"
+
+int main()
+{
+       struct test_platform_ctx *platform_ctx;
+       const uint8_t subsubsubsubarray1[] = {1, 2};
+       const uint8_t subsubsubsubarray2[] = {3, 4};
+       const uint8_t subsubsubsubarray3[] = {5, 6};
+       const uint8_t subsubsubsubarray4[] = {7, 8};
+       const uint8_t subsubsubsubarray5[] = {9, 10};
+       const uint8_t subsubsubsubarray6[] = {11, 12};
+       const uint8_t subsubsubsubarray7[] = {13, 14};
+       const uint8_t subsubsubsubarray8[] = {15, 16};
+       const uint8_t subsubsubsubarray9[] = {17, 18};
+       const uint8_t subsubsubsubarray10[] = {19, 20};
+       const uint8_t subsubsubsubarray11[] = {21, 22};
+       const uint8_t subsubsubsubarray12[] = {23, 24};
+       const uint8_t subsubsubsubarray13[] = {25, 26};
+       const uint8_t subsubsubsubarray14[] = {27, 28};
+       const uint8_t subsubsubsubarray15[] = {29, 30};
+       const uint8_t subsubsubsubarray16[] = {31, 32};
+       const uint8_t *subsubsubarray1[] = {subsubsubsubarray1, subsubsubsubarray2};
+       const uint8_t *subsubsubarray2[] = {subsubsubsubarray3, subsubsubsubarray4};
+       const uint8_t *subsubsubarray3[] = {subsubsubsubarray5, subsubsubsubarray6};
+       const uint8_t *subsubsubarray4[] = {subsubsubsubarray7, subsubsubsubarray8};
+       const uint8_t *subsubsubarray5[] = {subsubsubsubarray9, subsubsubsubarray10};
+       const uint8_t *subsubsubarray6[] = {subsubsubsubarray11, subsubsubsubarray12};
+       const uint8_t *subsubsubarray7[] = {subsubsubsubarray13, subsubsubsubarray14};
+       const uint8_t *subsubsubarray8[] = {subsubsubsubarray15, subsubsubsubarray16};
+       const uint8_t * const *subsubarray1[] = {subsubsubarray1, subsubsubarray2};
+       const uint8_t * const *subsubarray2[] = {subsubsubarray3, subsubsubarray4};
+       const uint8_t * const *subsubarray3[] = {subsubsubarray5, subsubsubarray6};
+       const uint8_t * const *subsubarray4[] = {subsubsubarray7, subsubsubarray8};
+       const uint8_t * const * const *subarray1[] = {subsubarray1, subsubarray2};
+       const uint8_t * const * const *subarray2[] = {subsubarray3, subsubarray4};
+       const uint8_t * const * const * const *array[] = {subarray1, subarray2};
+
+       platform_ctx = test_platform_init(512);
+       assert(platform_ctx);
+       barectf_trace_ev(test_platform_barectf_ctx(platform_ctx), array);
+       test_platform_fini(platform_ctx);
+       return 0;
+}
diff --git a/tests/tracing/src/succeed/static-array/of-double.c b/tests/tracing/src/succeed/static-array/of-double.c
new file mode 100644 (file)
index 0000000..448cccc
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <assert.h>
+
+#include "test-platform.h"
+#include "barectf.h"
+
+int main()
+{
+       struct test_platform_ctx *platform_ctx;
+       const double array[] = {3.14, 6.62, 299792458., 0.2229};
+
+       platform_ctx = test_platform_init(512);
+       assert(platform_ctx);
+       barectf_trace_ev(test_platform_barectf_ctx(platform_ctx), array);
+       test_platform_fini(platform_ctx);
+       return 0;
+}
diff --git a/tests/tracing/src/succeed/static-array/of-static-array-of-double.c b/tests/tracing/src/succeed/static-array/of-static-array-of-double.c
new file mode 100644 (file)
index 0000000..5ad721d
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <assert.h>
+
+#include "test-platform.h"
+#include "barectf.h"
+
+int main()
+{
+       struct test_platform_ctx *platform_ctx;
+       const double subarray1[] = {-17.5, 15.48, 1001.};
+       const double subarray2[] = {.1534, 555.555, 1e9};
+       const double *array[] = {subarray1, subarray2};
+
+       platform_ctx = test_platform_init(512);
+       assert(platform_ctx);
+       barectf_trace_ev(test_platform_barectf_ctx(platform_ctx), array);
+       test_platform_fini(platform_ctx);
+       return 0;
+}
diff --git a/tests/tracing/src/succeed/static-array/of-static-array-of-str.c b/tests/tracing/src/succeed/static-array/of-static-array-of-str.c
new file mode 100644 (file)
index 0000000..3b6b461
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <assert.h>
+
+#include "test-platform.h"
+#include "barectf.h"
+
+int main()
+{
+       struct test_platform_ctx *platform_ctx;
+       const char *str1[] = {"Officia", "sit", "labore"};
+       const char *str2[] = {"Excepteur", "labore", "non"};
+       const char * const *array[] = {str1, str2};
+
+       platform_ctx = test_platform_init(512);
+       assert(platform_ctx);
+       barectf_trace_ev(test_platform_barectf_ctx(platform_ctx), array);
+       test_platform_fini(platform_ctx);
+       return 0;
+}
diff --git a/tests/tracing/src/succeed/static-array/of-static-array-of-uint8.c b/tests/tracing/src/succeed/static-array/of-static-array-of-uint8.c
new file mode 100644 (file)
index 0000000..4ee6585
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "test-platform.h"
+#include "barectf.h"
+
+int main()
+{
+       struct test_platform_ctx *platform_ctx;
+       const uint8_t subarray1[] = {1, 2, 3};
+       const uint8_t subarray2[] = {4, 5, 6};
+       const uint8_t *array[] = {subarray1, subarray2};
+
+       platform_ctx = test_platform_init(512);
+       assert(platform_ctx);
+       barectf_trace_ev(test_platform_barectf_ctx(platform_ctx), array);
+       test_platform_fini(platform_ctx);
+       return 0;
+}
diff --git a/tests/tracing/src/succeed/static-array/of-str.c b/tests/tracing/src/succeed/static-array/of-str.c
new file mode 100644 (file)
index 0000000..36284a0
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <assert.h>
+
+#include "test-platform.h"
+#include "barectf.h"
+
+int main()
+{
+       struct test_platform_ctx *platform_ctx;
+       const char *array[] = {"Lorem", "ipsum", "quis"};
+
+       platform_ctx = test_platform_init(512);
+       assert(platform_ctx);
+       barectf_trace_ev(test_platform_barectf_ctx(platform_ctx), array);
+       test_platform_fini(platform_ctx);
+       return 0;
+}
diff --git a/tests/tracing/src/succeed/static-array/of-uint3-middle.c b/tests/tracing/src/succeed/static-array/of-uint3-middle.c
new file mode 100644 (file)
index 0000000..7326810
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "test-platform.h"
+#include "barectf.h"
+
+int main()
+{
+       struct test_platform_ctx *platform_ctx;
+       const uint8_t array[] = {7, 5, 3, 2, 1};
+
+       platform_ctx = test_platform_init(512);
+       assert(platform_ctx);
+       barectf_trace_ev(test_platform_barectf_ctx(platform_ctx), 123456,
+               array, "hello!");
+       test_platform_fini(platform_ctx);
+       return 0;
+}
diff --git a/tests/tracing/src/succeed/static-array/of-uint3.c b/tests/tracing/src/succeed/static-array/of-uint3.c
new file mode 100644 (file)
index 0000000..6028489
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "test-platform.h"
+#include "barectf.h"
+
+int main()
+{
+       struct test_platform_ctx *platform_ctx;
+       const uint8_t array[] = {7, 5, 3, 2, 1};
+
+       platform_ctx = test_platform_init(512);
+       assert(platform_ctx);
+       barectf_trace_ev(test_platform_barectf_ctx(platform_ctx), array);
+       test_platform_fini(platform_ctx);
+       return 0;
+}
diff --git a/tests/tracing/src/succeed/static-array/of-uint8.c b/tests/tracing/src/succeed/static-array/of-uint8.c
new file mode 100644 (file)
index 0000000..ebf655a
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "test-platform.h"
+#include "barectf.h"
+
+int main()
+{
+       struct test_platform_ctx *platform_ctx;
+       const uint8_t array[] = {1, 1, 2, 3, 5, 8, 13};
+
+       platform_ctx = test_platform_init(512);
+       assert(platform_ctx);
+       barectf_trace_ev(test_platform_barectf_ctx(platform_ctx), array);
+       test_platform_fini(platform_ctx);
+       return 0;
+}
diff --git a/tests/tracing/src/succeed/static-array/zero-len.c b/tests/tracing/src/succeed/static-array/zero-len.c
new file mode 100644 (file)
index 0000000..15f29ff
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+
+#include "test-platform.h"
+#include "barectf.h"
+
+int main()
+{
+       struct test_platform_ctx *platform_ctx;
+
+       platform_ctx = test_platform_init(512);
+       assert(platform_ctx);
+       barectf_trace_ev(test_platform_barectf_ctx(platform_ctx), 23, NULL, 177);
+       test_platform_fini(platform_ctx);
+       return 0;
+}
diff --git a/tests/tracing/support/Makefile b/tests/tracing/support/Makefile
new file mode 100644 (file)
index 0000000..a572962
--- /dev/null
@@ -0,0 +1,31 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2016-2020 Philippe Proulx <pproulx@efficios.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+CFLAGS += -O0 -g -Wall -pedantic -Wno-unused-function
+TARGET = test
+OBJS = $(TARGET).o barectf.o test-platform.o
+
+$(TARGET): $(OBJS)
+       $(CC) -o $@ $(LDFLAGS) $^
+
+barectf.o: barectf.c
+       $(CC) $(CFLAGS) -ansi -c $<
diff --git a/tests/tracing/support/test-platform.c b/tests/tracing/support/test-platform.c
new file mode 100644 (file)
index 0000000..d060fab
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <assert.h>
+
+#include "barectf.h"
+#include "test-platform.h"
+
+struct test_platform_ctx {
+       struct barectf_default_ctx ctx;
+       FILE *fh;
+};
+
+static void write_packet(struct test_platform_ctx * const platform_ctx)
+{
+       size_t nmemb = fwrite(barectf_packet_buf(&platform_ctx->ctx),
+               barectf_packet_buf_size(&platform_ctx->ctx), 1,
+                       platform_ctx->fh);
+       assert(nmemb == 1);
+}
+
+static int is_backend_full(void * const data)
+{
+       return 0;
+}
+
+static void open_packet(void * const data)
+{
+       struct test_platform_ctx * const platform_ctx = (void *) data;
+
+       barectf_default_open_packet(&platform_ctx->ctx);
+}
+
+static void close_packet(void * const data)
+{
+       struct test_platform_ctx * const platform_ctx = (void *) data;
+
+       barectf_default_close_packet(&platform_ctx->ctx);
+       write_packet(platform_ctx);
+}
+
+struct test_platform_ctx *test_platform_init(const size_t buf_size)
+{
+       uint8_t *buf;
+       struct test_platform_ctx *platform_ctx;
+       struct barectf_platform_callbacks cbs;
+
+       cbs.is_backend_full = is_backend_full;
+       cbs.open_packet = open_packet;
+       cbs.close_packet = close_packet;
+       platform_ctx = malloc(sizeof(*platform_ctx));
+       assert(platform_ctx);
+       buf = malloc(buf_size);
+       assert(buf);
+       memset(buf, 0, buf_size);
+       platform_ctx->fh = fopen("stream", "wb");
+       assert(platform_ctx->fh);
+       barectf_init(&platform_ctx->ctx, buf, buf_size, cbs, platform_ctx);
+       open_packet(platform_ctx);
+       return platform_ctx;
+}
+
+void test_platform_fini(struct test_platform_ctx * const platform_ctx)
+{
+       if (barectf_packet_is_open(&platform_ctx->ctx) &&
+                       !barectf_packet_is_empty(&platform_ctx->ctx)) {
+               close_packet(platform_ctx);
+       }
+
+       fclose(platform_ctx->fh);
+       free(barectf_packet_buf(&platform_ctx->ctx));
+       free(platform_ctx);
+}
+
+struct barectf_default_ctx *test_platform_barectf_ctx(
+       struct test_platform_ctx * const platform_ctx)
+{
+       return &platform_ctx->ctx;
+}
diff --git a/tests/tracing/support/test-platform.h b/tests/tracing/support/test-platform.h
new file mode 100644 (file)
index 0000000..8632a5e
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef _BARECTF_TEST_PLATFORM_H
+#define _BARECTF_TEST_PLATFORM_H
+
+/*
+ * Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdlib.h>
+
+#include "barectf.h"
+
+struct test_platform_ctx;
+
+struct test_platform_ctx *test_platform_init(size_t buf_size);
+void test_platform_fini(struct test_platform_ctx *ctx);
+struct barectf_default_ctx *test_platform_barectf_ctx(
+       struct test_platform_ctx *ctx);
+
+#endif /* _BARECTF_TEST_PLATFORM_H */
diff --git a/tests/tracing/test_succeed_static_array.py b/tests/tracing/test_succeed_static_array.py
new file mode 100644 (file)
index 0000000..f815407
--- /dev/null
@@ -0,0 +1,61 @@
+# The MIT License (MIT)
+#
+# Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+def test_nested_5_uint8(tracing_succeed_test):
+    tracing_succeed_test()
+
+
+def test_of_double(tracing_succeed_test):
+    tracing_succeed_test()
+
+
+def test_of_static_array_of_double(tracing_succeed_test):
+    tracing_succeed_test()
+
+
+def test_of_static_array_of_str(tracing_succeed_test):
+    tracing_succeed_test()
+
+
+def test_of_static_array_of_uint8(tracing_succeed_test):
+    tracing_succeed_test()
+
+
+def test_of_str(tracing_succeed_test):
+    tracing_succeed_test()
+
+
+def test_of_uint3(tracing_succeed_test):
+    tracing_succeed_test()
+
+
+def test_of_uint3_middle(tracing_succeed_test):
+    tracing_succeed_test()
+
+
+def test_of_uint8(tracing_succeed_test):
+    tracing_succeed_test()
+
+
+def test_zero_len(tracing_succeed_test):
+    tracing_succeed_test()
This page took 0.05356 seconds and 4 git commands to generate.