From 8800477645df39645e07ae0db9e628f38e6a50f5 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Wed, 9 Sep 2020 19:35:11 -0400 Subject: [PATCH] Add static array tracing tests 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 --- .../succeed/static-array/nested-5-uint8.yaml | 54 ++++++ .../succeed/static-array/of-double.yaml | 42 +++++ .../of-static-array-of-double.yaml | 45 +++++ .../static-array/of-static-array-of-str.yaml | 45 +++++ .../of-static-array-of-uint8.yaml | 45 +++++ .../configs/succeed/static-array/of-str.yaml | 42 +++++ .../succeed/static-array/of-uint3-middle.yaml | 47 +++++ .../succeed/static-array/of-uint3.yaml | 44 +++++ .../succeed/static-array/of-uint8.yaml | 42 +++++ .../succeed/static-array/zero-len.yaml | 47 +++++ tests/tracing/conftest.py | 163 ++++++++++++++++++ .../static-array/nested-5-uint8.data.expect | Bin 0 -> 512 bytes .../nested-5-uint8.metadata.expect | 103 +++++++++++ .../static-array/of-double.data.expect | Bin 0 -> 512 bytes .../static-array/of-double.metadata.expect | 102 +++++++++++ .../of-static-array-of-double.data.expect | Bin 0 -> 512 bytes .../of-static-array-of-double.metadata.expect | 102 +++++++++++ .../of-static-array-of-str.data.expect | Bin 0 -> 512 bytes .../of-static-array-of-str.metadata.expect | 99 +++++++++++ .../of-static-array-of-uint8.data.expect | Bin 0 -> 512 bytes .../of-static-array-of-uint8.metadata.expect | 103 +++++++++++ .../succeed/static-array/of-str.data.expect | Bin 0 -> 512 bytes .../static-array/of-str.metadata.expect | 99 +++++++++++ .../static-array/of-uint3-middle.data.expect | Bin 0 -> 512 bytes .../of-uint3-middle.metadata.expect | 113 ++++++++++++ .../succeed/static-array/of-uint3.data.expect | Bin 0 -> 512 bytes .../static-array/of-uint3.metadata.expect | 103 +++++++++++ .../succeed/static-array/of-uint8.data.expect | Bin 0 -> 512 bytes .../static-array/of-uint8.metadata.expect | 103 +++++++++++ .../succeed/static-array/zero-len.data.expect | Bin 0 -> 512 bytes .../static-array/zero-len.metadata.expect | 117 +++++++++++++ .../src/succeed/static-array/nested-5-uint8.c | 71 ++++++++ .../src/succeed/static-array/of-double.c | 40 +++++ .../static-array/of-static-array-of-double.c | 42 +++++ .../static-array/of-static-array-of-str.c | 42 +++++ .../static-array/of-static-array-of-uint8.c | 43 +++++ .../tracing/src/succeed/static-array/of-str.c | 40 +++++ .../succeed/static-array/of-uint3-middle.c | 42 +++++ .../src/succeed/static-array/of-uint3.c | 41 +++++ .../src/succeed/static-array/of-uint8.c | 41 +++++ .../src/succeed/static-array/zero-len.c | 40 +++++ tests/tracing/support/Makefile | 31 ++++ tests/tracing/support/test-platform.c | 102 +++++++++++ tests/tracing/support/test-platform.h | 37 ++++ tests/tracing/test_succeed_static_array.py | 61 +++++++ 45 files changed, 2333 insertions(+) create mode 100644 tests/tracing/configs/succeed/static-array/nested-5-uint8.yaml create mode 100644 tests/tracing/configs/succeed/static-array/of-double.yaml create mode 100644 tests/tracing/configs/succeed/static-array/of-static-array-of-double.yaml create mode 100644 tests/tracing/configs/succeed/static-array/of-static-array-of-str.yaml create mode 100644 tests/tracing/configs/succeed/static-array/of-static-array-of-uint8.yaml create mode 100644 tests/tracing/configs/succeed/static-array/of-str.yaml create mode 100644 tests/tracing/configs/succeed/static-array/of-uint3-middle.yaml create mode 100644 tests/tracing/configs/succeed/static-array/of-uint3.yaml create mode 100644 tests/tracing/configs/succeed/static-array/of-uint8.yaml create mode 100644 tests/tracing/configs/succeed/static-array/zero-len.yaml create mode 100644 tests/tracing/conftest.py create mode 100644 tests/tracing/expect/succeed/static-array/nested-5-uint8.data.expect create mode 100644 tests/tracing/expect/succeed/static-array/nested-5-uint8.metadata.expect create mode 100644 tests/tracing/expect/succeed/static-array/of-double.data.expect create mode 100644 tests/tracing/expect/succeed/static-array/of-double.metadata.expect create mode 100644 tests/tracing/expect/succeed/static-array/of-static-array-of-double.data.expect create mode 100644 tests/tracing/expect/succeed/static-array/of-static-array-of-double.metadata.expect create mode 100644 tests/tracing/expect/succeed/static-array/of-static-array-of-str.data.expect create mode 100644 tests/tracing/expect/succeed/static-array/of-static-array-of-str.metadata.expect create mode 100644 tests/tracing/expect/succeed/static-array/of-static-array-of-uint8.data.expect create mode 100644 tests/tracing/expect/succeed/static-array/of-static-array-of-uint8.metadata.expect create mode 100644 tests/tracing/expect/succeed/static-array/of-str.data.expect create mode 100644 tests/tracing/expect/succeed/static-array/of-str.metadata.expect create mode 100644 tests/tracing/expect/succeed/static-array/of-uint3-middle.data.expect create mode 100644 tests/tracing/expect/succeed/static-array/of-uint3-middle.metadata.expect create mode 100644 tests/tracing/expect/succeed/static-array/of-uint3.data.expect create mode 100644 tests/tracing/expect/succeed/static-array/of-uint3.metadata.expect create mode 100644 tests/tracing/expect/succeed/static-array/of-uint8.data.expect create mode 100644 tests/tracing/expect/succeed/static-array/of-uint8.metadata.expect create mode 100644 tests/tracing/expect/succeed/static-array/zero-len.data.expect create mode 100644 tests/tracing/expect/succeed/static-array/zero-len.metadata.expect create mode 100644 tests/tracing/src/succeed/static-array/nested-5-uint8.c create mode 100644 tests/tracing/src/succeed/static-array/of-double.c create mode 100644 tests/tracing/src/succeed/static-array/of-static-array-of-double.c create mode 100644 tests/tracing/src/succeed/static-array/of-static-array-of-str.c create mode 100644 tests/tracing/src/succeed/static-array/of-static-array-of-uint8.c create mode 100644 tests/tracing/src/succeed/static-array/of-str.c create mode 100644 tests/tracing/src/succeed/static-array/of-uint3-middle.c create mode 100644 tests/tracing/src/succeed/static-array/of-uint3.c create mode 100644 tests/tracing/src/succeed/static-array/of-uint8.c create mode 100644 tests/tracing/src/succeed/static-array/zero-len.c create mode 100644 tests/tracing/support/Makefile create mode 100644 tests/tracing/support/test-platform.c create mode 100644 tests/tracing/support/test-platform.h create mode 100644 tests/tracing/test_succeed_static_array.py 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 index 0000000..85c3d0f --- /dev/null +++ b/tests/tracing/configs/succeed/static-array/nested-5-uint8.yaml @@ -0,0 +1,54 @@ +# The MIT License (MIT) +# +# Copyright (c) 2020 Philippe Proulx +# +# 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. + +--- ! +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 index 0000000..d382847 --- /dev/null +++ b/tests/tracing/configs/succeed/static-array/of-double.yaml @@ -0,0 +1,42 @@ +# The MIT License (MIT) +# +# Copyright (c) 2020 Philippe Proulx +# +# 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. + +--- ! +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 index 0000000..7dcf80e --- /dev/null +++ b/tests/tracing/configs/succeed/static-array/of-static-array-of-double.yaml @@ -0,0 +1,45 @@ +# The MIT License (MIT) +# +# Copyright (c) 2020 Philippe Proulx +# +# 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. + +--- ! +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 index 0000000..124828a --- /dev/null +++ b/tests/tracing/configs/succeed/static-array/of-static-array-of-str.yaml @@ -0,0 +1,45 @@ +# The MIT License (MIT) +# +# Copyright (c) 2020 Philippe Proulx +# +# 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. + +--- ! +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 index 0000000..daf11f6 --- /dev/null +++ b/tests/tracing/configs/succeed/static-array/of-static-array-of-uint8.yaml @@ -0,0 +1,45 @@ +# The MIT License (MIT) +# +# Copyright (c) 2020 Philippe Proulx +# +# 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. + +--- ! +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 index 0000000..8257add --- /dev/null +++ b/tests/tracing/configs/succeed/static-array/of-str.yaml @@ -0,0 +1,42 @@ +# The MIT License (MIT) +# +# Copyright (c) 2020 Philippe Proulx +# +# 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. + +--- ! +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 index 0000000..2a03030 --- /dev/null +++ b/tests/tracing/configs/succeed/static-array/of-uint3-middle.yaml @@ -0,0 +1,47 @@ +# The MIT License (MIT) +# +# Copyright (c) 2020 Philippe Proulx +# +# 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. + +--- ! +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 index 0000000..5859a61 --- /dev/null +++ b/tests/tracing/configs/succeed/static-array/of-uint3.yaml @@ -0,0 +1,44 @@ +# The MIT License (MIT) +# +# Copyright (c) 2020 Philippe Proulx +# +# 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. + +--- ! +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 index 0000000..31c8b2f --- /dev/null +++ b/tests/tracing/configs/succeed/static-array/of-uint8.yaml @@ -0,0 +1,42 @@ +# The MIT License (MIT) +# +# Copyright (c) 2020 Philippe Proulx +# +# 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. + +--- ! +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 index 0000000..92b34a1 --- /dev/null +++ b/tests/tracing/configs/succeed/static-array/zero-len.yaml @@ -0,0 +1,47 @@ +# The MIT License (MIT) +# +# Copyright (c) 2020 Philippe Proulx +# +# 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. + +--- ! +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 index 0000000..2c3366b --- /dev/null +++ b/tests/tracing/conftest.py @@ -0,0 +1,163 @@ +# The MIT License (MIT) +# +# Copyright (c) 2020 Philippe Proulx +# +# 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 index 0000000000000000000000000000000000000000..f5709c9e6a371c48937785c6568b36fb12feea10 GIT binary patch literal 512 zcmX>o|K}hB3. + */ + +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 index 0000000000000000000000000000000000000000..fb88dff25b512e78c95af49397a1139f92352716 GIT binary patch literal 512 zcmX>o|K}hB3KI`@ZFQVu{FuZnvc9p@}k-ub8fj6Fi- JC~GK%006#z5MlrT literal 0 HcmV?d00001 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 index 0000000..59e206d --- /dev/null +++ b/tests/tracing/expect/succeed/static-array/of-double.metadata.expect @@ -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 . + */ + +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 index 0000000000000000000000000000000000000000..ca0b3b6131614eafe8559886053a7145974c5ff3 GIT binary patch literal 512 zcmX>o|K}hB3-yq?m`1R8 P>e;i7XgWu^gERyHN0}4B literal 0 HcmV?d00001 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 index 0000000..79d17b9 --- /dev/null +++ b/tests/tracing/expect/succeed/static-array/of-static-array-of-double.metadata.expect @@ -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 . + */ + +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 index 0000000000000000000000000000000000000000..b697fed8b851bf0f96c3ef65e8e7e607b8963417 GIT binary patch literal 512 zcmX>o|K}hB3. + */ + +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 index 0000000000000000000000000000000000000000..c1f475de94241840d4e6422ea4a145504b490f0c GIT binary patch literal 512 jcmX>o|K}hB3. + */ + +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 index 0000000000000000000000000000000000000000..4628e39f14d378b2fd0c89667080cd58db149f5f GIT binary patch literal 512 tcmX>o|K}hB3. + */ + +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 index 0000000000000000000000000000000000000000..21745525e692fbcd637c92ad1258fcc6c162baf1 GIT binary patch literal 512 pcmX>o|K}hB3R~aMruw@z9Op3C~v5T003bF2a*5) literal 0 HcmV?d00001 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 index 0000000..282a2f0 --- /dev/null +++ b/tests/tracing/expect/succeed/static-array/of-uint3-middle.metadata.expect @@ -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 . + */ + +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 index 0000000000000000000000000000000000000000..38032a81c24056f61df49943965a4f5e927b3c4c GIT binary patch literal 512 fcmX>o|K}hB3o6Jl|RZGJ|O@Al>P(Z literal 0 HcmV?d00001 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 index 0000000..618f6e5 --- /dev/null +++ b/tests/tracing/expect/succeed/static-array/of-uint3.metadata.expect @@ -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 . + */ + +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 index 0000000000000000000000000000000000000000..846d84124e4b343cde370ed26e1118f690d61e33 GIT binary patch literal 512 kcmX>o|K}hB3. + */ + +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 index 0000000000000000000000000000000000000000..338d48ca170e14b74a801a60c0aec47f6243d6b9 GIT binary patch literal 512 hcmX>o|K}hB3. + */ + +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 index 0000000..f4a7635 --- /dev/null +++ b/tests/tracing/src/succeed/static-array/nested-5-uint8.c @@ -0,0 +1,71 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Philippe Proulx + * + * 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 +#include + +#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 index 0000000..448cccc --- /dev/null +++ b/tests/tracing/src/succeed/static-array/of-double.c @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Philippe Proulx + * + * 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 + +#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 index 0000000..5ad721d --- /dev/null +++ b/tests/tracing/src/succeed/static-array/of-static-array-of-double.c @@ -0,0 +1,42 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Philippe Proulx + * + * 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 + +#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 index 0000000..3b6b461 --- /dev/null +++ b/tests/tracing/src/succeed/static-array/of-static-array-of-str.c @@ -0,0 +1,42 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Philippe Proulx + * + * 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 + +#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 index 0000000..4ee6585 --- /dev/null +++ b/tests/tracing/src/succeed/static-array/of-static-array-of-uint8.c @@ -0,0 +1,43 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Philippe Proulx + * + * 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 +#include + +#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 index 0000000..36284a0 --- /dev/null +++ b/tests/tracing/src/succeed/static-array/of-str.c @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Philippe Proulx + * + * 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 + +#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 index 0000000..7326810 --- /dev/null +++ b/tests/tracing/src/succeed/static-array/of-uint3-middle.c @@ -0,0 +1,42 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Philippe Proulx + * + * 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 +#include + +#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 index 0000000..6028489 --- /dev/null +++ b/tests/tracing/src/succeed/static-array/of-uint3.c @@ -0,0 +1,41 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Philippe Proulx + * + * 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 +#include + +#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 index 0000000..ebf655a --- /dev/null +++ b/tests/tracing/src/succeed/static-array/of-uint8.c @@ -0,0 +1,41 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Philippe Proulx + * + * 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 +#include + +#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 index 0000000..15f29ff --- /dev/null +++ b/tests/tracing/src/succeed/static-array/zero-len.c @@ -0,0 +1,40 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016 Philippe Proulx + * + * 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 +#include + +#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 index 0000000..a572962 --- /dev/null +++ b/tests/tracing/support/Makefile @@ -0,0 +1,31 @@ +# The MIT License (MIT) +# +# Copyright (c) 2016-2020 Philippe Proulx +# +# 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 index 0000000..d060fab --- /dev/null +++ b/tests/tracing/support/test-platform.c @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2020 Philippe Proulx + * + * 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 +#include +#include +#include +#include + +#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 index 0000000..8632a5e --- /dev/null +++ b/tests/tracing/support/test-platform.h @@ -0,0 +1,37 @@ +#ifndef _BARECTF_TEST_PLATFORM_H +#define _BARECTF_TEST_PLATFORM_H + +/* + * Copyright (c) 2020 Philippe Proulx + * + * 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 + +#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 index 0000000..f815407 --- /dev/null +++ b/tests/tracing/test_succeed_static_array.py @@ -0,0 +1,61 @@ +# The MIT License (MIT) +# +# Copyright (c) 2020 Philippe Proulx +# +# 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() -- 2.34.1