pax_global_header00006660000000000000000000000064131714743510014520gustar00rootroot0000000000000052 comment=1249f43a5f5bf2525fdf861b2c695d759e6229aa barectf-2.3.0/000077500000000000000000000000001317147435100131305ustar00rootroot00000000000000barectf-2.3.0/.gitignore000066400000000000000000000013211317147435100151150ustar00rootroot00000000000000# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] # C extensions *.so # C objects *.o # Distribution / packaging .Python env/ build/ develop-eggs/ dist/ downloads/ eggs/ lib/ lib64/ parts/ sdist/ var/ *.egg-info/ .installed.cfg *.egg # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .cache nosetests.xml coverage.xml # Translations *.mo *.pot # Django stuff: *.log # Sphinx documentation docs/_build/ # PyBuilder target/ # Virtual environment virt/ barectf-2.3.0/CHANGELOG.md000066400000000000000000000123321317147435100147420ustar00rootroot00000000000000# barectf 2 changelog ## barectf v2.3.0 **Features**: * Add tracing activity and tracing section API to check whether or not the traced thread is currently within a barectf tracing function and to enable or disable tracing. **Tests**: * Add tox configuration. **Fixes**: * Fix various testing infrastructure issues. * Fix generated `bitfield.h` big-endian macros. ## barectf v2.2.1 **Minor improvements**: * barectf now generates ANSI C code. * The generated code can be compiled with a C++ compiler. **README.md**: * barectf claims to generate ANSI C code. * Reword some paragraphs. ## barectf v2.2.0 **Features**: * Add `$default` boolean property to stream objects, and `$default-stream` string property to the metadata object, to specify a _default stream_: when a default stream exists, tracing function aliases without the default stream name (`barectf_trace_my_event()`, for example) are also generated * Add `options` property to the configuration object, with: * `gen-prefix-def`: true to generate a preprocessor definition (`#define`) in `barectf.h` for the effective prefix * `gen-default-stream-def`: true to generate a preprocessor definition for the default stream name, if any * Create `barectf-tracepoint.h`, a bridging C header file that allows LTTng-UST tracepoints to be used as is with barectf by providing the same `tracepoint()` macro **Tests**: * Test the new `$default` (stream object), `$default-stream` (metadata object), and `options` (configuration object) properties **README.md**: * Add instructions for installing barectf on Arch Linux using the AUR * Add instructions for installing barectf on Ubuntu using a PPA ## barectf v2.1.4 **Minor improvements**: * Override default metadata `env` entries with user entries instead of the opposite * Statically align and compute the size of event fields when possible for the `_get_event_size_*()` functions when possible **Bug fixes**: * Do not write event's `stream_id` or stream's `id` when the trace packet header type has no `stream_id` field. **Tests**: * Add config test for multiple streams, no `stream_id` field in packet header type **README.md**: * Indicate how to install the command's man page ## barectf v2.1.3 **Minor improvements**: * Allow no or empty event payload type, as long as the event is not empty itself (contains at least one field in its 4 entities) **Tests**: * Remove no/empty event payload type config tests * Add config test for empty event **README.md**: * Add image on top * Add Community section ## barectf v2.1.2 **Bug fixes**: * Inherit from appropriate unsigned integer type aliases in `stdint.yaml` for self-aligned, signed integer type aliases ## barectf v2.1.1 **Bug fixes**: * Force clock offset object properties to their default values when set to `null` **README.md**: * Update Babeltrace's URL * Add `--python=python3` option to virtualenv line in the testing section ## barectf v2.1.0 **Features**: * Add `$include` property to metadata, clock, trace, stream, and event objects to [include external YAML files](https://github.com/efficios/barectf/wiki/Including-external-YAML-files) * Object properties which have a default value can force it with `null`; this is especially useful when also using type inheritance or including external YAML files **Bug fixes**: * Fix a few error messages * Use appropriate prefix for event context type parameters in generated code * `_write_cstring()`: use prefix * Enumeration type object: start from current last value when adding label-only members to parent object * Check the size of the `id` (event header) and `stream_id` (packet header) to make sure they can fit all events/streams * Reduce the number of compiler warnings when using `-Wall` and `-pedantic` * Make sure all entity types are structure types * Make sure all enumeration type object member values fit within the enumeration's value type * Check for unknown properties in enumeration type object * Check for unknown properties in floating point number size object * Check for unknown `base` values in integer type object * Check the type of the `byte-order` property in trace object * Check the signedness of the `uuid` field's element type in the trace packet header type * Check for unknown properties in configuration object * Check node type before checking its properties * Use unions to write floating point numbers to avoid aliasing warnings **Tests**: * Add configuration file tests **README.md**: * Add CI badge * Add C99 compliance limitation * Move documentation to the project's wiki ## barectf v2.0.2 **README.md**: * Add PyPI badge * Fix Arch Linux installation command line ## barectf v2.0.1 **Bug fixes**: * Fix various bugs in the Parallella platform ## barectf v2.0.0 Initial release. Major changes from barectf 0.x: * Single YAML configuration input * TSDL metadata is generated by barectf instead of being consumed * Introduction of platforms to handle buffers automatically with custom callbacks and to allow continuous tracing * Various optimizations in the generated C code barectf-2.3.0/LICENSE000066400000000000000000000021361317147435100141370ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2014-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. barectf-2.3.0/README.md000066400000000000000000000207721317147435100144170ustar00rootroot00000000000000![Icon made by Freepik from www.flaticon.com](https://lttng.org/blog/images/barectf.png) [![](https://img.shields.io/pypi/v/barectf.svg)](https://pypi.python.org/pypi/barectf) [![Jenkins](https://img.shields.io/jenkins/s/https/ci.lttng.org/barectf_master_build.svg)](https://ci.lttng.org/job/barectf_master_build) _**barectf**_ is a command-line generator of ANSI C tracers which output [Common Trace Format](http://diamon.org/ctf) packets natively. You will find barectf interesting if: 1. You need to trace an application. 2. You need tracing to be efficient, yet flexible: record integers of custom sizes and alignments, floating point numbers, enumerations supported by a specific integer type, and null-terminated UTF-8/ASCII strings (C strings). 3. You need to be able to convert the recorded binary events to human-readable text, as well as analyze them with Python scripts ([Babeltrace](http://diamon.org/babeltrace/) does all that, given a CTF input). [Trace Compass](http://tracecompass.org/) is another CTF-compatible application. 4. You _cannot_ use [LTTng](http://lttng.org/), an efficient tracing framework for the Linux kernel and Linux/BSD user applications, which also outputs CTF traces. The target audience of barectf is developers who need to trace [bare metal](https://en.wikipedia.org/wiki/Bare_machine) systems. The code produced by barectf is pure ANCI C (with one exception, see the current limitations below) and can be lightweight enough to fit on a tiny microcontroller. **Key features**: * Single input: easy-to-write [YAML configuration file](https://github.com/efficios/barectf/wiki/Writing-the-YAML-configuration-file). * 1-to-1 mapping from tracing function parameters to event fields. * Custom and bundled [_platforms_](https://github.com/efficios/barectf/wiki/barectf-platform) hiding the details of opening/closing packets and writing them to a back-end (continuous tracing), getting the clock values, etc.: * _linux-fs_: basic Linux application tracing platform which writes stream files to the file system for demonstration purposes. * _parallella_: Adapteva Epiphany/[Parallella](http://parallella.org/) with host-side consumer. * CTF metadata is generated by the command-line tool (automatic trace UUID, stream IDs, and event IDs). * All basic CTF types are supported: integers, floating point numbers, enumerations, and null-terminated strings (C strings). * Binary streams produced by the generated tracer and metadata file produced by barectf are CTF 1.8-compliant. * Human-readable error reporting at generation time. * barectf is written in Python 3, hence you can run the tool on various platforms. * Generated tracers are known to build with `gcc` (tested with the IA-32, x86-64, MIPS, ARM, and AVR architectures), `g++`, `clang`, `clang++`, [`8cc`](https://github.com/rui314/8cc), [`tcc`](http://bellard.org/tcc/), VS2008 (with a custom `stdint.h`), and VS2010. **Current limitations**: As of this version: * All the generated tracing C functions, for a given barectf stream-specific context, need to be called from the same thread, and cannot be called from an interrupt handler, _unless_ a user-provided synchronization mechanism is used. * The generated C code needs the `stdint.h` header, which is new in C99. If your standard C library does not have this header, you can create one yourself and put it in one of your include directories to define the following types according to your architecture: * `int8_t` * `int16_t` * `int32_t` * `int64_t` * `uint8_t` * `uint16_t` * `uint32_t` * `uint64_t` * CTF compound types (array, sequence, structure, variant) are not supported yet, except at some very specific locations in the metadata. ## Installing Make sure you have Python 3 and `pip` for Python 3 installed, then install barectf. Note that you may pass the `--user` argument to `pip install` to install the tool in your home directory (instead of installing globally). **Ubuntu 14.04 and 16.04**: It is recommended to use the [barectf PPA](https://launchpad.net/~lttng/+archive/ubuntu/barectf), which also installs the man page: sudo apt-add-repository ppa:lttng/barectf sudo apt-get update sudo apt-get install python3-barectf Otherwise, you can always use `pip3`: sudo apt-get install python3-pip sudo pip3 install barectf **Other, recent Ubuntu**: sudo apt-get install python3-pip sudo pip3 install barectf **Ubuntu 12.04 and lower**: sudo apt-get install python3-setuptools sudo easy_install3 pip sudo pip3 install barectf **Debian**: sudo apt-get install python3-pip sudo pip3 install barectf **Fedora 20 and up**: sudo yum install python3-pip sudo pip3 install barectf **Arch Linux**: It is recommended to use the [AUR package](https://aur.archlinux.org/packages/barectf/), which also installs the man page. If you have [yaourt](https://archlinux.fr/yaourt-en): sudo yaourt -Sy barectf Otherwise, you can always use `pip`: sudo pacman -S python-pip sudo pip install barectf **macOS (OS X)**: With [Homebrew](http://brew.sh/): brew install python3 pip3 install barectf ### Man page Since the philosophy of setuptools packages is to include everything within the package, the barectf man page is not installed on the system when installing barectf with `pip` or with `setup.py`. This would be the job of distribution packages. You can install it manually: wget https://raw.githubusercontent.com/efficios/barectf/vVERSION/doc/man/barectf.1 -O /usr/local/man/man1/barectf.1 Replace `VERSION` with the desired version, for example: wget https://raw.githubusercontent.com/efficios/barectf/v2.1.4/doc/man/barectf.1 -O /usr/local/man/man1/barectf.1 ## What is CTF? See the [CTF in a nutshell](http://diamon.org/ctf/#ctf-in-a-nutshell) section of CTF's website to understand the basics of this trace format. The most important thing to understand about CTF, for barectf use cases, is the layout of a binary stream packet: * Packet header (defined at the trace level) * Packet context (defined at the stream level) * Sequence of events (defined at the stream level): * Event header (defined at the stream level) * Stream event context (defined at the stream level) * Event context (defined at the event level) * Event payload (defined at the event level) The following diagram, stolen without remorse from CTF's website, shows said packet layout: ![](http://diamon.org/ctf/img/ctf-stream-packet.png) Any of those six dynamic scopes, if defined at all, has an associated CTF type. barectf requires them to be structure types. ## Using See the [project's wiki](https://github.com/efficios/barectf/wiki) which contains all the information needed to use barectf. ## Testing Bash is required for testing barectf. The barectf tests execute the `barectf` command available in your `$PATH`. The best way to test a specific version of barectf is to create a Python 3 [virtual environment](https://virtualenv.pypa.io/en/latest/), install the appropriate version, and then run the tests. In the barectf source tree root, do: virtualenv --python=python3 virt . ./virt/bin/activate rehash # if using zsh ./setup.py install (cd tests && ./test.bash) You can specify [Bats](https://github.com/sstephenson/bats) options to `./test.bash`, like `--tap` to get a [TAP](https://testanything.org/) output. You can exit the virtual environment by running `deactivate`. ## Community Since the barectf community is small, it's sharing the communication channels of the [LTTng](http://lttng.org/) project, as [EfficiOS](http://www.efficios.com/) is the main sponsor of both projects. It goes like this: | Item | Location | Notes | | --- | --- | --- | | Mailing list | [lttng-dev](https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev) (`lttng-dev@lists.lttng.org`) | Preferably, use the `[barectf]` subject prefix | | IRC | [`#lttng`](irc://irc.oftc.net/lttng) on the OFTC network | More specifically, query `eepp` (barectf's maintainer) on this network or on freenode | | Code contribution | Create a new GitHub [pull request](https://github.com/efficios/barectf/pulls) | | | Bug reporting | Create a new GitHub [issue](https://github.com/efficios/barectf/issues/new) | | | Continuous integration | [barectf item on LTTng's CI](https://ci.lttng.org/job/barectf/) | | | Blog | The [LTTng blog](http://lttng.org/blog/) contains many posts about barectf | | barectf-2.3.0/barectf/000077500000000000000000000000001317147435100145365ustar00rootroot00000000000000barectf-2.3.0/barectf/__init__.py000066400000000000000000000030611317147435100166470ustar00rootroot00000000000000# The MIT License (MIT) # # Copyright (c) 2014-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. __version__ = '2.3.0' def _split_version_suffix(): parts = __version__.split('-') version = parts[0] suffix = None if len(parts) == 2: suffix = parts[1] return version, suffix def get_version_tuple(): version, suffix = _split_version_suffix() parts = version.split('.') return (int(parts[0]), int(parts[1]), int(parts[2])) def get_version_suffix(): return _split_version_suffix()[1] barectf-2.3.0/barectf/cli.py000066400000000000000000000134731317147435100156670ustar00rootroot00000000000000# The MIT License (MIT) # # Copyright (c) 2014-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. from pkg_resources import resource_filename from termcolor import cprint, colored import barectf.tsdl182gen import barectf.config import barectf.gen import argparse import os.path import barectf import sys import os import re def _perror(msg): cprint('Error: ', 'red', end='', file=sys.stderr) cprint(msg, 'red', attrs=['bold'], file=sys.stderr) sys.exit(1) def _pconfig_error(e): lines = [] while True: if e is None: break lines.append(str(e)) if not hasattr(e, 'prev'): break e = e.prev if len(lines) == 1: _perror(lines[0]) cprint('Error:', 'red', file=sys.stderr) for i, line in enumerate(lines): suf = ':' if i < len(lines) - 1 else '' cprint(' ' + line + suf, 'red', attrs=['bold'], file=sys.stderr) sys.exit(1) def _psuccess(msg): cprint('{}'.format(msg), 'green', attrs=['bold']) def _parse_args(): ap = argparse.ArgumentParser() ap.add_argument('-c', '--code-dir', metavar='DIR', action='store', default=os.getcwd(), help='output directory of C source file') ap.add_argument('--dump-config', action='store_true', help='also dump the effective YAML configuration file used for generation') ap.add_argument('-H', '--headers-dir', metavar='DIR', action='store', default=os.getcwd(), help='output directory of C header files') ap.add_argument('-I', '--include-dir', metavar='DIR', action='append', default=[], help='add directory DIR to the list of directories to be searched for include files') ap.add_argument('--ignore-include-not-found', action='store_true', help='continue to process the configuration file when included files are not found') ap.add_argument('-m', '--metadata-dir', metavar='DIR', action='store', default=os.getcwd(), help='output directory of CTF metadata') ap.add_argument('-p', '--prefix', metavar='PREFIX', action='store', help='override configuration\'s prefix') ap.add_argument('-V', '--version', action='version', version='%(prog)s {}'.format(barectf.__version__)) ap.add_argument('config', metavar='CONFIG', action='store', help='barectf YAML configuration file') # parse args args = ap.parse_args() # validate output directories for d in [args.code_dir, args.headers_dir, args.metadata_dir] + args.include_dir: if not os.path.isdir(d): _perror('"{}" is not an existing directory'.format(d)) # validate that configuration file exists if not os.path.isfile(args.config): _perror('"{}" is not an existing, regular file'.format(args.config)) # append current working directory and provided include directory args.include_dir += [os.getcwd(), resource_filename(__name__, 'include')] return args def _write_file(d, name, content): with open(os.path.join(d, name), 'w') as f: f.write(content) def run(): # parse arguments args = _parse_args() # create configuration try: config = barectf.config.from_yaml_file(args.config, args.include_dir, args.ignore_include_not_found, args.dump_config) except barectf.config.ConfigError as e: _pconfig_error(e) except Exception as e: _perror('unknown exception: {}'.format(e)) # replace prefix if needed if args.prefix: try: config.prefix = args.prefix except barectf.config.ConfigError as e: _pconfig_error(e) # generate metadata metadata = barectf.tsdl182gen.from_metadata(config.metadata) try: _write_file(args.metadata_dir, 'metadata', metadata) except Exception as e: _perror('cannot write metadata file: {}'.format(e)) # create generator generator = barectf.gen.CCodeGenerator(config) # generate C headers header = generator.generate_header() bitfield_header = generator.generate_bitfield_header() try: _write_file(args.headers_dir, generator.get_header_filename(), header) _write_file(args.headers_dir, generator.get_bitfield_header_filename(), bitfield_header) except Exception as e: _perror('cannot write header files: {}'.format(e)) # generate C source c_src = generator.generate_c_src() try: _write_file(args.code_dir, '{}.c'.format(config.prefix.rstrip('_')), c_src) except Exception as e: _perror('cannot write C source file: {}'.format(e)) barectf-2.3.0/barectf/codegen.py000066400000000000000000000050171317147435100165170ustar00rootroot00000000000000# The MIT License (MIT) # # Copyright (c) 2015 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. class CodeGenerator: def __init__(self, indent_string): self._indent_string = indent_string self.reset() @property def code(self): return '\n'.join(self._lines) def reset(self): self._lines = [] self._indent = 0 self._glue = False def add_line(self, line): if self._glue: self.append_to_last_line(line) self._glue = False return indent_string = self._get_indent_string() self._lines.append(indent_string + str(line)) def add_lines(self, lines): if type(lines) is str: lines = lines.split('\n') for line in lines: self.add_line(line) def add_glue(self): self._glue = True def append_to_last_line(self, s): if self._lines: self._lines[-1] += str(s) def add_empty_line(self): self._lines.append('') def add_cc_line(self, comment): self.add_line('/* {} */'.format(comment)) def append_cc_to_last_line(self, comment, with_space=True): if with_space: sp = ' ' else: sp = '' self.append_to_last_line('{}/* {} */'.format(sp, comment)) def indent(self): self._indent += 1 def unindent(self): self._indent = max(self._indent - 1, 0) def _get_indent_string(self): return self._indent_string * self._indent barectf-2.3.0/barectf/config.py000066400000000000000000003121211317147435100163550ustar00rootroot00000000000000# The MIT License (MIT) # # Copyright (c) 2015-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. from barectf import metadata import collections import datetime import barectf import enum import yaml import uuid import copy import re import os class ConfigError(RuntimeError): def __init__(self, msg, prev=None): super().__init__(msg) self._prev = prev @property def prev(self): return self._prev class Config: def __init__(self, version, prefix, metadata, options): self.prefix = prefix self.version = version self.metadata = metadata self.options = options def _validate_metadata(self, meta): try: validator = _MetadataTypesHistologyValidator() validator.validate(meta) validator = _MetadataDynamicTypesValidator() validator.validate(meta) validator = _MetadataSpecialFieldsValidator() validator.validate(meta) except Exception as e: raise ConfigError('metadata error', e) try: validator = _BarectfMetadataValidator() validator.validate(meta) except Exception as e: raise ConfigError('barectf metadata error', e) def _augment_metadata_env(self, meta): version_tuple = barectf.get_version_tuple() base_env = { 'domain': 'bare', 'tracer_name': 'barectf', 'tracer_major': version_tuple[0], 'tracer_minor': version_tuple[1], 'tracer_patch': version_tuple[2], 'barectf_gen_date': str(datetime.datetime.now().isoformat()), } base_env.update(meta.env) meta.env = base_env @property def version(self): return self._version @version.setter def version(self, value): self._version = value @property def metadata(self): return self._metadata @metadata.setter def metadata(self, value): self._validate_metadata(value) self._augment_metadata_env(value) self._metadata = value @property def prefix(self): return self._prefix @prefix.setter def prefix(self, value): if not _is_valid_identifier(value): raise ConfigError('configuration prefix must be a valid C identifier') self._prefix = value @property def options(self): return self._options @options.setter def options(self, options): self._options = options class ConfigOptions: def __init__(self): self._gen_prefix_def = False self._gen_default_stream_def = False @property def gen_prefix_def(self): return self._gen_prefix_def @gen_prefix_def.setter def gen_prefix_def(self, value): self._gen_prefix_def = value @property def gen_default_stream_def(self): return self._gen_default_stream_def @gen_default_stream_def.setter def gen_default_stream_def(self, value): self._gen_default_stream_def = value def _is_assoc_array_prop(node): return isinstance(node, dict) def _is_array_prop(node): return isinstance(node, list) def _is_int_prop(node): return type(node) is int def _is_str_prop(node): return type(node) is str def _is_bool_prop(node): return type(node) is bool def _is_valid_alignment(align): return ((align & (align - 1)) == 0) and align > 0 def _byte_order_str_to_bo(bo_str): bo_str = bo_str.lower() if bo_str == 'le': return metadata.ByteOrder.LE elif bo_str == 'be': return metadata.ByteOrder.BE def _encoding_str_to_encoding(encoding_str): encoding_str = encoding_str.lower() if encoding_str == 'utf-8' or encoding_str == 'utf8': return metadata.Encoding.UTF8 elif encoding_str == 'ascii': return metadata.Encoding.ASCII elif encoding_str == 'none': return metadata.Encoding.NONE _re_iden = re.compile(r'^[a-zA-Z][a-zA-Z0-9_]*$') _ctf_keywords = set([ 'align', 'callsite', 'clock', 'enum', 'env', 'event', 'floating_point', 'integer', 'stream', 'string', 'struct', 'trace', 'typealias', 'typedef', 'variant', ]) def _is_valid_identifier(iden): if not _re_iden.match(iden): return False if _re_iden in _ctf_keywords: return False return True def _get_first_unknown_prop(node, known_props): for prop_name in node: if prop_name in known_props: continue return prop_name # This validator validates the configured metadata for barectf specific # needs. # # barectf needs: # # * all header/contexts are at least byte-aligned # * all integer and floating point number sizes to be <= 64 # * no inner structures, arrays, or variants class _BarectfMetadataValidator: def __init__(self): self._type_to_validate_type_func = { metadata.Integer: self._validate_int_type, metadata.FloatingPoint: self._validate_float_type, metadata.Enum: self._validate_enum_type, metadata.String: self._validate_string_type, metadata.Struct: self._validate_struct_type, metadata.Array: self._validate_array_type, metadata.Variant: self._validate_variant_type, } def _validate_int_type(self, t, entity_root): if t.size > 64: raise ConfigError('integer type\'s size must be lesser than or equal to 64 bits') def _validate_float_type(self, t, entity_root): if t.size > 64: raise ConfigError('floating point number type\'s size must be lesser than or equal to 64 bits') def _validate_enum_type(self, t, entity_root): if t.value_type.size > 64: raise ConfigError('enumeration type\'s integer type\'s size must be lesser than or equal to 64 bits') def _validate_string_type(self, t, entity_root): pass def _validate_struct_type(self, t, entity_root): if not entity_root: raise ConfigError('inner structure types are not supported as of this version') for field_name, field_type in t.fields.items(): if entity_root and self._cur_entity is _Entity.TRACE_PACKET_HEADER: if field_name == 'uuid': # allow continue try: self._validate_type(field_type, False) except Exception as e: raise ConfigError('in structure type\'s field "{}"'.format(field_name), e) def _validate_array_type(self, t, entity_root): raise ConfigError('array types are not supported as of this version') def _validate_variant_type(self, t, entity_root): raise ConfigError('variant types are not supported as of this version') def _validate_type(self, t, entity_root): self._type_to_validate_type_func[type(t)](t, entity_root) def _validate_entity(self, t): if t is None: return # make sure entity is byte-aligned if t.align < 8: raise ConfigError('type\'s alignment must be at least byte-aligned') # make sure entity is a structure if type(t) is not metadata.Struct: raise ConfigError('expecting a structure type') # validate types self._validate_type(t, True) def _validate_entities_and_names(self, meta): self._cur_entity = _Entity.TRACE_PACKET_HEADER try: self._validate_entity(meta.trace.packet_header_type) except Exception as e: raise ConfigError('invalid trace packet header type', e) for stream_name, stream in meta.streams.items(): if not _is_valid_identifier(stream_name): raise ConfigError('stream name "{}" is not a valid C identifier'.format(stream_name)) self._cur_entity = _Entity.STREAM_PACKET_CONTEXT try: self._validate_entity(stream.packet_context_type) except Exception as e: raise ConfigError('invalid packet context type in stream "{}"'.format(stream_name), e) self._cur_entity = _Entity.STREAM_EVENT_HEADER try: self._validate_entity(stream.event_header_type) except Exception as e: raise ConfigError('invalid event header type in stream "{}"'.format(stream_name), e) self._cur_entity = _Entity.STREAM_EVENT_CONTEXT try: self._validate_entity(stream.event_context_type) except Exception as e: raise ConfigError('invalid event context type in stream "{}"'.format(stream_name), e) try: for ev_name, ev in stream.events.items(): if not _is_valid_identifier(ev_name): raise ConfigError('event name "{}" is not a valid C identifier'.format(ev_name)) self._cur_entity = _Entity.EVENT_CONTEXT try: self._validate_entity(ev.context_type) except Exception as e: raise ConfigError('invalid context type in event "{}"'.format(ev_name), e) self._cur_entity = _Entity.EVENT_PAYLOAD try: self._validate_entity(ev.payload_type) except Exception as e: raise ConfigError('invalid payload type in event "{}"'.format(ev_name), e) if stream.is_event_empty(ev): raise ConfigError('event "{}" is empty'.format(ev_name)) except Exception as e: raise ConfigError('invalid stream "{}"'.format(stream_name), e) def _validate_default_stream(self, meta): if meta.default_stream_name: if meta.default_stream_name not in meta.streams.keys(): raise ConfigError('default stream name ("{}") does not exist'.format(meta.default_stream_name)) def validate(self, meta): self._validate_entities_and_names(meta) self._validate_default_stream(meta) # This validator validates special fields of trace, stream, and event # types. For example, if checks that the "stream_id" field exists in the # trace packet header if there's more than one stream, and much more. class _MetadataSpecialFieldsValidator: def _validate_trace_packet_header_type(self, t): # needs "stream_id" field? if len(self._meta.streams) > 1: # yes if t is None: raise ConfigError('need "stream_id" field in trace packet header type (more than one stream), but trace packet header type is missing') if type(t) is not metadata.Struct: raise ConfigError('need "stream_id" field in trace packet header type (more than one stream), but trace packet header type is not a structure type') if 'stream_id' not in t.fields: raise ConfigError('need "stream_id" field in trace packet header type (more than one stream)') # validate "magic" and "stream_id" types if type(t) is not metadata.Struct: return for i, (field_name, field_type) in enumerate(t.fields.items()): if field_name == 'magic': if type(field_type) is not metadata.Integer: raise ConfigError('"magic" field in trace packet header type must be an integer type') if field_type.signed or field_type.size != 32: raise ConfigError('"magic" field in trace packet header type must be a 32-bit unsigned integer type') if i != 0: raise ConfigError('"magic" field must be the first trace packet header type\'s field') elif field_name == 'stream_id': if type(field_type) is not metadata.Integer: raise ConfigError('"stream_id" field in trace packet header type must be an integer type') if field_type.signed: raise ConfigError('"stream_id" field in trace packet header type must be an unsigned integer type') # "id" size can fit all event IDs if len(self._meta.streams) > (1 << field_type.size): raise ConfigError('"stream_id" field\' size in trace packet header type is too small for the number of trace streams') elif field_name == 'uuid': if self._meta.trace.uuid is None: raise ConfigError('"uuid" field in trace packet header type specified, but no trace UUID provided') if type(field_type) is not metadata.Array: raise ConfigError('"uuid" field in trace packet header type must be an array') if field_type.length != 16: raise ConfigError('"uuid" field in trace packet header type must be an array of 16 bytes') element_type = field_type.element_type if type(element_type) is not metadata.Integer: raise ConfigError('"uuid" field in trace packet header type must be an array of 16 unsigned bytes') if element_type.size != 8: raise ConfigError('"uuid" field in trace packet header type must be an array of 16 unsigned bytes') if element_type.signed: raise ConfigError('"uuid" field in trace packet header type must be an array of 16 unsigned bytes') if element_type.align != 8: raise ConfigError('"uuid" field in trace packet header type must be an array of 16 unsigned, byte-aligned bytes') def _validate_trace(self, meta): self._validate_trace_packet_header_type(meta.trace.packet_header_type) def _validate_stream_packet_context(self, stream): t = stream.packet_context_type if type(t) is None: raise ConfigError('missing "packet-context-type" property in stream object') if type(t) is not metadata.Struct: raise ConfigError('"packet-context-type": expecting a structure type') # "timestamp_begin", if exists, is an unsigned integer type, # mapped to a clock ts_begin = None if 'timestamp_begin' in t.fields: ts_begin = t.fields['timestamp_begin'] if type(ts_begin) is not metadata.Integer: raise ConfigError('"timestamp_begin" field in stream packet context type must be an integer type') if ts_begin.signed: raise ConfigError('"timestamp_begin" field in stream packet context type must be an unsigned integer type') if not ts_begin.property_mappings: raise ConfigError('"timestamp_begin" field in stream packet context type must be mapped to a clock') # "timestamp_end", if exists, is an unsigned integer type, # mapped to a clock ts_end = None if 'timestamp_end' in t.fields: ts_end = t.fields['timestamp_end'] if type(ts_end) is not metadata.Integer: raise ConfigError('"timestamp_end" field in stream packet context type must be an integer type') if ts_end.signed: raise ConfigError('"timestamp_end" field in stream packet context type must be an unsigned integer type') if not ts_end.property_mappings: raise ConfigError('"timestamp_end" field in stream packet context type must be mapped to a clock') # "timestamp_begin" and "timestamp_end" exist together if (('timestamp_begin' in t.fields) ^ ('timestamp_end' in t.fields)): raise ConfigError('"timestamp_begin" and "timestamp_end" fields must be defined together in stream packet context type') # "timestamp_begin" and "timestamp_end" are mapped to the same clock if ts_begin is not None and ts_end is not None: if ts_begin.property_mappings[0].object.name != ts_end.property_mappings[0].object.name: raise ConfigError('"timestamp_begin" and "timestamp_end" fields must be mapped to the same clock object in stream packet context type') # "events_discarded", if exists, is an unsigned integer type if 'events_discarded' in t.fields: events_discarded = t.fields['events_discarded'] if type(events_discarded) is not metadata.Integer: raise ConfigError('"events_discarded" field in stream packet context type must be an integer type') if events_discarded.signed: raise ConfigError('"events_discarded" field in stream packet context type must be an unsigned integer type') # "packet_size" and "content_size" must exist if 'packet_size' not in t.fields: raise ConfigError('missing "packet_size" field in stream packet context type') packet_size = t.fields['packet_size'] # "content_size" and "content_size" must exist if 'content_size' not in t.fields: raise ConfigError('missing "content_size" field in stream packet context type') content_size = t.fields['content_size'] # "packet_size" is an unsigned integer type if type(packet_size) is not metadata.Integer: raise ConfigError('"packet_size" field in stream packet context type must be an integer type') if packet_size.signed: raise ConfigError('"packet_size" field in stream packet context type must be an unsigned integer type') # "content_size" is an unsigned integer type if type(content_size) is not metadata.Integer: raise ConfigError('"content_size" field in stream packet context type must be an integer type') if content_size.signed: raise ConfigError('"content_size" field in stream packet context type must be an unsigned integer type') # "packet_size" size should be greater than or equal to "content_size" size if content_size.size > packet_size.size: raise ConfigError('"content_size" field size must be lesser than or equal to "packet_size" field size') def _validate_stream_event_header(self, stream): t = stream.event_header_type # needs "id" field? if len(stream.events) > 1: # yes if t is None: raise ConfigError('need "id" field in stream event header type (more than one event), but stream event header type is missing') if type(t) is not metadata.Struct: raise ConfigError('need "id" field in stream event header type (more than one event), but stream event header type is not a structure type') if 'id' not in t.fields: raise ConfigError('need "id" field in stream event header type (more than one event)') # validate "id" and "timestamp" types if type(t) is not metadata.Struct: return # "timestamp", if exists, is an unsigned integer type, # mapped to a clock if 'timestamp' in t.fields: ts = t.fields['timestamp'] if type(ts) is not metadata.Integer: raise ConfigError('"timestamp" field in stream event header type must be an integer type') if ts.signed: raise ConfigError('"timestamp" field in stream event header type must be an unsigned integer type') if not ts.property_mappings: raise ConfigError('"timestamp" field in stream event header type must be mapped to a clock') if 'id' in t.fields: eid = t.fields['id'] # "id" is an unsigned integer type if type(eid) is not metadata.Integer: raise ConfigError('"id" field in stream event header type must be an integer type') if eid.signed: raise ConfigError('"id" field in stream event header type must be an unsigned integer type') # "id" size can fit all event IDs if len(stream.events) > (1 << eid.size): raise ConfigError('"id" field\' size in stream event header type is too small for the number of stream events') def _validate_stream(self, stream): self._validate_stream_packet_context(stream) self._validate_stream_event_header(stream) def validate(self, meta): self._meta = meta self._validate_trace(meta) for stream in meta.streams.values(): try: self._validate_stream(stream) except Exception as e: raise ConfigError('invalid stream "{}"'.format(stream.name), e) class _MetadataDynamicTypesValidatorStackEntry: def __init__(self, base_t): self._base_t = base_t self._index = 0 @property def index(self): return self._index @index.setter def index(self, value): self._index = value @property def base_t(self): return self._base_t @base_t.setter def base_t(self, value): self._base_t = value # Entities. Order of values is important here. @enum.unique class _Entity(enum.IntEnum): TRACE_PACKET_HEADER = 0 STREAM_PACKET_CONTEXT = 1 STREAM_EVENT_HEADER = 2 STREAM_EVENT_CONTEXT = 3 EVENT_CONTEXT = 4 EVENT_PAYLOAD = 5 # This validator validates dynamic metadata types, that is, it ensures # variable-length array lengths and variant tags actually point to # something that exists. It also checks that variable-length array # lengths point to integer types and variant tags to enumeration types. class _MetadataDynamicTypesValidator: def __init__(self): self._type_to_visit_type_func = { metadata.Integer: None, metadata.FloatingPoint: None, metadata.Enum: None, metadata.String: None, metadata.Struct: self._visit_struct_type, metadata.Array: self._visit_array_type, metadata.Variant: self._visit_variant_type, } self._cur_trace = None self._cur_stream = None self._cur_event = None def _lookup_path_from_base(self, path, parts, base, start_index, base_is_current, from_t): index = start_index cur_t = base found_path = [] while index < len(parts): part = parts[index] next_t = None if type(cur_t) is metadata.Struct: enumerated_items = enumerate(cur_t.fields.items()) # lookup each field for i, (field_name, field_type) in enumerated_items: if field_name == part: next_t = field_type found_path.append((i, field_type)) if next_t is None: raise ConfigError('invalid path "{}": cannot find field "{}" in structure type'.format(path, part)) elif type(cur_t) is metadata.Variant: enumerated_items = enumerate(cur_t.types.items()) # lookup each type for i, (type_name, type_type) in enumerated_items: if type_name == part: next_t = type_type found_path.append((i, type_type)) if next_t is None: raise ConfigError('invalid path "{}": cannot find type "{}" in variant type'.format(path, part)) else: raise ConfigError('invalid path "{}": requesting "{}" in a non-variant, non-structure type'.format(path, part)) cur_t = next_t index += 1 # make sure that the pointed type is not the pointing type if from_t is cur_t: raise ConfigError('invalid path "{}": pointing to self'.format(path)) # if we're here, we found the type; however, it could be located # _after_ the variant/VLA looking for it, if the pointing # and pointed types are in the same entity, so compare the # current stack entries indexes to our index path in that case if not base_is_current: return cur_t for index, entry in enumerate(self._stack): if index == len(found_path): # end of index path; valid so far break if found_path[index][0] > entry.index: raise ConfigError('invalid path "{}": pointed type is after pointing type'.format(path)) # also make sure that both pointed and pointing types share # a common structure ancestor for index, entry in enumerate(self._stack): if index == len(found_path): break if entry.base_t is not found_path[index][1]: # found common ancestor if type(entry.base_t) is metadata.Variant: raise ConfigError('invalid path "{}": type cannot be reached because pointed and pointing types are in the same variant type'.format(path)) return cur_t def _lookup_path_from_top(self, path, parts): if len(parts) != 1: raise ConfigError('invalid path "{}": multipart relative path not supported'.format(path)) find_name = parts[0] index = len(self._stack) - 1 got_struct = False # check stack entries in reversed order for entry in reversed(self._stack): # structure base type if type(entry.base_t) is metadata.Struct: got_struct = True enumerated_items = enumerate(entry.base_t.fields.items()) # lookup each field, until the current visiting index is met for i, (field_name, field_type) in enumerated_items: if i == entry.index: break if field_name == find_name: return field_type # variant base type elif type(entry.base_t) is metadata.Variant: enumerated_items = enumerate(entry.base_t.types.items()) # lookup each type, until the current visiting index is met for i, (type_name, type_type) in enumerated_items: if i == entry.index: break if type_name == find_name: if not got_struct: raise ConfigError('invalid path "{}": type cannot be reached because pointed and pointing types are in the same variant type'.format(path)) return type_type # nothing returned here: cannot find type raise ConfigError('invalid path "{}": cannot find type in current context'.format(path)) def _lookup_path(self, path, from_t): parts = path.lower().split('.') base = None base_is_current = False if len(parts) >= 3: if parts[0] == 'trace': if parts[1] == 'packet' and parts[2] == 'header': # make sure packet header exists if self._cur_trace.packet_header_type is None: raise ConfigError('invalid path "{}": no defined trace packet header type'.format(path)) base = self._cur_trace.packet_header_type if self._cur_entity == _Entity.TRACE_PACKET_HEADER: base_is_current = True else: raise ConfigError('invalid path "{}": unknown names after "trace"'.format(path)) elif parts[0] == 'stream': if parts[1] == 'packet' and parts[2] == 'context': if self._cur_entity < _Entity.STREAM_PACKET_CONTEXT: raise ConfigError('invalid path "{}": cannot access stream packet context here'.format(path)) if self._cur_stream.packet_context_type is None: raise ConfigError('invalid path "{}": no defined stream packet context type'.format(path)) base = self._cur_stream.packet_context_type if self._cur_entity == _Entity.STREAM_PACKET_CONTEXT: base_is_current = True elif parts[1] == 'event': if parts[2] == 'header': if self._cur_entity < _Entity.STREAM_EVENT_HEADER: raise ConfigError('invalid path "{}": cannot access stream event header here'.format(path)) if self._cur_stream.event_header_type is None: raise ConfigError('invalid path "{}": no defined stream event header type'.format(path)) base = self._cur_stream.event_header_type if self._cur_entity == _Entity.STREAM_EVENT_HEADER: base_is_current = True elif parts[2] == 'context': if self._cur_entity < _Entity.STREAM_EVENT_CONTEXT: raise ConfigError('invalid path "{}": cannot access stream event context here'.format(path)) if self._cur_stream.event_context_type is None: raise ConfigError('invalid path "{}": no defined stream event context type'.format(path)) base = self._cur_stream.event_context_type if self._cur_entity == _Entity.STREAM_EVENT_CONTEXT: base_is_current = True else: raise ConfigError('invalid path "{}": unknown names after "stream.event"'.format(path)) else: raise ConfigError('invalid path "{}": unknown names after "stream"'.format(path)) if base is not None: start_index = 3 if len(parts) >= 2 and base is None: if parts[0] == 'event': if parts[1] == 'context': if self._cur_entity < _Entity.EVENT_CONTEXT: raise ConfigError('invalid path "{}": cannot access event context here'.format(path)) if self._cur_event.context_type is None: raise ConfigError('invalid path "{}": no defined event context type'.format(path)) base = self._cur_event.context_type if self._cur_entity == _Entity.EVENT_CONTEXT: base_is_current = True elif parts[1] == 'payload' or parts[1] == 'fields': if self._cur_entity < _Entity.EVENT_PAYLOAD: raise ConfigError('invalid path "{}": cannot access event payload here'.format(path)) if self._cur_event.payload_type is None: raise ConfigError('invalid path "{}": no defined event payload type'.format(path)) base = self._cur_event.payload_type if self._cur_entity == _Entity.EVENT_PAYLOAD: base_is_current = True else: raise ConfigError('invalid path "{}": unknown names after "event"'.format(path)) if base is not None: start_index = 2 if base is not None: return self._lookup_path_from_base(path, parts, base, start_index, base_is_current, from_t) else: return self._lookup_path_from_top(path, parts) def _stack_reset(self): self._stack = [] def _stack_push(self, base_t): entry = _MetadataDynamicTypesValidatorStackEntry(base_t) self._stack.append(entry) def _stack_pop(self): self._stack.pop() def _stack_incr_index(self): self._stack[-1].index += 1 def _visit_struct_type(self, t): self._stack_push(t) for field_name, field_type in t.fields.items(): try: self._visit_type(field_type) except Exception as e: raise ConfigError('in structure type\'s field "{}"'.format(field_name), e) self._stack_incr_index() self._stack_pop() def _visit_array_type(self, t): if t.is_variable_length: # find length type try: length_type = self._lookup_path(t.length, t) except Exception as e: raise ConfigError('invalid array type\'s length', e) # make sure length type an unsigned integer if type(length_type) is not metadata.Integer: raise ConfigError('array type\'s length does not point to an integer type') if length_type.signed: raise ConfigError('array type\'s length does not point to an unsigned integer type') self._visit_type(t.element_type) def _visit_variant_type(self, t): # find tag type try: tag_type = self._lookup_path(t.tag, t) except Exception as e: raise ConfigError('invalid variant type\'s tag', e) # make sure tag type is an enumeration if type(tag_type) is not metadata.Enum: raise ConfigError('variant type\'s tag does not point to an enumeration type') # verify that each variant type's type exists as an enumeration member for tag_name in t.types.keys(): if tag_name not in tag_type.members: raise ConfigError('cannot find variant type\'s type "{}" in pointed tag type'.format(tag_name)) self._stack_push(t) for type_name, type_type in t.types.items(): try: self._visit_type(type_type) except Exception as e: raise ConfigError('in variant type\'s type "{}"'.format(type_name), e) self._stack_incr_index() self._stack_pop() def _visit_type(self, t): if t is None: return if type(t) in self._type_to_visit_type_func: func = self._type_to_visit_type_func[type(t)] if func is not None: func(t) def _visit_event(self, ev): ev_name = ev.name # set current event self._cur_event = ev # visit event context type self._stack_reset() self._cur_entity = _Entity.EVENT_CONTEXT try: self._visit_type(ev.context_type) except Exception as e: raise ConfigError('invalid context type in event "{}"'.format(ev_name), e) # visit event payload type self._stack_reset() self._cur_entity = _Entity.EVENT_PAYLOAD try: self._visit_type(ev.payload_type) except Exception as e: raise ConfigError('invalid payload type in event "{}"'.format(ev_name), e) def _visit_stream(self, stream): stream_name = stream.name # set current stream self._cur_stream = stream # reset current event self._cur_event = None # visit stream packet context type self._stack_reset() self._cur_entity = _Entity.STREAM_PACKET_CONTEXT try: self._visit_type(stream.packet_context_type) except Exception as e: raise ConfigError('invalid packet context type in stream "{}"'.format(stream_name), e) # visit stream event header type self._stack_reset() self._cur_entity = _Entity.STREAM_EVENT_HEADER try: self._visit_type(stream.event_header_type) except Exception as e: raise ConfigError('invalid event header type in stream "{}"'.format(stream_name), e) # visit stream event context type self._stack_reset() self._cur_entity = _Entity.STREAM_EVENT_CONTEXT try: self._visit_type(stream.event_context_type) except Exception as e: raise ConfigError('invalid event context type in stream "{}"'.format(stream_name), e) # visit events for ev in stream.events.values(): try: self._visit_event(ev) except Exception as e: raise ConfigError('invalid stream "{}"'.format(stream_name)) def validate(self, meta): # set current trace self._cur_trace = meta.trace # visit trace packet header type self._stack_reset() self._cur_entity = _Entity.TRACE_PACKET_HEADER try: self._visit_type(meta.trace.packet_header_type) except Exception as e: raise ConfigError('invalid packet header type in trace', e) # visit streams for stream in meta.streams.values(): self._visit_stream(stream) # Since type inheritance allows types to be only partially defined at # any place in the configuration, this validator validates that actual # trace, stream, and event types are all complete and valid. Therefore # an invalid, but unusued type alias is accepted. class _MetadataTypesHistologyValidator: def __init__(self): self._type_to_validate_type_histology_func = { metadata.Integer: self._validate_integer_histology, metadata.FloatingPoint: self._validate_float_histology, metadata.Enum: self._validate_enum_histology, metadata.String: self._validate_string_histology, metadata.Struct: self._validate_struct_histology, metadata.Array: self._validate_array_histology, metadata.Variant: self._validate_variant_histology, } def _validate_integer_histology(self, t): # size is set if t.size is None: raise ConfigError('missing integer type\'s size') def _validate_float_histology(self, t): # exponent digits is set if t.exp_size is None: raise ConfigError('missing floating point number type\'s exponent size') # mantissa digits is set if t.mant_size is None: raise ConfigError('missing floating point number type\'s mantissa size') # exponent and mantissa sum is a multiple of 8 if (t.exp_size + t.mant_size) % 8 != 0: raise ConfigError('floating point number type\'s mantissa and exponent sizes sum must be a multiple of 8') def _validate_enum_histology(self, t): # integer type is set if t.value_type is None: raise ConfigError('missing enumeration type\'s value type') # there's at least one member if not t.members: raise ConfigError('enumeration type needs at least one member') # no overlapping values and all values are valid considering # the value type ranges = [] if t.value_type.signed: value_min = -(1 << t.value_type.size - 1) value_max = (1 << (t.value_type.size - 1)) - 1 else: value_min = 0 value_max = (1 << t.value_type.size) - 1 for label, value in t.members.items(): for rg in ranges: if value[0] <= rg[1] and rg[0] <= value[1]: raise ConfigError('enumeration type\'s member "{}" overlaps another member'.format(label)) fmt = 'enumeration type\'s member "{}": value {} is outside the value type range [{}, {}]' if value[0] < value_min or value[0] > value_max: raise ConfigError(fmt.format(label, value[0], value_min, value_max)) if value[1] < value_min or value[1] > value_max: raise ConfigError(fmt.format(label, value[1], value_min, value_max)) ranges.append(value) def _validate_string_histology(self, t): # always valid pass def _validate_struct_histology(self, t): # all fields are valid for field_name, field_type in t.fields.items(): try: self._validate_type_histology(field_type) except Exception as e: raise ConfigError('invalid structure type\'s field "{}"'.format(field_name), e) def _validate_array_histology(self, t): # length is set if t.length is None: raise ConfigError('missing array type\'s length') # element type is set if t.element_type is None: raise ConfigError('missing array type\'s element type') # element type is valid try: self._validate_type_histology(t.element_type) except Exception as e: raise ConfigError('invalid array type\'s element type', e) def _validate_variant_histology(self, t): # tag is set if t.tag is None: raise ConfigError('missing variant type\'s tag') # there's at least one type if not t.types: raise ConfigError('variant type needs at least one type') # all types are valid for type_name, type_t in t.types.items(): try: self._validate_type_histology(type_t) except Exception as e: raise ConfigError('invalid variant type\'s type "{}"'.format(type_name), e) def _validate_type_histology(self, t): if t is None: return self._type_to_validate_type_histology_func[type(t)](t) def _validate_entity_type_histology(self, t): if t is None: return if type(t) is not metadata.Struct: raise ConfigError('expecting a structure type') self._validate_type_histology(t) def _validate_event_types_histology(self, ev): ev_name = ev.name # validate event context type try: self._validate_entity_type_histology(ev.context_type) except Exception as e: raise ConfigError('invalid event context type for event "{}"'.format(ev_name), e) # validate event payload type try: self._validate_entity_type_histology(ev.payload_type) except Exception as e: raise ConfigError('invalid event payload type for event "{}"'.format(ev_name), e) def _validate_stream_types_histology(self, stream): stream_name = stream.name # validate stream packet context type try: self._validate_entity_type_histology(stream.packet_context_type) except Exception as e: raise ConfigError('invalid stream packet context type for stream "{}"'.format(stream_name), e) # validate stream event header type try: self._validate_entity_type_histology(stream.event_header_type) except Exception as e: raise ConfigError('invalid stream event header type for stream "{}"'.format(stream_name), e) # validate stream event context type try: self._validate_entity_type_histology(stream.event_context_type) except Exception as e: raise ConfigError('invalid stream event context type for stream "{}"'.format(stream_name), e) # validate events for ev in stream.events.values(): try: self._validate_event_types_histology(ev) except Exception as e: raise ConfigError('invalid event in stream "{}"'.format(stream_name), e) def validate(self, meta): # validate trace packet header type try: self._validate_entity_type_histology(meta.trace.packet_header_type) except Exception as e: raise ConfigError('invalid trace packet header type', e) # validate streams for stream in meta.streams.values(): self._validate_stream_types_histology(stream) class _YamlConfigParser: def __init__(self, include_dirs, ignore_include_not_found, dump_config): self._class_name_to_create_type_func = { 'int': self._create_integer, 'integer': self._create_integer, 'flt': self._create_float, 'float': self._create_float, 'floating-point': self._create_float, 'enum': self._create_enum, 'enumeration': self._create_enum, 'str': self._create_string, 'string': self._create_string, 'struct': self._create_struct, 'structure': self._create_struct, 'array': self._create_array, 'var': self._create_variant, 'variant': self._create_variant, } self._type_to_create_type_func = { metadata.Integer: self._create_integer, metadata.FloatingPoint: self._create_float, metadata.Enum: self._create_enum, metadata.String: self._create_string, metadata.Struct: self._create_struct, metadata.Array: self._create_array, metadata.Variant: self._create_variant, } self._include_dirs = include_dirs self._ignore_include_not_found = ignore_include_not_found self._dump_config = dump_config def _set_byte_order(self, metadata_node): if 'trace' not in metadata_node: raise ConfigError('missing "trace" property (metadata)') trace_node = metadata_node['trace'] if not _is_assoc_array_prop(trace_node): raise ConfigError('"trace" property (metadata) must be an associative array') if 'byte-order' not in trace_node: raise ConfigError('missing "byte-order" property (trace)') bo_node = trace_node['byte-order'] if not _is_str_prop(bo_node): raise ConfigError('"byte-order" property of trace object must be a string ("le" or "be")') self._bo = _byte_order_str_to_bo(bo_node) if self._bo is None: raise ConfigError('invalid "byte-order" property (trace): must be "le" or "be"') def _lookup_type_alias(self, name): if name in self._tas: return copy.deepcopy(self._tas[name]) def _set_int_clock_prop_mapping(self, int_obj, prop_mapping_node): unk_prop = _get_first_unknown_prop(prop_mapping_node, ['type', 'name', 'property']) if unk_prop: raise ConfigError('unknown property in integer type object\'s clock property mapping: "{}"'.format(unk_prop)) if 'name' not in prop_mapping_node: raise ConfigError('missing "name" property in integer type object\'s clock property mapping') if 'property' not in prop_mapping_node: raise ConfigError('missing "property" property in integer type object\'s clock property mapping') clock_name = prop_mapping_node['name'] prop = prop_mapping_node['property'] if not _is_str_prop(clock_name): raise ConfigError('"name" property of integer type object\'s clock property mapping must be a string') if not _is_str_prop(prop): raise ConfigError('"property" property of integer type object\'s clock property mapping must be a string') if clock_name not in self._clocks: raise ConfigError('invalid clock name "{}" in integer type object\'s clock property mapping'.format(clock_name)) if prop != 'value': raise ConfigError('invalid "property" property in integer type object\'s clock property mapping: "{}"'.format(prop)) mapped_clock = self._clocks[clock_name] int_obj.property_mappings.append(metadata.PropertyMapping(mapped_clock, prop)) def _get_first_unknown_type_prop(self, type_node, known_props): kp = known_props + ['inherit', 'class'] if self._version >= 201: kp.append('$inherit') return _get_first_unknown_prop(type_node, kp) def _create_integer(self, obj, node): if obj is None: # create integer object obj = metadata.Integer() unk_prop = self._get_first_unknown_type_prop(node, [ 'size', 'align', 'signed', 'byte-order', 'base', 'encoding', 'property-mappings', ]) if unk_prop: raise ConfigError('unknown integer type object property: "{}"'.format(unk_prop)) # size if 'size' in node: size = node['size'] if not _is_int_prop(size): raise ConfigError('"size" property of integer type object must be an integer') if size < 1: raise ConfigError('invalid integer size: {}'.format(size)) obj.size = size # align if 'align' in node: align = node['align'] if align is None: obj.set_default_align() else: if not _is_int_prop(align): raise ConfigError('"align" property of integer type object must be an integer') if not _is_valid_alignment(align): raise ConfigError('invalid alignment: {}'.format(align)) obj.align = align # signed if 'signed' in node: signed = node['signed'] if signed is None: obj.set_default_signed() else: if not _is_bool_prop(signed): raise ConfigError('"signed" property of integer type object must be a boolean') obj.signed = signed # byte order if 'byte-order' in node: byte_order = node['byte-order'] if byte_order is None: obj.byte_order = self._bo else: if not _is_str_prop(byte_order): raise ConfigError('"byte-order" property of integer type object must be a string ("le" or "be")') byte_order = _byte_order_str_to_bo(byte_order) if byte_order is None: raise ConfigError('invalid "byte-order" property in integer type object') obj.byte_order = byte_order else: obj.byte_order = self._bo # base if 'base' in node: base = node['base'] if base is None: obj.set_default_base() else: if not _is_str_prop(base): raise ConfigError('"base" property of integer type object must be a string ("bin", "oct", "dec", or "hex")') if base == 'bin': base = 2 elif base == 'oct': base = 8 elif base == 'dec': base = 10 elif base == 'hex': base = 16 else: raise ConfigError('unknown "base" property value: "{}" ("bin", "oct", "dec", and "hex" are accepted)'.format(base)) obj.base = base # encoding if 'encoding' in node: encoding = node['encoding'] if encoding is None: obj.set_default_encoding() else: if not _is_str_prop(encoding): raise ConfigError('"encoding" property of integer type object must be a string ("none", "ascii", or "utf-8")') encoding = _encoding_str_to_encoding(encoding) if encoding is None: raise ConfigError('invalid "encoding" property in integer type object') obj.encoding = encoding # property mappings if 'property-mappings' in node: prop_mappings = node['property-mappings'] if prop_mappings is None: obj.set_default_property_mappings() else: if not _is_array_prop(prop_mappings): raise ConfigError('"property-mappings" property of integer type object must be an array') if len(prop_mappings) > 1: raise ConfigError('length of "property-mappings" array in integer type object must be 1') for index, prop_mapping in enumerate(prop_mappings): if not _is_assoc_array_prop(prop_mapping): raise ConfigError('elements of "property-mappings" property of integer type object must be associative arrays') if 'type' not in prop_mapping: raise ConfigError('missing "type" property in integer type object\'s "property-mappings" array\'s element #{}'.format(index)) prop_type = prop_mapping['type'] if not _is_str_prop(prop_type): raise ConfigError('"type" property of integer type object\'s "property-mappings" array\'s element #{} must be a string'.format(index)) if prop_type == 'clock': self._set_int_clock_prop_mapping(obj, prop_mapping) else: raise ConfigError('unknown property mapping type "{}" in integer type object\'s "property-mappings" array\'s element #{}'.format(prop_type, index)) return obj def _create_float(self, obj, node): if obj is None: # create floating point number object obj = metadata.FloatingPoint() unk_prop = self._get_first_unknown_type_prop(node, [ 'size', 'align', 'byte-order', ]) if unk_prop: raise ConfigError('unknown floating point number type object property: "{}"'.format(unk_prop)) # size if 'size' in node: size = node['size'] if not _is_assoc_array_prop(size): raise ConfigError('"size" property of floating point number type object must be an associative array') unk_prop = _get_first_unknown_prop(size, ['exp', 'mant']) if unk_prop: raise ConfigError('unknown floating point number type object\'s "size" property: "{}"'.format(unk_prop)) if 'exp' in size: exp = size['exp'] if not _is_int_prop(exp): raise ConfigError('"exp" property of floating point number type object\'s "size" property must be an integer') if exp < 1: raise ConfigError('invalid floating point number exponent size: {}') obj.exp_size = exp if 'mant' in size: mant = size['mant'] if not _is_int_prop(mant): raise ConfigError('"mant" property of floating point number type object\'s "size" property must be an integer') if mant < 1: raise ConfigError('invalid floating point number mantissa size: {}') obj.mant_size = mant # align if 'align' in node: align = node['align'] if align is None: obj.set_default_align() else: if not _is_int_prop(align): raise ConfigError('"align" property of floating point number type object must be an integer') if not _is_valid_alignment(align): raise ConfigError('invalid alignment: {}'.format(align)) obj.align = align # byte order if 'byte-order' in node: byte_order = node['byte-order'] if byte_order is None: obj.byte_order = self._bo else: if not _is_str_prop(byte_order): raise ConfigError('"byte-order" property of floating point number type object must be a string ("le" or "be")') byte_order = _byte_order_str_to_bo(byte_order) if byte_order is None: raise ConfigError('invalid "byte-order" property in floating point number type object') else: obj.byte_order = self._bo return obj def _create_enum(self, obj, node): if obj is None: # create enumeration object obj = metadata.Enum() unk_prop = self._get_first_unknown_type_prop(node, [ 'value-type', 'members', ]) if unk_prop: raise ConfigError('unknown enumeration type object property: "{}"'.format(unk_prop)) # value type if 'value-type' in node: value_type_node = node['value-type'] try: obj.value_type = self._create_type(value_type_node) except Exception as e: raise ConfigError('cannot create enumeration type\'s integer type', e) # members if 'members' in node: members_node = node['members'] if not _is_array_prop(members_node): raise ConfigError('"members" property of enumeration type object must be an array') cur = 0 last_value = obj.last_value if last_value is None: cur = 0 else: cur = last_value + 1 for index, m_node in enumerate(members_node): if not _is_str_prop(m_node) and not _is_assoc_array_prop(m_node): raise ConfigError('invalid enumeration member #{}: expecting a string or an associative array'.format(index)) if _is_str_prop(m_node): label = m_node value = (cur, cur) cur += 1 else: unk_prop = _get_first_unknown_prop(m_node, [ 'label', 'value', ]) if unk_prop: raise ConfigError('unknown enumeration type member object property: "{}"'.format(unk_prop)) if 'label' not in m_node: raise ConfigError('missing "label" property in enumeration member #{}'.format(index)) label = m_node['label'] if not _is_str_prop(label): raise ConfigError('"label" property of enumeration member #{} must be a string'.format(index)) if 'value' not in m_node: raise ConfigError('missing "value" property in enumeration member ("{}")'.format(label)) value = m_node['value'] if not _is_int_prop(value) and not _is_array_prop(value): raise ConfigError('invalid enumeration member ("{}"): expecting an integer or an array'.format(label)) if _is_int_prop(value): cur = value + 1 value = (value, value) else: if len(value) != 2: raise ConfigError('invalid enumeration member ("{}"): range must have exactly two items'.format(label)) mn = value[0] mx = value[1] if mn > mx: raise ConfigError('invalid enumeration member ("{}"): invalid range ({} > {})'.format(label, mn, mx)) value = (mn, mx) cur = mx + 1 obj.members[label] = value return obj def _create_string(self, obj, node): if obj is None: # create string object obj = metadata.String() unk_prop = self._get_first_unknown_type_prop(node, [ 'encoding', ]) if unk_prop: raise ConfigError('unknown string type object property: "{}"'.format(unk_prop)) # encoding if 'encoding' in node: encoding = node['encoding'] if encoding is None: obj.set_default_encoding() else: if not _is_str_prop(encoding): raise ConfigError('"encoding" property of string type object must be a string ("none", "ascii", or "utf-8")') encoding = _encoding_str_to_encoding(encoding) if encoding is None: raise ConfigError('invalid "encoding" property in string type object') obj.encoding = encoding return obj def _create_struct(self, obj, node): if obj is None: # create structure object obj = metadata.Struct() unk_prop = self._get_first_unknown_type_prop(node, [ 'min-align', 'fields', ]) if unk_prop: raise ConfigError('unknown string type object property: "{}"'.format(unk_prop)) # minimum alignment if 'min-align' in node: min_align = node['min-align'] if min_align is None: obj.set_default_min_align() else: if not _is_int_prop(min_align): raise ConfigError('"min-align" property of structure type object must be an integer') if not _is_valid_alignment(min_align): raise ConfigError('invalid minimum alignment: {}'.format(min_align)) obj.min_align = min_align # fields if 'fields' in node: fields = node['fields'] if fields is None: obj.set_default_fields() else: if not _is_assoc_array_prop(fields): raise ConfigError('"fields" property of structure type object must be an associative array') for field_name, field_node in fields.items(): if not _is_valid_identifier(field_name): raise ConfigError('"{}" is not a valid field name for structure type'.format(field_name)) try: obj.fields[field_name] = self._create_type(field_node) except Exception as e: raise ConfigError('cannot create structure type\'s field "{}"'.format(field_name), e) return obj def _create_array(self, obj, node): if obj is None: # create array object obj = metadata.Array() unk_prop = self._get_first_unknown_type_prop(node, [ 'length', 'element-type', ]) if unk_prop: raise ConfigError('unknown array type object property: "{}"'.format(unk_prop)) # length if 'length' in node: length = node['length'] if not _is_int_prop(length) and not _is_str_prop(length): raise ConfigError('"length" property of array type object must be an integer or a string') if type(length) is int and length < 0: raise ConfigError('invalid static array length: {}'.format(length)) obj.length = length # element type if 'element-type' in node: element_type_node = node['element-type'] try: obj.element_type = self._create_type(node['element-type']) except Exception as e: raise ConfigError('cannot create array type\'s element type', e) return obj def _create_variant(self, obj, node): if obj is None: # create variant object obj = metadata.Variant() unk_prop = self._get_first_unknown_type_prop(node, [ 'tag', 'types', ]) if unk_prop: raise ConfigError('unknown variant type object property: "{}"'.format(unk_prop)) # tag if 'tag' in node: tag = node['tag'] if not _is_str_prop(tag): raise ConfigError('"tag" property of variant type object must be a string') # do not validate variant tag for the moment; will be done in a # second phase obj.tag = tag # element type if 'types' in node: types = node['types'] if not _is_assoc_array_prop(types): raise ConfigError('"types" property of variant type object must be an associative array') # do not validate type names for the moment; will be done in a # second phase for type_name, type_node in types.items(): if not _is_valid_identifier(type_name): raise ConfigError('"{}" is not a valid type name for variant type'.format(type_name)) try: obj.types[type_name] = self._create_type(type_node) except Exception as e: raise ConfigError('cannot create variant type\'s type "{}"'.format(type_name), e) return obj def _create_type(self, type_node): if type(type_node) is str: t = self._lookup_type_alias(type_node) if t is None: raise ConfigError('unknown type alias "{}"'.format(type_node)) return t if not _is_assoc_array_prop(type_node): raise ConfigError('type objects must be associative arrays or strings (type alias name)') # inherit: # v2.0: "inherit" # v2.1+: "$inherit" inherit_node = None if self._version >= 200: if 'inherit' in type_node: inherit_prop = 'inherit' inherit_node = type_node[inherit_prop] if self._version >= 201: if '$inherit' in type_node: if inherit_node is not None: raise ConfigError('cannot specify both "inherit" and "$inherit" properties of type object: prefer "$inherit"') inherit_prop = '$inherit' inherit_node = type_node[inherit_prop] if inherit_node is not None and 'class' in type_node: raise ConfigError('cannot specify both "{}" and "class" properties in type object'.format(inherit_prop)) if inherit_node is not None: if not _is_str_prop(inherit_node): raise ConfigError('"{}" property of type object must be a string'.format(inherit_prop)) base = self._lookup_type_alias(inherit_node) if base is None: raise ConfigError('cannot inherit from type alias "{}": type alias does not exist at this point'.format(inherit_node)) func = self._type_to_create_type_func[type(base)] else: if 'class' not in type_node: raise ConfigError('type objects which do not inherit must have a "class" property') class_name = type_node['class'] if type(class_name) is not str: raise ConfigError('type objects\' "class" property must be a string') if class_name not in self._class_name_to_create_type_func: raise ConfigError('unknown type class "{}"'.format(class_name)) base = None func = self._class_name_to_create_type_func[class_name] return func(base, type_node) def _register_type_aliases(self, metadata_node): self._tas = dict() if 'type-aliases' not in metadata_node: return ta_node = metadata_node['type-aliases'] if ta_node is None: return if not _is_assoc_array_prop(ta_node): raise ConfigError('"type-aliases" property (metadata) must be an associative array') for ta_name, ta_type in ta_node.items(): if ta_name in self._tas: raise ConfigError('duplicate type alias "{}"'.format(ta_name)) try: t = self._create_type(ta_type) except Exception as e: raise ConfigError('cannot create type alias "{}"'.format(ta_name), e) self._tas[ta_name] = t def _create_clock(self, node): # create clock object clock = metadata.Clock() if not _is_assoc_array_prop(node): raise ConfigError('clock objects must be associative arrays') known_props = [ 'uuid', 'description', 'freq', 'error-cycles', 'offset', 'absolute', 'return-ctype', ] if self._version >= 201: known_props.append('$return-ctype') unk_prop = _get_first_unknown_prop(node, known_props) if unk_prop: raise ConfigError('unknown clock object property: "{}"'.format(unk_prop)) # UUID if 'uuid' in node: uuidp = node['uuid'] if uuidp is None: clock.set_default_uuid() else: if not _is_str_prop(uuidp): raise ConfigError('"uuid" property of clock object must be a string') try: uuidp = uuid.UUID(uuidp) except: raise ConfigError('malformed UUID (clock object): "{}"'.format(uuidp)) clock.uuid = uuidp # description if 'description' in node: desc = node['description'] if desc is None: clock.set_default_description() else: if not _is_str_prop(desc): raise ConfigError('"description" property of clock object must be a string') clock.description = desc # frequency if 'freq' in node: freq = node['freq'] if freq is None: clock.set_default_freq() else: if not _is_int_prop(freq): raise ConfigError('"freq" property of clock object must be an integer') if freq < 1: raise ConfigError('invalid clock frequency: {}'.format(freq)) clock.freq = freq # error cycles if 'error-cycles' in node: error_cycles = node['error-cycles'] if error_cycles is None: clock.set_default_error_cycles() else: if not _is_int_prop(error_cycles): raise ConfigError('"error-cycles" property of clock object must be an integer') if error_cycles < 0: raise ConfigError('invalid clock error cycles: {}'.format(error_cycles)) clock.error_cycles = error_cycles # offset if 'offset' in node: offset = node['offset'] if offset is None: clock.set_default_offset_seconds() clock.set_default_offset_cycles() else: if not _is_assoc_array_prop(offset): raise ConfigError('"offset" property of clock object must be an associative array') unk_prop = _get_first_unknown_prop(offset, ['cycles', 'seconds']) if unk_prop: raise ConfigError('unknown clock object\'s offset property: "{}"'.format(unk_prop)) # cycles if 'cycles' in offset: offset_cycles = offset['cycles'] if offset_cycles is None: clock.set_default_offset_cycles() else: if not _is_int_prop(offset_cycles): raise ConfigError('"cycles" property of clock object\'s offset property must be an integer') if offset_cycles < 0: raise ConfigError('invalid clock offset cycles: {}'.format(offset_cycles)) clock.offset_cycles = offset_cycles # seconds if 'seconds' in offset: offset_seconds = offset['seconds'] if offset_seconds is None: clock.set_default_offset_seconds() else: if not _is_int_prop(offset_seconds): raise ConfigError('"seconds" property of clock object\'s offset property must be an integer') if offset_seconds < 0: raise ConfigError('invalid clock offset seconds: {}'.format(offset_seconds)) clock.offset_seconds = offset_seconds # absolute if 'absolute' in node: absolute = node['absolute'] if absolute is None: clock.set_default_absolute() else: if not _is_bool_prop(absolute): raise ConfigError('"absolute" property of clock object must be a boolean') clock.absolute = absolute # return C type: # v2.0: "return-ctype" # v2.1+: "$return-ctype" return_ctype_node = None if self._version >= 200: if 'return-ctype' in node: return_ctype_prop = 'return-ctype' return_ctype_node = node[return_ctype_prop] if self._version >= 201: if '$return-ctype' in node: if return_ctype_node is not None: raise ConfigError('cannot specify both "return-ctype" and "$return-ctype" properties of clock object: prefer "$return-ctype"') return_ctype_prop = '$return-ctype' return_ctype_node = node[return_ctype_prop] if return_ctype_node is not None: if return_ctype_node is None: clock.set_default_return_ctype() else: if not _is_str_prop(return_ctype_node): raise ConfigError('"{}" property of clock object must be a string'.format(return_ctype_prop)) clock.return_ctype = return_ctype_node return clock def _register_clocks(self, metadata_node): self._clocks = collections.OrderedDict() if 'clocks' not in metadata_node: return clocks_node = metadata_node['clocks'] if clocks_node is None: return if not _is_assoc_array_prop(clocks_node): raise ConfigError('"clocks" property (metadata) must be an associative array') for clock_name, clock_node in clocks_node.items(): if not _is_valid_identifier(clock_name): raise ConfigError('invalid clock name: "{}"'.format(clock_name)) if clock_name in self._clocks: raise ConfigError('duplicate clock "{}"'.format(clock_name)) try: clock = self._create_clock(clock_node) except Exception as e: raise ConfigError('cannot create clock "{}"'.format(clock_name), e) clock.name = clock_name self._clocks[clock_name] = clock def _create_env(self, metadata_node): env = collections.OrderedDict() if 'env' not in metadata_node: return env env_node = metadata_node['env'] if env_node is None: return env if not _is_assoc_array_prop(env_node): raise ConfigError('"env" property (metadata) must be an associative array') for env_name, env_value in env_node.items(): if env_name in env: raise ConfigError('duplicate environment variable "{}"'.format(env_name)) if not _is_valid_identifier(env_name): raise ConfigError('invalid environment variable name: "{}"'.format(env_name)) if not _is_int_prop(env_value) and not _is_str_prop(env_value): raise ConfigError('invalid environment variable value ("{}"): expecting integer or string'.format(env_name)) env[env_name] = env_value return env def _register_log_levels(self, metadata_node): self._log_levels = dict() # log levels: # v2.0: "log-levels" # v2.1+: "$log-levels" log_levels_node = None if self._version >= 200: if 'log-levels' in metadata_node: log_levels_prop = 'log-levels' log_levels_node = metadata_node[log_levels_prop] if self._version >= 201: if '$log-levels' in metadata_node: if log_levels_node is not None: raise ConfigError('cannot specify both "log-levels" and "$log-levels" properties of metadata object: prefer "$log-levels"') log_levels_prop = '$log-levels' log_levels_node = metadata_node[log_levels_prop] if log_levels_node is None: return if not _is_assoc_array_prop(log_levels_node): raise ConfigError('"{}" property (metadata) must be an associative array'.format(log_levels_prop)) for ll_name, ll_value in log_levels_node.items(): if ll_name in self._log_levels: raise ConfigError('duplicate log level entry "{}"'.format(ll_name)) if not _is_int_prop(ll_value): raise ConfigError('invalid log level entry ("{}"): expecting an integer'.format(ll_name)) if ll_value < 0: raise ConfigError('invalid log level entry ("{}"): log level value must be positive'.format(ll_name)) self._log_levels[ll_name] = ll_value def _create_trace(self, metadata_node): # create trace object trace = metadata.Trace() if 'trace' not in metadata_node: raise ConfigError('missing "trace" property (metadata)') trace_node = metadata_node['trace'] if not _is_assoc_array_prop(trace_node): raise ConfigError('"trace" property (metadata) must be an associative array') unk_prop = _get_first_unknown_prop(trace_node, [ 'byte-order', 'uuid', 'packet-header-type', ]) if unk_prop: raise ConfigError('unknown trace object property: "{}"'.format(unk_prop)) # set byte order (already parsed) trace.byte_order = self._bo # UUID if 'uuid' in trace_node and trace_node['uuid'] is not None: uuidp = trace_node['uuid'] if not _is_str_prop(uuidp): raise ConfigError('"uuid" property of trace object must be a string') if uuidp == 'auto': uuidp = uuid.uuid1() else: try: uuidp = uuid.UUID(uuidp) except: raise ConfigError('malformed UUID (trace object): "{}"'.format(uuidp)) trace.uuid = uuidp # packet header type if 'packet-header-type' in trace_node and trace_node['packet-header-type'] is not None: try: ph_type = self._create_type(trace_node['packet-header-type']) except Exception as e: raise ConfigError('cannot create packet header type (trace)', e) trace.packet_header_type = ph_type return trace def _lookup_log_level(self, ll): if _is_int_prop(ll): return ll elif _is_str_prop(ll) and ll in self._log_levels: return self._log_levels[ll] def _create_event(self, event_node): event = metadata.Event() if not _is_assoc_array_prop(event_node): raise ConfigError('event objects must be associative arrays') unk_prop = _get_first_unknown_prop(event_node, [ 'log-level', 'context-type', 'payload-type', ]) if unk_prop: raise ConfigError('unknown event object property: "{}"'.format(unk_prop)) if 'log-level' in event_node and event_node['log-level'] is not None: ll_node = event_node['log-level'] if _is_str_prop(ll_node): ll_value = self._lookup_log_level(event_node['log-level']) if ll_value is None: raise ConfigError('cannot find log level "{}"'.format(ll_node)) ll = metadata.LogLevel(event_node['log-level'], ll_value) elif _is_int_prop(ll_node): if ll_node < 0: raise ConfigError('invalid log level value {}: value must be positive'.format(ll_node)) ll = metadata.LogLevel(None, ll_node) else: raise ConfigError('"log-level" property must be either a string or an integer') event.log_level = ll if 'context-type' in event_node and event_node['context-type'] is not None: ctx_type_node = event_node['context-type'] try: t = self._create_type(event_node['context-type']) except Exception as e: raise ConfigError('cannot create event\'s context type object', e) event.context_type = t if 'payload-type' in event_node and event_node['payload-type'] is not None: try: t = self._create_type(event_node['payload-type']) except Exception as e: raise ConfigError('cannot create event\'s payload type object', e) event.payload_type = t return event def _create_stream(self, stream_name, stream_node): stream = metadata.Stream() if not _is_assoc_array_prop(stream_node): raise ConfigError('stream objects must be associative arrays') known_props = [ 'packet-context-type', 'event-header-type', 'event-context-type', 'events', ] if self._version >= 202: known_props.append('$default') unk_prop = _get_first_unknown_prop(stream_node, known_props) if unk_prop: add = '' if unk_prop == '$default': add = ' (use version 2.2 or greater)' raise ConfigError('unknown stream object property{}: "{}"'.format(add, unk_prop)) if 'packet-context-type' in stream_node and stream_node['packet-context-type'] is not None: try: t = self._create_type(stream_node['packet-context-type']) except Exception as e: raise ConfigError('cannot create stream\'s packet context type object', e) stream.packet_context_type = t if 'event-header-type' in stream_node and stream_node['event-header-type'] is not None: try: t = self._create_type(stream_node['event-header-type']) except Exception as e: raise ConfigError('cannot create stream\'s event header type object', e) stream.event_header_type = t if 'event-context-type' in stream_node and stream_node['event-context-type'] is not None: try: t = self._create_type(stream_node['event-context-type']) except Exception as e: raise ConfigError('cannot create stream\'s event context type object', e) stream.event_context_type = t if 'events' not in stream_node: raise ConfigError('missing "events" property in stream object') events = stream_node['events'] if events is not None: if not _is_assoc_array_prop(events): raise ConfigError('"events" property of stream object must be an associative array') if not events: raise ConfigError('at least one event is needed within a stream object') cur_id = 0 for ev_name, ev_node in events.items(): try: ev = self._create_event(ev_node) except Exception as e: raise ConfigError('cannot create event "{}"'.format(ev_name), e) ev.id = cur_id ev.name = ev_name stream.events[ev_name] = ev cur_id += 1 if '$default' in stream_node and stream_node['$default'] is not None: default_node = stream_node['$default'] if not _is_bool_prop(default_node): raise ConfigError('invalid "$default" property in stream object: expecting a boolean') if default_node: if self._meta.default_stream_name is not None and self._meta.default_stream_name != stream_name: fmt = 'cannot specify more than one default stream (default stream already set to "{}")' raise ConfigError(fmt.format(self._meta.default_stream_name)) self._meta.default_stream_name = stream_name return stream def _create_streams(self, metadata_node): streams = collections.OrderedDict() if 'streams' not in metadata_node: raise ConfigError('missing "streams" property (metadata)') streams_node = metadata_node['streams'] if not _is_assoc_array_prop(streams_node): raise ConfigError('"streams" property (metadata) must be an associative array') if not streams_node: raise ConfigError('at least one stream is needed (metadata)') cur_id = 0 for stream_name, stream_node in streams_node.items(): try: stream = self._create_stream(stream_name, stream_node) except Exception as e: raise ConfigError('cannot create stream "{}"'.format(stream_name), e) stream.id = cur_id stream.name = str(stream_name) streams[stream_name] = stream cur_id += 1 return streams def _create_metadata(self, root): self._meta = metadata.Metadata() if 'metadata' not in root: raise ConfigError('missing "metadata" property (configuration)') metadata_node = root['metadata'] if not _is_assoc_array_prop(metadata_node): raise ConfigError('"metadata" property (configuration) must be an associative array') known_props = [ 'type-aliases', 'log-levels', 'trace', 'env', 'clocks', 'streams', ] if self._version >= 201: known_props.append('$log-levels') if self._version >= 202: known_props.append('$default-stream') unk_prop = _get_first_unknown_prop(metadata_node, known_props) if unk_prop: add = '' if unk_prop == '$include': add = ' (use version 2.1 or greater)' if unk_prop == '$default-stream': add = ' (use version 2.2 or greater)' raise ConfigError('unknown metadata property{}: "{}"'.format(add, unk_prop)) if '$default-stream' in metadata_node and metadata_node['$default-stream'] is not None: default_stream_node = metadata_node['$default-stream'] if not _is_str_prop(default_stream_node): raise ConfigError('invalid "$default-stream" property (metadata): expecting a string') self._meta.default_stream_name = default_stream_node self._set_byte_order(metadata_node) self._register_clocks(metadata_node) self._meta.clocks = self._clocks self._register_type_aliases(metadata_node) self._meta.env = self._create_env(metadata_node) self._meta.trace = self._create_trace(metadata_node) self._register_log_levels(metadata_node) self._meta.streams = self._create_streams(metadata_node) return self._meta def _get_version(self, root): if 'version' not in root: raise ConfigError('missing "version" property (configuration)') version_node = root['version'] if not _is_str_prop(version_node): raise ConfigError('"version" property (configuration) must be a string') version_node = version_node.strip() if version_node not in ['2.0', '2.1', '2.2']: raise ConfigError('unsupported version ({}): versions 2.0, 2.1, and 2.2 are supported'.format(version_node)) # convert version string to comparable version integer parts = version_node.split('.') version = int(parts[0]) * 100 + int(parts[1]) return version def _get_prefix(self, root): def_prefix = 'barectf_' if 'prefix' not in root: return def_prefix prefix_node = root['prefix'] if prefix_node is None: return def_prefix if not _is_str_prop(prefix_node): raise ConfigError('"prefix" property (configuration) must be a string') if not _is_valid_identifier(prefix_node): raise ConfigError('"prefix" property (configuration) must be a valid C identifier') return prefix_node def _get_options(self, root): cfg_options = ConfigOptions() if 'options' not in root: return cfg_options options_node = root['options'] if not _is_assoc_array_prop(options_node): raise ConfigError('"options" property (configuration) must be an associative array') known_props = [ 'gen-prefix-def', 'gen-default-stream-def', ] unk_prop = _get_first_unknown_prop(options_node, known_props) if unk_prop: raise ConfigError('unknown configuration option property: "{}"'.format(unk_prop)) if 'gen-prefix-def' in options_node and options_node['gen-prefix-def'] is not None: gen_prefix_def_node = options_node['gen-prefix-def'] if not _is_bool_prop(gen_prefix_def_node): raise ConfigError('invalid configuration option "gen-prefix-def": expecting a boolean') cfg_options.gen_prefix_def = gen_prefix_def_node if 'gen-default-stream-def' in options_node and options_node['gen-default-stream-def'] is not None: gen_default_stream_def_node = options_node['gen-default-stream-def'] if not _is_bool_prop(gen_default_stream_def_node): raise ConfigError('invalid configuration option "gen-default-stream-def": expecting a boolean') cfg_options.gen_default_stream_def = gen_default_stream_def_node return cfg_options def _get_last_include_file(self): if self._include_stack: return self._include_stack[-1] return self._root_yaml_path def _load_include(self, yaml_path): for inc_dir in self._include_dirs: # current include dir + file name path # note: os.path.join() only takes the last arg if it's absolute inc_path = os.path.join(inc_dir, yaml_path) # real path (symbolic links resolved) real_path = os.path.realpath(inc_path) # normalized path (weird stuff removed!) norm_path = os.path.normpath(real_path) if not os.path.isfile(norm_path): # file does not exist: skip continue if norm_path in self._include_stack: base_path = self._get_last_include_file() raise ConfigError('in "{}": cannot recursively include file "{}"'.format(base_path, norm_path)) self._include_stack.append(norm_path) # load raw content return self._yaml_ordered_load(norm_path) if not self._ignore_include_not_found: base_path = self._get_last_include_file() raise ConfigError('in "{}": cannot include file "{}": file not found in include directories'.format(base_path, yaml_path)) return None def _get_include_paths(self, include_node): if include_node is None: return [] if _is_str_prop(include_node): return [include_node] if _is_array_prop(include_node): for include_path in include_node: if not _is_str_prop(include_path): raise ConfigError('invalid include property: expecting array of strings') return include_node raise ConfigError('invalid include property: expecting string or array of strings') def _update_node(self, base_node, overlay_node): for olay_key, olay_value in overlay_node.items(): if olay_key in base_node: base_value = base_node[olay_key] if _is_assoc_array_prop(olay_value) and _is_assoc_array_prop(base_value): # merge dictionaries self._update_node(base_value, olay_value) elif _is_array_prop(olay_value) and _is_array_prop(base_value): # append extension array items to base items base_value += olay_value else: # fall back to replacing base_node[olay_key] = olay_value else: base_node[olay_key] = olay_value def _process_node_include(self, last_overlay_node, name, process_base_include_cb, process_children_include_cb=None): if not _is_assoc_array_prop(last_overlay_node): raise ConfigError('{} objects must be associative arrays'.format(name)) # process children inclusions first if process_children_include_cb: process_children_include_cb(last_overlay_node) if '$include' in last_overlay_node: include_node = last_overlay_node['$include'] else: # no includes! return last_overlay_node include_paths = self._get_include_paths(include_node) cur_base_path = self._get_last_include_file() base_node = None # keep the include paths and remove the include property include_paths = copy.deepcopy(include_paths) del last_overlay_node['$include'] for include_path in include_paths: # load raw YAML from included file overlay_node = self._load_include(include_path) if overlay_node is None: # cannot find include file, but we're ignoring those # errors, otherwise _load_include() itself raises # a config error continue # recursively process includes try: overlay_node = process_base_include_cb(overlay_node) except Exception as e: raise ConfigError('in "{}"'.format(cur_base_path), e) # pop include stack now that we're done including del self._include_stack[-1] # at this point, base_node is fully resolved (does not # contain any include property) if base_node is None: base_node = overlay_node else: self._update_node(base_node, overlay_node) # finally, we update the latest base node with our last overlay # node if base_node is None: # nothing was included, which is possible when we're # ignoring include errors return last_overlay_node self._update_node(base_node, last_overlay_node) return base_node def _process_event_include(self, event_node): return self._process_node_include(event_node, 'event', self._process_event_include) def _process_stream_include(self, stream_node): def process_children_include(stream_node): if 'events' in stream_node: events_node = stream_node['events'] if not _is_assoc_array_prop(events_node): raise ConfigError('"events" property must be an associative array') events_node_keys = list(events_node.keys()) for key in events_node_keys: event_node = events_node[key] try: events_node[key] = self._process_event_include(event_node) except Exception as e: raise ConfigError('cannot process includes of event object "{}"'.format(key), e) return self._process_node_include(stream_node, 'stream', self._process_stream_include, process_children_include) def _process_trace_include(self, trace_node): return self._process_node_include(trace_node, 'trace', self._process_trace_include) def _process_clock_include(self, clock_node): return self._process_node_include(clock_node, 'clock', self._process_clock_include) def _process_metadata_include(self, metadata_node): def process_children_include(metadata_node): if 'trace' in metadata_node: metadata_node['trace'] = self._process_trace_include(metadata_node['trace']) if 'clocks' in metadata_node: clocks_node = metadata_node['clocks'] if not _is_assoc_array_prop(clocks_node): raise ConfigError('"clocks" property (metadata) must be an associative array') clocks_node_keys = list(clocks_node.keys()) for key in clocks_node_keys: clock_node = clocks_node[key] try: clocks_node[key] = self._process_clock_include(clock_node) except Exception as e: raise ConfigError('cannot process includes of clock object "{}"'.format(key), e) if 'streams' in metadata_node: streams_node = metadata_node['streams'] if not _is_assoc_array_prop(streams_node): raise ConfigError('"streams" property (metadata) must be an associative array') streams_node_keys = list(streams_node.keys()) for key in streams_node_keys: stream_node = streams_node[key] try: streams_node[key] = self._process_stream_include(stream_node) except Exception as e: raise ConfigError('cannot process includes of stream object "{}"'.format(key), e) return self._process_node_include(metadata_node, 'metadata', self._process_metadata_include, process_children_include) def _process_root_includes(self, root): # The following config objects support includes: # # * Metadata object # * Trace object # * Stream object # * Event object # # We need to process the event includes first, then the stream # includes, then the trace includes, and finally the metadata # includes. # # In each object, only one of the $include and $include-replace # special properties is allowed. # # We keep a stack of absolute paths to included files to detect # recursion. if 'metadata' in root: root['metadata'] = self._process_metadata_include(root['metadata']) return root def _yaml_ordered_dump(self, node, **kwds): class ODumper(yaml.Dumper): pass def dict_representer(dumper, node): return dumper.represent_mapping(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, node.items()) ODumper.add_representer(collections.OrderedDict, dict_representer) return yaml.dump(node, Dumper=ODumper, **kwds) def _yaml_ordered_load(self, yaml_path): class OLoader(yaml.Loader): pass def construct_mapping(loader, node): loader.flatten_mapping(node) return collections.OrderedDict(loader.construct_pairs(node)) OLoader.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, construct_mapping) # YAML -> Python try: with open(yaml_path, 'r') as f: node = yaml.load(f, OLoader) except (OSError, IOError) as e: raise ConfigError('cannot open file "{}"'.format(yaml_path)) except Exception as e: raise ConfigError('unknown error while trying to load file "{}"'.format(yaml_path), e) # loaded node must be an associate array if not _is_assoc_array_prop(node): raise ConfigError('root of YAML file "{}" must be an associative array'.format(yaml_path)) return node def _reset(self): self._version = None self._include_stack = [] def parse(self, yaml_path): self._reset() self._root_yaml_path = yaml_path try: root = self._yaml_ordered_load(yaml_path) except Exception as e: raise ConfigError('cannot parse YAML file "{}"'.format(yaml_path), e) if not _is_assoc_array_prop(root): raise ConfigError('configuration must be an associative array') # get the config version self._version = self._get_version(root) known_props = [ 'version', 'prefix', 'metadata', ] if self._version >= 202: known_props.append('options') unk_prop = _get_first_unknown_prop(root, known_props) if unk_prop: add = '' if unk_prop == 'options': add = ' (use version 2.2 or greater)' raise ConfigError('unknown configuration property{}: "{}"'.format(add, unk_prop)) # process includes if supported if self._version >= 201: root = self._process_root_includes(root) # dump config if required if self._dump_config: print(self._yaml_ordered_dump(root, indent=2, default_flow_style=False)) # get prefix and metadata prefix = self._get_prefix(root) meta = self._create_metadata(root) opts = self._get_options(root) return Config(self._version, prefix, meta, opts) def from_yaml_file(path, include_dirs, ignore_include_not_found, dump_config): try: parser = _YamlConfigParser(include_dirs, ignore_include_not_found, dump_config) cfg = parser.parse(path) return cfg except Exception as e: raise ConfigError('cannot create configuration from YAML file "{}"'.format(path), e) barectf-2.3.0/barectf/gen.py000066400000000000000000001200231317147435100156570ustar00rootroot00000000000000# The MIT License (MIT) # # Copyright (c) 2014-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. from barectf import templates from barectf import metadata import barectf.codegen import collections import argparse import datetime import barectf import sys import os import re def _align(v, align): return (v + (align - 1)) & -align class _StaticAlignSizeAutomatonByteOffset: def __init__(self): self._byte_offset = 0 self._type_to_update_byte_offset_func = { metadata.Integer: self._write_static_size, metadata.FloatingPoint: self._write_static_size, metadata.Enum: self._write_static_size, metadata.String: self._write_string_size, } @property def byte_offset(self): return self._byte_offset @byte_offset.setter def byte_offset(self, value): self._byte_offset = value def _wrap_byte_offset(self): self._byte_offset %= 8 def align(self, align): # align byte offset self._byte_offset = _align(self._byte_offset, align) # wrap on current byte self._wrap_byte_offset() def write_type(self, t): self._type_to_update_byte_offset_func[type(t)](t) def _write_string_size(self, t): self.reset() def _write_static_size(self, t): # increment byte offset self._byte_offset += t.size # wrap on current byte self._wrap_byte_offset() def reset(self): # reset byte offset self._byte_offset = 0 def set_unknown(self): self._byte_offset = None class _StaticAlignSizeAutomatonPreSize: def __init__(self): self.reset(1) def reset(self, initial_align): self._max_align = initial_align self._size = 0 def add_type(self, t): if t.align > self._max_align: # type alignment is greater than the maximum alignment we # got so far since the last reset, so we don't know how many # padding bits are needed between this type and the previous # one, hence the static size is set to the type's size # (since we're aligned) and our new alignment is saved self._max_align = t.align if type(t) is metadata.Struct: self._size = 0 else: self._size = t.size return False else: # type alignment is lesser than or equal to the maximum # alignment we got so far, so we just align the static size # and add the type's size self._size = _align(self._size, t.align) if type(t) is not metadata.Struct: self._size += t.size return True @property def size(self): return self._size _PREFIX_TPH = 'tph_' _PREFIX_SPC = 'spc_' _PREFIX_SEH = 'seh_' _PREFIX_SEC = 'sec_' _PREFIX_EC = 'ec_' _PREFIX_EP = 'ep_' class CCodeGenerator: def __init__(self, cfg): self._cfg = cfg self._cg = barectf.codegen.CodeGenerator('\t') self._type_to_get_ctype_func = { metadata.Integer: self._get_int_ctype, metadata.FloatingPoint: self._get_float_ctype, metadata.Enum: self._get_enum_ctype, metadata.String: self._get_string_ctype, } self._type_to_generate_serialize_func = { metadata.Integer: self._generate_serialize_int, metadata.FloatingPoint: self._generate_serialize_float, metadata.Enum: self._generate_serialize_enum, metadata.String: self._generate_serialize_string, } self._saved_byte_offsets = {} self._sasa = _StaticAlignSizeAutomatonByteOffset() def _generate_ctx_parent(self): tmpl = templates._CTX_PARENT self._cg.add_lines(tmpl.format(prefix=self._cfg.prefix)) def _generate_ctx(self, stream): tmpl = templates._CTX_BEGIN self._cg.add_lines(tmpl.format(prefix=self._cfg.prefix, sname=stream.name)) tmpl = 'uint32_t off_tph_{fname};' self._cg.indent() trace_packet_header_type = self._cfg.metadata.trace.packet_header_type if trace_packet_header_type is not None: for field_name in trace_packet_header_type.fields: self._cg.add_lines(tmpl.format(fname=field_name)) tmpl = 'uint32_t off_spc_{fname};' if stream.packet_context_type is not None: for field_name in stream.packet_context_type.fields: self._cg.add_lines(tmpl.format(fname=field_name)) self._cg.unindent() tmpl = templates._CTX_END self._cg.add_lines(tmpl) def _generate_ctxs(self): for stream in self._cfg.metadata.streams.values(): self._generate_ctx(stream) def _generate_clock_cb(self, clock): tmpl = templates._CLOCK_CB self._cg.add_lines(tmpl.format(return_ctype=clock.return_ctype, cname=clock.name)) def _generate_clock_cbs(self): for clock in self._cfg.metadata.clocks.values(): self._generate_clock_cb(clock) def _generate_platform_callbacks(self): tmpl = templates._PLATFORM_CALLBACKS_BEGIN self._cg.add_lines(tmpl.format(prefix=self._cfg.prefix)) self._cg.indent() self._generate_clock_cbs() self._cg.unindent() tmpl = templates._PLATFORM_CALLBACKS_END self._cg.add_lines(tmpl) def generate_bitfield_header(self): self._cg.reset() tmpl = templates._BITFIELD tmpl = tmpl.replace('$prefix$', self._cfg.prefix) tmpl = tmpl.replace('$PREFIX$', self._cfg.prefix.upper()) if self._cfg.metadata.trace.byte_order == metadata.ByteOrder.BE: endian_def = 'BIG_ENDIAN' else: endian_def = 'LITTLE_ENDIAN' tmpl = tmpl.replace('$ENDIAN_DEF$', endian_def) self._cg.add_lines(tmpl) return self._cg.code def _generate_func_init_proto(self): tmpl = templates._FUNC_INIT_PROTO self._cg.add_lines(tmpl.format(prefix=self._cfg.prefix)) def _get_int_ctype(self, t): signed = 'u' if not t.signed else '' if t.size <= 8: sz = '8' elif t.size <= 16: sz = '16' elif t.size <= 32: sz = '32' elif t.size == 64: sz = '64' return '{}int{}_t'.format(signed, sz) def _get_float_ctype(self, t): if t.exp_size == 8 and t.mant_size == 24 and t.align == 32: ctype = 'float' elif t.exp_size == 11 and t.mant_size == 53 and t.align == 64: ctype = 'double' else: ctype = 'uint64_t' return ctype def _get_enum_ctype(self, t): return self._get_int_ctype(t.value_type) def _get_string_ctype(self, t): return 'const char *' def _get_type_ctype(self, t): return self._type_to_get_ctype_func[type(t)](t) def _generate_type_ctype(self, t): ctype = self._get_type_ctype(t) self._cg.append_to_last_line(ctype) def _generate_proto_param(self, t, name): self._generate_type_ctype(t) self._cg.append_to_last_line(' ') self._cg.append_to_last_line(name) def _generate_proto_params(self, t, name_prefix, exclude_list): self._cg.indent() for field_name, field_type in t.fields.items(): if field_name in exclude_list: continue name = name_prefix + field_name self._cg.append_to_last_line(',') self._cg.add_line('') self._generate_proto_param(field_type, name) self._cg.unindent() def _generate_func_open_proto(self, stream): tmpl = templates._FUNC_OPEN_PROTO_BEGIN self._cg.add_lines(tmpl.format(prefix=self._cfg.prefix, sname=stream.name)) trace_packet_header_type = self._cfg.metadata.trace.packet_header_type if trace_packet_header_type is not None: exclude_list = ['magic', 'stream_id', 'uuid'] self._generate_proto_params(trace_packet_header_type, _PREFIX_TPH, exclude_list) if stream.packet_context_type is not None: exclude_list = [ 'timestamp_begin', 'timestamp_end', 'packet_size', 'content_size', 'events_discarded', ] self._generate_proto_params(stream.packet_context_type, _PREFIX_SPC, exclude_list) tmpl = templates._FUNC_OPEN_PROTO_END self._cg.add_lines(tmpl) def _generate_func_close_proto(self, stream): tmpl = templates._FUNC_CLOSE_PROTO self._cg.add_lines(tmpl.format(prefix=self._cfg.prefix, sname=stream.name)) def _generate_func_trace_proto_params(self, stream, event): if stream.event_header_type is not None: exclude_list = [ 'id', 'timestamp', ] self._generate_proto_params(stream.event_header_type, _PREFIX_SEH, exclude_list) if stream.event_context_type is not None: self._generate_proto_params(stream.event_context_type, _PREFIX_SEC, []) if event.context_type is not None: self._generate_proto_params(event.context_type, _PREFIX_EC, []) if event.payload_type is not None: self._generate_proto_params(event.payload_type, _PREFIX_EP, []) def _generate_func_trace_proto(self, stream, event): tmpl = templates._FUNC_TRACE_PROTO_BEGIN self._cg.add_lines(tmpl.format(prefix=self._cfg.prefix, sname=stream.name, evname=event.name)) self._generate_func_trace_proto_params(stream, event) tmpl = templates._FUNC_TRACE_PROTO_END self._cg.add_lines(tmpl) def _punctuate_proto(self): self._cg.append_to_last_line(';') def generate_header(self): self._cg.reset() dt = datetime.datetime.now().isoformat() bh_filename = self.get_bitfield_header_filename() prefix_def = '' default_stream_def = '' if self._cfg.options.gen_prefix_def: prefix_def = '#define _BARECTF_PREFIX {}'.format(self._cfg.prefix) if self._cfg.options.gen_default_stream_def and self._cfg.metadata.default_stream_name is not None: default_stream_def = '#define _BARECTF_DEFAULT_STREAM {}'.format(self._cfg.metadata.default_stream_name) default_stream_trace_defs = '' default_stream_name = self._cfg.metadata.default_stream_name if default_stream_name is not None: default_stream = self._cfg.metadata.streams[default_stream_name] lines = [] for ev_name in default_stream.events.keys(): tmpl = templates._DEFINE_DEFAULT_STREAM_TRACE define = tmpl.format(prefix=self._cfg.prefix, sname=default_stream_name, evname=ev_name) lines.append(define) default_stream_trace_defs = '\n'.join(lines) tmpl = templates._HEADER_BEGIN self._cg.add_lines(tmpl.format(prefix=self._cfg.prefix, ucprefix=self._cfg.prefix.upper(), bitfield_header_filename=bh_filename, version=barectf.__version__, date=dt, prefix_def=prefix_def, default_stream_def=default_stream_def, default_stream_trace_defs=default_stream_trace_defs)) self._cg.add_empty_line() # platform callbacks structure self._generate_platform_callbacks() self._cg.add_empty_line() # context parent self._generate_ctx_parent() self._cg.add_empty_line() # stream contexts self._generate_ctxs() self._cg.add_empty_line() # initialization function prototype self._generate_func_init_proto() self._punctuate_proto() self._cg.add_empty_line() for stream in self._cfg.metadata.streams.values(): self._generate_func_open_proto(stream) self._punctuate_proto() self._cg.add_empty_line() self._generate_func_close_proto(stream) self._punctuate_proto() self._cg.add_empty_line() for ev in stream.events.values(): self._generate_func_trace_proto(stream, ev) self._punctuate_proto() self._cg.add_empty_line() tmpl = templates._HEADER_END self._cg.add_lines(tmpl.format(ucprefix=self._cfg.prefix.upper())) return self._cg.code def _get_call_event_param_list_from_struct(self, t, prefix, exclude_list): lst = '' for field_name in t.fields: if field_name in exclude_list: continue lst += ', {}{}'.format(prefix, field_name) return lst def _get_call_event_param_list(self, stream, event): lst = '' gcp_func = self._get_call_event_param_list_from_struct if stream.event_header_type is not None: exclude_list = [ 'id', 'timestamp', ] lst += gcp_func(stream.event_header_type, _PREFIX_SEH, exclude_list) if stream.event_context_type is not None: lst += gcp_func(stream.event_context_type, _PREFIX_SEC, []) if event.context_type is not None: lst += gcp_func(event.context_type, _PREFIX_EC, []) if event.payload_type is not None: lst += gcp_func(event.payload_type, _PREFIX_EP, []) return lst def _generate_align(self, at, align): self._cg.add_line('_ALIGN({}, {});'.format(at, align)) self._sasa.align(align) def _generate_align_type(self, at, t): if t.align == 1: return self._generate_align(at, t.align) def _generate_incr_pos(self, var, value): self._cg.add_line('{} += {};'.format(var, value)) def _generate_incr_pos_bytes(self, var, value): self._generate_incr_pos(var, '_BYTES_TO_BITS({})'.format(value)) def _generate_func_get_event_size_proto(self, stream, event): tmpl = templates._FUNC_GET_EVENT_SIZE_PROTO_BEGIN self._cg.add_lines(tmpl.format(prefix=self._cfg.prefix, sname=stream.name, evname=event.name)) self._generate_func_trace_proto_params(stream, event) tmpl = templates._FUNC_GET_EVENT_SIZE_PROTO_END self._cg.add_lines(tmpl) def _generate_func_get_event_size_from_entity(self, prefix, t): self._cg.add_line('{') self._cg.indent() statically_aligned = self._pre_size_sasa.add_type(t) if not statically_aligned: # increment current position if needed if self._last_basic_types_size > 0: self._generate_incr_pos('at', self._last_basic_types_size) self._last_basic_types_size = 0 self._cg.add_cc_line('align structure') self._generate_align_type('at', t) for field_name, field_type in t.fields.items(): self._cg.add_empty_line() self._generate_field_name_cc_line(field_name) if type(field_type) is metadata.String: # increment current position if needed if self._last_basic_types_size > 0: self._generate_incr_pos('at', self._last_basic_types_size) self._last_basic_types_size = 0 param = prefix + field_name self._generate_incr_pos_bytes('at', 'strlen({}) + 1'.format(param)) self._pre_size_sasa.reset(8) else: statically_aligned = self._pre_size_sasa.add_type(field_type) if not statically_aligned: # increment current position if needed if self._last_basic_types_size > 0: self._generate_incr_pos('at', self._last_basic_types_size) # realign dynamically self._cg.add_cc_line('align for field') self._generate_align_type('at', field_type) fmt = 'field size: {} (partial total so far: {})' self._cg.add_cc_line(fmt.format(field_type.size, self._pre_size_sasa.size)) self._last_basic_types_size = self._pre_size_sasa.size self._cg.unindent() self._cg.add_line('}') self._cg.add_empty_line() def _generate_func_get_event_size(self, stream, event): self._reset_per_func_state() self._generate_func_get_event_size_proto(stream, event) tmpl = templates._FUNC_GET_EVENT_SIZE_BODY_BEGIN lines = tmpl.format(prefix=self._cfg.prefix) self._cg.add_lines(lines) self._cg.add_empty_line() self._cg.indent() func = self._generate_func_get_event_size_from_entity self._pre_size_sasa = _StaticAlignSizeAutomatonPreSize() self._cg.add_cc_line('byte-align entity') self._generate_align('at', 8) self._cg.add_empty_line() self._pre_size_sasa.reset(8) self._last_basic_types_size = 0 if stream.event_header_type is not None: self._cg.add_cc_line('stream event header') func(_PREFIX_SEH, stream.event_header_type) if stream.event_context_type is not None: self._cg.add_cc_line('stream event context') func(_PREFIX_SEC, stream.event_context_type) if event.context_type is not None: self._cg.add_cc_line('event context') func(_PREFIX_EC, event.context_type) if event.payload_type is not None: self._cg.add_cc_line('event payload') func(_PREFIX_EP, event.payload_type) # increment current position if needed if self._last_basic_types_size > 0: self._generate_incr_pos('at', self._last_basic_types_size) self._cg.add_empty_line() self._cg.unindent() tmpl = templates._FUNC_GET_EVENT_SIZE_BODY_END self._cg.add_lines(tmpl) def _generate_func_serialize_event_proto(self, stream, event): tmpl = templates._FUNC_SERIALIZE_EVENT_PROTO_BEGIN clock_ctype = 'const int' if stream.event_header_type is not None: if 'timestamp' in stream.event_header_type.fields: field = stream.event_header_type['timestamp'] clock_ctype = self._get_first_clock_ctype(field) self._cg.add_lines(tmpl.format(prefix=self._cfg.prefix, clock_ctype=clock_ctype, sname=stream.name, evname=event.name)) self._generate_func_trace_proto_params(stream, event) tmpl = templates._FUNC_SERIALIZE_EVENT_PROTO_END self._cg.add_lines(tmpl) def _generate_bitfield_write(self, ctype, var, ctx, t): ptr = '&{ctx}->buf[_BITS_TO_BYTES({ctx}->at)]'.format(ctx=ctx) start = self._sasa.byte_offset suffix = 'le' if t.byte_order is metadata.ByteOrder.LE else 'be' func = '{}bt_bitfield_write_{}'.format(self._cfg.prefix, suffix) call_fmt = '{func}({ptr}, uint8_t, {start}, {size}, {ctype}, ({ctype}) {var});' call = call_fmt.format(func=func, ptr=ptr, start=start, size=t.size, ctype=ctype, var=var) self._cg.add_line(call) def _generate_serialize_int(self, var, ctx, t): ctype = self._get_int_ctype(t) self._generate_bitfield_write(ctype, var, ctx, t) self._generate_incr_pos('{}->at'.format(ctx), t.size) def _generate_serialize_float(self, var, ctx, t): ctype = self._get_type_ctype(t) flt_dbl = False if ctype == 'float' or ctype == 'double': flt_dbl = True if ctype == 'float': union_name = 'f2u' int_ctype = 'uint32_t' elif ctype == 'double': union_name = 'd2u' int_ctype = 'uint64_t' # union for reading the bytes of the floating point number self._cg.add_empty_line() self._cg.add_line('{') self._cg.indent() self._cg.add_line('union {name} {name};'.format(name=union_name)) self._cg.add_empty_line() self._cg.add_line('{}.f = {};'.format(union_name, var)) bf_var = '{}.u'.format(union_name) else: bf_var = '({}) {}'.format(ctype, var) int_ctype = ctype self._generate_bitfield_write(int_ctype, bf_var, ctx, t) if flt_dbl: self._cg.unindent() self._cg.add_line('}') self._cg.add_empty_line() self._generate_incr_pos('{}->at'.format(ctx), t.size) def _generate_serialize_enum(self, var, ctx, t): self._generate_serialize_type(var, ctx, t.value_type) def _generate_serialize_string(self, var, ctx, t): tmpl = '_write_cstring({}, {});'.format(ctx, var) self._cg.add_lines(tmpl) def _generate_serialize_type(self, var, ctx, t): self._type_to_generate_serialize_func[type(t)](var, ctx, t) self._sasa.write_type(t) def _generate_func_serialize_event_from_entity(self, prefix, t, spec_src=None): self._cg.add_line('{') self._cg.indent() self._cg.add_cc_line('align structure') self._sasa.reset() self._generate_align_type('ctx->at', t) for field_name, field_type in t.fields.items(): src = prefix + field_name if spec_src is not None: if field_name in spec_src: src = spec_src[field_name] self._cg.add_empty_line() self._generate_field_name_cc_line(field_name) self._generate_align_type('ctx->at', field_type) self._generate_serialize_type(src, 'ctx', field_type) self._cg.unindent() self._cg.add_line('}') self._cg.add_empty_line() def _generate_func_serialize_event(self, stream, event): self._reset_per_func_state() self._generate_func_serialize_event_proto(stream, event) tmpl = templates._FUNC_SERIALIZE_EVENT_BODY_BEGIN lines = tmpl.format(prefix=self._cfg.prefix) self._cg.add_lines(lines) self._cg.indent() self._cg.add_empty_line() if stream.event_header_type is not None: t = stream.event_header_type exclude_list = ['timestamp', 'id'] params = self._get_call_event_param_list_from_struct(t, _PREFIX_SEH, exclude_list) tmpl = '_serialize_stream_event_header_{sname}(ctx, ts, {evid}{params});' self._cg.add_cc_line('stream event header') self._cg.add_line(tmpl.format(sname=stream.name, evid=event.id, params=params)) self._cg.add_empty_line() if stream.event_context_type is not None: t = stream.event_context_type params = self._get_call_event_param_list_from_struct(t, _PREFIX_SEC, []) tmpl = '_serialize_stream_event_context_{sname}(ctx{params});' self._cg.add_cc_line('stream event context') self._cg.add_line(tmpl.format(sname=stream.name, params=params)) self._cg.add_empty_line() if event.context_type is not None: self._cg.add_cc_line('event context') self._generate_func_serialize_event_from_entity(_PREFIX_EC, event.context_type) if event.payload_type is not None: self._cg.add_cc_line('event payload') self._generate_func_serialize_event_from_entity(_PREFIX_EP, event.payload_type) self._cg.unindent() tmpl = templates._FUNC_SERIALIZE_EVENT_BODY_END self._cg.add_lines(tmpl) def _generate_func_serialize_stream_event_header_proto(self, stream): tmpl = templates._FUNC_SERIALIZE_STREAM_EVENT_HEADER_PROTO_BEGIN clock_ctype = 'const int' if stream.event_header_type is not None: if 'timestamp' in stream.event_header_type.fields: field = stream.event_header_type['timestamp'] clock_ctype = self._get_first_clock_ctype(field) self._cg.add_lines(tmpl.format(prefix=self._cfg.prefix, sname=stream.name, clock_ctype=clock_ctype)) if stream.event_header_type is not None: exclude_list = [ 'id', 'timestamp', ] self._generate_proto_params(stream.event_header_type, _PREFIX_SEH, exclude_list) tmpl = templates._FUNC_SERIALIZE_STREAM_EVENT_HEADER_PROTO_END self._cg.add_lines(tmpl) def _generate_func_serialize_stream_event_context_proto(self, stream): tmpl = templates._FUNC_SERIALIZE_STREAM_EVENT_CONTEXT_PROTO_BEGIN self._cg.add_lines(tmpl.format(prefix=self._cfg.prefix, sname=stream.name)) if stream.event_context_type is not None: self._generate_proto_params(stream.event_context_type, _PREFIX_SEC, []) tmpl = templates._FUNC_SERIALIZE_STREAM_EVENT_CONTEXT_PROTO_END self._cg.add_lines(tmpl) def _generate_func_serialize_stream_event_header(self, stream): self._reset_per_func_state() self._generate_func_serialize_stream_event_header_proto(stream) tmpl = templates._FUNC_SERIALIZE_STREAM_EVENT_HEADER_BODY_BEGIN lines = tmpl.format(prefix=self._cfg.prefix) self._cg.add_lines(lines) self._cg.indent() self._cg.add_empty_line() func = self._generate_func_serialize_event_from_entity if stream.event_header_type is not None: spec_src = {} if 'id' in stream.event_header_type.fields: id_t = stream.event_header_type.fields['id'] id_t_ctype = self._get_int_ctype(id_t) spec_src['id'] = '({}) event_id'.format(id_t_ctype) if 'timestamp' in stream.event_header_type.fields: field = stream.event_header_type.fields['timestamp'] ts_ctype = self._get_int_ctype(field) spec_src['timestamp'] = '({}) ts'.format(ts_ctype) func(_PREFIX_SEH, stream.event_header_type, spec_src) self._cg.unindent() tmpl = templates._FUNC_SERIALIZE_STREAM_EVENT_HEADER_BODY_END self._cg.add_lines(tmpl) def _generate_func_serialize_stream_event_context(self, stream): self._reset_per_func_state() self._generate_func_serialize_stream_event_context_proto(stream) tmpl = templates._FUNC_SERIALIZE_STREAM_EVENT_CONTEXT_BODY_BEGIN lines = tmpl.format(prefix=self._cfg.prefix) self._cg.add_lines(lines) self._cg.indent() func = self._generate_func_serialize_event_from_entity if stream.event_context_type is not None: func(_PREFIX_SEC, stream.event_context_type) self._cg.unindent() tmpl = templates._FUNC_SERIALIZE_STREAM_EVENT_CONTEXT_BODY_END self._cg.add_lines(tmpl) def _generate_func_trace(self, stream, event): self._reset_per_func_state() self._generate_func_trace_proto(stream, event) params = self._get_call_event_param_list(stream, event) tmpl = templates._FUNC_TRACE_BODY ts_line = '' if stream.event_header_type is not None: if 'timestamp' in stream.event_header_type.fields: field = stream.event_header_type.fields['timestamp'] ts_line = self._get_ts_line(field) if not ts_line: ts_line = '\tconst int ts = 0; /* unused */' self._cg.add_lines(tmpl.format(sname=stream.name, evname=event.name, params=params, ts=ts_line)) def _generate_func_init(self): self._reset_per_func_state() self._generate_func_init_proto() tmpl = templates._FUNC_INIT_BODY self._cg.add_lines(tmpl.format(prefix=self._cfg.prefix)) def _generate_field_name_cc_line(self, field_name): self._cg.add_cc_line('"{}" field'.format(field_name)) def _save_byte_offset(self, name): self._saved_byte_offsets[name] = self._sasa.byte_offset def _restore_byte_offset(self, name): self._sasa.byte_offset = self._saved_byte_offsets[name] def _reset_per_func_state(self): pass def _get_first_clock_ctype(self, field, default='int'): if not field.property_mappings: return 'const {}'.format(default) clock = field.property_mappings[0].object return 'const {}'.format(clock.return_ctype) def _get_ts_line(self, field): if field is None: return '' if not field.property_mappings: return '' tmpl = '\tconst {} ts = ctx->parent.cbs.{}_clock_get_value(ctx->parent.data);' clock = field.property_mappings[0].object line = tmpl.format(clock.return_ctype, clock.name) return line def _generate_func_open(self, stream): def generate_save_offset(name): tmpl = 'ctx->off_spc_{} = ctx->parent.at;'.format(name) self._cg.add_line(tmpl) self._save_byte_offset(name) self._reset_per_func_state() self._generate_func_open_proto(stream) tmpl = templates._FUNC_OPEN_BODY_BEGIN ts_line = '' spc_type = stream.packet_context_type if spc_type is not None and 'timestamp_begin' in spc_type.fields: field = spc_type.fields['timestamp_begin'] ts_line = self._get_ts_line(field) lines = tmpl.format(ts=ts_line) self._cg.add_lines(lines) self._cg.indent() self._cg.add_cc_line('do not open a packet that is already open') self._cg.add_line('if (ctx->parent.packet_is_open) {') self._cg.indent() self._cg.add_line('ctx->parent.in_tracing_section = saved_in_tracing_section;') self._cg.add_line('return;') self._cg.unindent() self._cg.add_line('}') self._cg.add_empty_line() self._cg.add_line('ctx->parent.at = 0;') tph_type = self._cfg.metadata.trace.packet_header_type if tph_type is not None: self._cg.add_empty_line() self._cg.add_cc_line('trace packet header') self._cg.add_line('{') self._cg.indent() self._cg.add_cc_line('align structure') self._sasa.reset() self._generate_align_type('ctx->parent.at', tph_type) for field_name, field_type in tph_type.fields.items(): src = _PREFIX_TPH + field_name if field_name == 'magic': src = '0xc1fc1fc1UL' elif field_name == 'stream_id': stream_id_ctype = self._get_int_ctype(field_type) src = '({}) {}'.format(stream_id_ctype, stream.id) elif field_name == 'uuid': self._cg.add_empty_line() self._generate_field_name_cc_line(field_name) self._cg.add_line('{') self._cg.indent() self._cg.add_line('static uint8_t uuid[] = {') self._cg.indent() for b in self._cfg.metadata.trace.uuid.bytes: self._cg.add_line('{},'.format(b)) self._cg.unindent() self._cg.add_line('};') self._cg.add_empty_line() self._generate_align('ctx->parent.at', 8) line = 'memcpy(&ctx->parent.buf[_BITS_TO_BYTES(ctx->parent.at)], uuid, 16);' self._cg.add_line(line) self._generate_incr_pos_bytes('ctx->parent.at', 16) self._cg.unindent() self._cg.add_line('}') self._sasa.reset() continue self._cg.add_empty_line() self._generate_field_name_cc_line(field_name) self._generate_align_type('ctx->parent.at', field_type) self._generate_serialize_type(src, '(&ctx->parent)', field_type) self._cg.unindent() self._cg.add_lines('}') if spc_type is not None: self._cg.add_empty_line() self._cg.add_cc_line('stream packet context') self._cg.add_line('{') self._cg.indent() self._cg.add_cc_line('align structure') self._sasa.reset() self._generate_align_type('ctx->parent.at', spc_type) tmpl_off = 'off_spc_{fname}' for field_name, field_type in spc_type.fields.items(): src = _PREFIX_SPC + field_name skip_int = False self._cg.add_empty_line() self._generate_field_name_cc_line(field_name) if field_name == 'timestamp_begin': ctype = self._get_type_ctype(field_type) src = '({}) ts'.format(ctype) elif field_name in ['timestamp_end', 'content_size', 'events_discarded']: skip_int = True elif field_name == 'packet_size': ctype = self._get_type_ctype(field_type) src = '({}) ctx->parent.packet_size'.format(ctype) self._generate_align_type('ctx->parent.at', field_type) if skip_int: generate_save_offset(field_name) self._generate_incr_pos('ctx->parent.at', field_type.size) self._sasa.write_type(field_type) else: self._generate_serialize_type(src, '(&ctx->parent)', field_type) self._cg.unindent() self._cg.add_lines('}') self._cg.unindent() tmpl = templates._FUNC_OPEN_BODY_END self._cg.add_lines(tmpl) def _generate_func_close(self, stream): def generate_goto_offset(name): tmpl = 'ctx->parent.at = ctx->off_spc_{};'.format(name) self._cg.add_line(tmpl) self._reset_per_func_state() self._generate_func_close_proto(stream) tmpl = templates._FUNC_CLOSE_BODY_BEGIN ts_line = '' spc_type = stream.packet_context_type if spc_type is not None and 'timestamp_end' in spc_type.fields: field = spc_type.fields['timestamp_end'] ts_line = self._get_ts_line(field) lines = tmpl.format(ts=ts_line) self._cg.add_lines(lines) self._cg.indent() self._cg.add_cc_line('do not close a packet that is not open') self._cg.add_line('if (!ctx->parent.packet_is_open) {') self._cg.indent() self._cg.add_line('ctx->parent.in_tracing_section = saved_in_tracing_section;') self._cg.add_line('return;') self._cg.unindent() self._cg.add_line('}') self._cg.add_empty_line() self._cg.add_cc_line('save content size') self._cg.add_line('ctx->parent.content_size = ctx->parent.at;') if spc_type is not None: field_name = 'timestamp_end' if field_name in spc_type.fields: t = spc_type.fields[field_name] ctype = self._get_type_ctype(t) src = '({}) ts'.format(ctype) self._cg.add_empty_line() self._generate_field_name_cc_line(field_name) generate_goto_offset(field_name) self._restore_byte_offset(field_name) self._generate_serialize_type(src, '(&ctx->parent)', t) field_name = 'content_size' if 'content_size' in spc_type.fields: t = spc_type.fields[field_name] ctype = self._get_type_ctype(t) src = '({}) ctx->parent.content_size'.format(ctype) self._cg.add_empty_line() self._generate_field_name_cc_line(field_name) generate_goto_offset(field_name) self._restore_byte_offset(field_name) self._generate_serialize_type(src, '(&ctx->parent)', t) field_name = 'events_discarded' if field_name in spc_type.fields: t = spc_type.fields[field_name] ctype = self._get_type_ctype(t) src = '({}) ctx->parent.events_discarded'.format(ctype) self._cg.add_empty_line() self._generate_field_name_cc_line(field_name) generate_goto_offset(field_name) self._restore_byte_offset(field_name) self._generate_serialize_type(src, '(&ctx->parent)', t) self._cg.unindent() tmpl = templates._FUNC_CLOSE_BODY_END self._cg.add_lines(tmpl) self._sasa.reset() def generate_c_src(self): self._cg.reset() dt = datetime.datetime.now().isoformat() header_filename = self.get_header_filename() tmpl = templates._C_SRC self._cg.add_lines(tmpl.format(prefix=self._cfg.prefix, header_filename=header_filename, version=barectf.__version__, date=dt)) self._cg.add_empty_line() # initialization function self._generate_func_init() self._cg.add_empty_line() for stream in self._cfg.metadata.streams.values(): self._generate_func_open(stream) self._cg.add_empty_line() self._generate_func_close(stream) self._cg.add_empty_line() if stream.event_header_type is not None: self._generate_func_serialize_stream_event_header(stream) self._cg.add_empty_line() if stream.event_context_type is not None: self._generate_func_serialize_stream_event_context(stream) self._cg.add_empty_line() for ev in stream.events.values(): self._generate_func_get_event_size(stream, ev) self._cg.add_empty_line() self._generate_func_serialize_event(stream, ev) self._cg.add_empty_line() self._generate_func_trace(stream, ev) self._cg.add_empty_line() return self._cg.code def get_header_filename(self): return '{}.h'.format(self._cfg.prefix.rstrip('_')) def get_bitfield_header_filename(self): return '{}-bitfield.h'.format(self._cfg.prefix.rstrip('_')) barectf-2.3.0/barectf/include/000077500000000000000000000000001317147435100161615ustar00rootroot00000000000000barectf-2.3.0/barectf/include/lttng-ust-log-levels.yaml000066400000000000000000000007341317147435100230610ustar00rootroot00000000000000# Include this in the metadata object to have access to the LTTng-UST # log level values by name. # # Note that the values from 0 to 7 are compatible with syslog log # levels, although the debug severity in syslog is named DEBUG_SYSTEM # here. $log-levels: EMERG: 0 ALERT: 1 CRIT: 2 ERR: 3 WARNING: 4 NOTICE: 5 INFO: 6 DEBUG_SYSTEM: 7 DEBUG_PROGRAM: 8 DEBUG_PROCESS: 9 DEBUG_MODULE: 10 DEBUG_UNIT: 11 DEBUG_FUNCTION: 12 DEBUG_LINE: 13 DEBUG: 14 barectf-2.3.0/barectf/include/stdfloat.yaml000066400000000000000000000006261317147435100206710ustar00rootroot00000000000000# Include this in the metadata object of your configuration to have # access to basic floating point number type aliases. type-aliases: # IEEE 754-2008 binary32 (single-precision) float: class: floating-point size: exp: 8 mant: 24 align: 32 # IEEE 754-2008 binary64 (double-precision) double: class: floating-point size: exp: 11 mant: 53 align: 64 barectf-2.3.0/barectf/include/stdint.yaml000066400000000000000000000044401317147435100203540ustar00rootroot00000000000000# Include this in the metadata object of your configuratio # access to basic integer type aliases. type-aliases: # 8-bit unsigned integer, 8-bit aligned uint8: class: int size: 8 align: 8 byte: uint8 # 8-bit signed integer, 8-bit aligned int8: $inherit: uint8 signed: true # 16-bit unsigned integer, 16-bit aligned uint16: class: int size: 16 align: 16 word: uint16 # 16-bit signed integer, 16-bit aligned int16: $inherit: uint16 signed: true # 32-bit unsigned integer, 32-bit aligned uint32: class: int size: 32 align: 32 dword: uint32 # 32-bit signed integer, 32-bit aligned int32: $inherit: uint32 signed: true # 64-bit unsigned integer, 64-bit aligned uint64: class: int size: 64 align: 64 # 64-bit signed integer, 64-bit aligned int64: $inherit: uint64 signed: true # byte-packed 8-bit unsigned integer byte-packed-uint8: uint8 # byte-packed 8-bit signed integer byte-packed-int8: int8 # byte-packed 16-bit unsigned integer byte-packed-uint16: $inherit: uint16 align: 8 # byte-packed 16-bit signed integer byte-packed-int16: $inherit: int16 align: 8 # byte-packed 32-bit unsigned integer byte-packed-uint32: $inherit: uint32 align: 8 # byte-packed 32-bit signed integer byte-packed-int32: $inherit: int32 align: 8 # byte-packed 64-bit unsigned integer byte-packed-uint64: $inherit: uint64 align: 8 # byte-packed 64-bit signed integer byte-packed-int64: $inherit: int64 align: 8 # byte-packed 8-bit unsigned integer bit-packed-uint8: $inherit: uint8 align: 1 # bit-packed 8-bit signed integer bit-packed-int8: $inherit: int8 align: 1 # bit-packed 16-bit unsigned integer bit-packed-uint16: $inherit: uint16 align: 1 # bit-packed 16-bit signed integer bit-packed-int16: $inherit: int16 align: 1 # bit-packed 32-bit unsigned integer bit-packed-uint32: $inherit: uint32 align: 1 # bit-packed 32-bit signed integer bit-packed-int32: $inherit: int32 align: 1 # bit-packed 64-bit unsigned integer bit-packed-uint64: $inherit: uint64 align: 1 # bit-packed 64-bit signed integer bit-packed-int64: $inherit: int64 align: 1 barectf-2.3.0/barectf/include/stdmisc.yaml000066400000000000000000000005471317147435100205210ustar00rootroot00000000000000# Include this in the metadata object of your configuration to have # access to various useful type aliases. type-aliases: # UUID array uuid: class: array length: 16 element-type: class: int size: 8 # CTF magic number type ctf-magic: class: int size: 32 align: 32 # a simple string string: class: string barectf-2.3.0/barectf/include/trace-basic.yaml000066400000000000000000000011051317147435100212170ustar00rootroot00000000000000# Include this in the trace object of your configuration to get a # default, basic trace object with a little-endian byte order. The # packet header type contains the 32-bit magic number, followed by the # UUID, followed by an 8-bit stream ID. The trace's UUID is # automatically generated by barectf. byte-order: le uuid: auto packet-header-type: class: struct fields: magic: class: int size: 32 align: 32 uuid: class: array length: 16 element-type: class: int size: 8 stream_id: class: int size: 8 barectf-2.3.0/barectf/metadata.py000066400000000000000000000422561317147435100167010ustar00rootroot00000000000000# The MIT License (MIT) # # Copyright (c) 2015 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 enum import collections @enum.unique class ByteOrder(enum.Enum): LE = 0 BE = 1 @enum.unique class Encoding(enum.Enum): NONE = 0 UTF8 = 1 ASCII = 2 class Type: @property def align(self): return None @property def size(self): pass @property def is_dynamic(self): raise NotImplementedError() class PropertyMapping: def __init__(self, object, prop): self._object = object self._prop = prop @property def object(self): return self._object @object.setter def object(self, value): self._object = value @property def prop(self): return self.prop @prop.setter def prop(self, value): self.prop = value class Integer(Type): def __init__(self): self.set_default_size() self.set_default_align() self.set_default_signed() self.set_default_byte_order() self.set_default_base() self.set_default_encoding() self.set_default_property_mappings() def set_default_size(self): self._size = None def set_default_align(self): self._align = None def set_default_signed(self): self._signed = False def set_default_byte_order(self): self._byte_order = None def set_default_base(self): self._base = 10 def set_default_encoding(self): self._encoding = Encoding.NONE def set_default_property_mappings(self): self._property_mappings = [] @property def signed(self): return self._signed @signed.setter def signed(self, value): self._signed = value @property def byte_order(self): return self._byte_order @byte_order.setter def byte_order(self, value): self._byte_order = value @property def base(self): return self._base @base.setter def base(self, value): self._base = value @property def encoding(self): return self._encoding @encoding.setter def encoding(self, value): self._encoding = value @property def align(self): if self._align is None: if self._size is None: return else: if self._size % 8 == 0: return 8 else: return 1 else: return self._align @align.setter def align(self, value): self._align = value @property def size(self): return self._size @size.setter def size(self, value): self._size = value @property def property_mappings(self): return self._property_mappings @property def is_dynamic(self): return False class FloatingPoint(Type): def __init__(self): self.set_default_exp_size() self.set_default_mant_size() self.set_default_align() self.set_default_byte_order() def set_default_exp_size(self): self._exp_size = None def set_default_mant_size(self): self._mant_size = None def set_default_align(self): self._align = 8 def set_default_byte_order(self): self._byte_order = None @property def exp_size(self): return self._exp_size @exp_size.setter def exp_size(self, value): self._exp_size = value @property def mant_size(self): return self._mant_size @mant_size.setter def mant_size(self, value): self._mant_size = value @property def size(self): if self._exp_size is None or self._mant_size is None: return return self._exp_size + self._mant_size @property def byte_order(self): return self._byte_order @byte_order.setter def byte_order(self, value): self._byte_order = value @property def align(self): return self._align @align.setter def align(self, value): self._align = value @property def is_dynamic(self): return False class Enum(Type): def __init__(self): self.set_default_value_type() self.set_default_members() def set_default_value_type(self): self._value_type = None def set_default_members(self): self._members = collections.OrderedDict() @property def align(self): return self._value_type.align @property def size(self): return self._value_type.size @property def value_type(self): return self._value_type @value_type.setter def value_type(self, value): self._value_type = value @property def members(self): return self._members @property def last_value(self): if not self._members: return return list(self._members.values())[-1][1] def value_of(self, label): return self._members[label] def label_of(self, value): for label, vrange in self._members.items(): if value >= vrange[0] and value <= vrange[1]: return label def __getitem__(self, key): if type(key) is str: return self.value_of(key) elif type(key) is int: return self.label_of(key) raise TypeError('wrong subscript type') @property def is_dynamic(self): return False class String(Type): def __init__(self): self.set_default_encoding() def set_default_encoding(self): self._encoding = Encoding.UTF8 @property def align(self): return 8 @property def encoding(self): return self._encoding @encoding.setter def encoding(self, value): self._encoding = value @property def is_dynamic(self): return True class Array(Type): def __init__(self): self.set_default_element_type() self.set_default_length() def set_default_element_type(self): self._default_element_type = None def set_default_length(self): self._default_length = None @property def align(self): return self._element_type.align @property def element_type(self): return self._element_type @element_type.setter def element_type(self, value): self._element_type = value @property def length(self): return self._length @length.setter def length(self, value): self._length = value @property def is_variable_length(self): return type(self._length) is not int @property def is_dynamic(self): if self.is_variable_length: return True return self.element_type.is_dynamic class Struct(Type): def __init__(self): self.set_default_min_align() self.set_default_fields() def set_default_min_align(self): self._min_align = 1 def set_default_fields(self): self._fields = collections.OrderedDict() @property def min_align(self): return self._min_align @min_align.setter def min_align(self, value): self._min_align = value @property def align(self): align = self.min_align for field in self.fields.values(): if field.align is None: return if field.align > align: align = field.align return align @property def is_dynamic(self): for field in self.fields.values(): if field.is_dynamic: return True return False @property def fields(self): return self._fields def __getitem__(self, key): return self.fields[key] def __len__(self): return len(self._fields) class Variant(Type): def __init__(self): self.set_default_tag() self.set_default_types() def set_default_tag(self): self._tag = None def set_default_types(self): self._types = collections.OrderedDict() @property def align(self): single_type = self.get_single_type() if single_type is not None: return single_type.align # if all the possible types have the same alignment, then # there's only one possible alignment align = None for t in self.types.values(): if t.align is None: return if align is None: # first align = t.align else: if t.align != align: return return align @property def size(self): single_type = self.get_single_type() if single_type is not None: return single_type.size @property def tag(self): return self._tag @tag.setter def tag(self, value): self._tag = value @property def types(self): return self._types def __getitem__(self, key): return self.types[key] def get_single_type(self): if len(self.members) == 1: return list(self.members.values())[0] @property def is_dynamic(self): single_type = self.get_single_type() if single_type is not None: return single_type.is_dynamic return True class Trace: def __init__(self): self._byte_order = None self._packet_header_type = None self._uuid = None @property def uuid(self): return self._uuid @uuid.setter def uuid(self, value): self._uuid = value @property def byte_order(self): return self._byte_order @byte_order.setter def byte_order(self, value): self._byte_order = value @property def packet_header_type(self): return self._packet_header_type @packet_header_type.setter def packet_header_type(self, value): self._packet_header_type = value class Env(collections.OrderedDict): pass class Clock: def __init__(self): self.set_default_name() self.set_default_uuid() self.set_default_description() self.set_default_freq() self.set_default_error_cycles() self.set_default_offset_seconds() self.set_default_offset_cycles() self.set_default_absolute() self.set_default_return_ctype() def set_default_name(self): self._name = None def set_default_uuid(self): self._uuid = None def set_default_description(self): self._description = None def set_default_freq(self): self._freq = 1000000000 def set_default_error_cycles(self): self._error_cycles = 0 def set_default_offset_seconds(self): self._offset_seconds = 0 def set_default_offset_cycles(self): self._offset_cycles = 0 def set_default_absolute(self): self._absolute = False def set_default_return_ctype(self): self._return_ctype = 'uint32_t' @property def name(self): return self._name @name.setter def name(self, value): self._name = value @property def uuid(self): return self._uuid @uuid.setter def uuid(self, value): self._uuid = value @property def description(self): return self._description @description.setter def description(self, value): self._description = value @property def error_cycles(self): return self._error_cycles @error_cycles.setter def error_cycles(self, value): self._error_cycles = value @property def freq(self): return self._freq @freq.setter def freq(self, value): self._freq = value @property def offset_seconds(self): return self._offset_seconds @offset_seconds.setter def offset_seconds(self, value): self._offset_seconds = value @property def offset_cycles(self): return self._offset_cycles @offset_cycles.setter def offset_cycles(self, value): self._offset_cycles = value @property def absolute(self): return self._absolute @absolute.setter def absolute(self, value): self._absolute = value @property def return_ctype(self): return self._return_ctype @return_ctype.setter def return_ctype(self, value): self._return_ctype = value LogLevel = collections.namedtuple('LogLevel', ['name', 'value']) class Event: def __init__(self): self._id = None self._name = None self._log_level = None self._context_type = None self._payload_type = None @property def id(self): return self._id @id.setter def id(self, value): self._id = value @property def name(self): return self._name @name.setter def name(self, value): self._name = value @property def log_level(self): return self._log_level @log_level.setter def log_level(self, value): self._log_level = value @property def context_type(self): return self._context_type @context_type.setter def context_type(self, value): self._context_type = value @property def payload_type(self): return self._payload_type @payload_type.setter def payload_type(self, value): self._payload_type = value def __getitem__(self, key): if type(self.payload_type) in [Struct, Variant]: return self.payload_type[key] raise TypeError('{} is not subscriptable') class Stream: def __init__(self): self._id = 0 self._name = None self._packet_context_type = None self._event_header_type = None self._event_context_type = None self._events = collections.OrderedDict() @property def name(self): return self._name @name.setter def name(self, value): self._name = value @property def id(self): return self._id @id.setter def id(self, value): self._id = value @property def packet_context_type(self): return self._packet_context_type @packet_context_type.setter def packet_context_type(self, value): self._packet_context_type = value @property def event_header_type(self): return self._event_header_type @event_header_type.setter def event_header_type(self, value): self._event_header_type = value @property def event_context_type(self): return self._event_context_type @event_context_type.setter def event_context_type(self, value): self._event_context_type = value @property def events(self): return self._events def is_event_empty(self, event): total_fields = 0 if self.event_header_type: total_fields += len(self.event_header_type) if self.event_context_type: total_fields += len(self.event_context_type) if event.context_type: total_fields += len(event.context_type) if event.payload_type: total_fields += len(event.payload_type) return total_fields == 0 class Metadata: def __init__(self): self._trace = None self._env = collections.OrderedDict() self._clocks = collections.OrderedDict() self._streams = collections.OrderedDict() self._default_stream_name = None @property def trace(self): return self._trace @trace.setter def trace(self, value): self._trace = value @property def env(self): return self._env @env.setter def env(self, value): self._env = value @property def clocks(self): return self._clocks @clocks.setter def clocks(self, value): self._clocks = value @property def streams(self): return self._streams @streams.setter def streams(self, value): self._streams = value @property def default_stream_name(self): return self._default_stream_name @default_stream_name.setter def default_stream_name(self, value): self._default_stream_name = value @property def default_stream(self): if self._default_stream_name in self._streams: return self._streams[self._default_stream_name] barectf-2.3.0/barectf/templates.py000066400000000000000000000547071317147435100171230ustar00rootroot00000000000000# The MIT License (MIT) # # Copyright (c) 2015-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. _CLOCK_CB = '{return_ctype} (*{cname}_clock_get_value)(void *);' _PLATFORM_CALLBACKS_BEGIN = '''/* barectf platform callbacks */ struct {prefix}platform_callbacks {{ /* clock callbacks */''' _PLATFORM_CALLBACKS_END = ''' /* is back-end full? */ int (*is_backend_full)(void *); /* open packet */ void (*open_packet)(void *); /* close packet */ void (*close_packet)(void *); };''' _CTX_PARENT = '''/* common barectf context */ struct {prefix}ctx {{ /* platform callbacks */ struct {prefix}platform_callbacks cbs; /* platform data (passed to callbacks) */ void *data; /* output buffer (will contain a CTF binary packet) */ uint8_t *buf; /* packet size in bits */ uint32_t packet_size; /* content size in bits */ uint32_t content_size; /* current position from beginning of packet in bits */ uint32_t at; /* packet header + context size (content offset) */ uint32_t off_content; /* events discarded */ uint32_t events_discarded; /* current packet is opened */ int packet_is_open; /* in tracing code */ volatile int in_tracing_section; /* tracing is enabled */ volatile int is_tracing_enabled; }};''' _CTX_BEGIN = '''/* context for stream "{sname}" */ struct {prefix}{sname}_ctx {{ /* parent */ struct {prefix}ctx parent; /* config-specific members follow */''' _CTX_END = '};' _FUNC_INIT_PROTO = '''/* initialize context */ void {prefix}init( void *vctx, uint8_t *buf, uint32_t buf_size, struct {prefix}platform_callbacks cbs, void *data )''' _FUNC_INIT_BODY = '''{{ struct {prefix}ctx *ctx = FROM_VOID_PTR(struct {prefix}ctx, vctx); ctx->cbs = cbs; ctx->data = data; ctx->buf = buf; ctx->packet_size = _BYTES_TO_BITS(buf_size); ctx->at = 0; ctx->events_discarded = 0; ctx->packet_is_open = 0; ctx->in_tracing_section = 0; ctx->is_tracing_enabled = 1; }}''' _FUNC_OPEN_PROTO_BEGIN = '''/* open packet for stream "{sname}" */ void {prefix}{sname}_open_packet( struct {prefix}{sname}_ctx *ctx''' _FUNC_OPEN_PROTO_END = ')' _FUNC_OPEN_BODY_BEGIN = '''{{ {ts} const int saved_in_tracing_section = ctx->parent.in_tracing_section; /* * This function is either called by a tracing function, or * directly by the platform. * * If it's called by a tracing function, then * ctx->parent.in_tracing_section is 1, so it's safe to open * the packet here (alter the packet), even if tracing was * disabled in the meantime because we're already in a tracing * section (which finishes at the end of the tracing function * call). * * If it's called directly by the platform, then if tracing is * disabled, we don't want to alter the packet, and return * immediately. */ if (!ctx->parent.is_tracing_enabled && !saved_in_tracing_section) {{ ctx->parent.in_tracing_section = 0; return; }} /* we can modify the packet */ ctx->parent.in_tracing_section = 1; ''' _FUNC_OPEN_BODY_END = ''' ctx->parent.off_content = ctx->parent.at; /* mark current packet as open */ ctx->parent.packet_is_open = 1; /* not tracing anymore */ ctx->parent.in_tracing_section = saved_in_tracing_section; }''' _FUNC_CLOSE_PROTO = '''/* close packet for stream "{sname}" */ void {prefix}{sname}_close_packet(struct {prefix}{sname}_ctx *ctx)''' _FUNC_CLOSE_BODY_BEGIN = '''{{ {ts} const int saved_in_tracing_section = ctx->parent.in_tracing_section; /* * This function is either called by a tracing function, or * directly by the platform. * * If it's called by a tracing function, then * ctx->parent.in_tracing_section is 1, so it's safe to close * the packet here (alter the packet), even if tracing was * disabled in the meantime, because we're already in a tracing * section (which finishes at the end of the tracing function * call). * * If it's called directly by the platform, then if tracing is * disabled, we don't want to alter the packet, and return * immediately. */ if (!ctx->parent.is_tracing_enabled && !saved_in_tracing_section) {{ ctx->parent.in_tracing_section = 0; return; }} /* we can modify the packet */ ctx->parent.in_tracing_section = 1; ''' _FUNC_CLOSE_BODY_END = ''' /* go back to end of packet */ ctx->parent.at = ctx->parent.packet_size; /* mark packet as closed */ ctx->parent.packet_is_open = 0; /* not tracing anymore */ ctx->parent.in_tracing_section = saved_in_tracing_section; }''' _DEFINE_DEFAULT_STREAM_TRACE = '#define {prefix}trace_{evname} {prefix}{sname}_trace_{evname}' _FUNC_TRACE_PROTO_BEGIN = '''/* trace (stream "{sname}", event "{evname}") */ void {prefix}{sname}_trace_{evname}( struct {prefix}{sname}_ctx *ctx''' _FUNC_TRACE_PROTO_END = ')' _FUNC_TRACE_BODY = '''{{ {ts} uint32_t ev_size; if (!ctx->parent.is_tracing_enabled) {{ return; }} /* we can modify the packet */ ctx->parent.in_tracing_section = 1; /* get event size */ ev_size = _get_event_size_{sname}_{evname}(TO_VOID_PTR(ctx){params}); /* do we have enough space to serialize? */ if (!_reserve_event_space(TO_VOID_PTR(ctx), ev_size)) {{ /* no: forget this */ ctx->parent.in_tracing_section = 0; return; }} /* serialize event */ _serialize_event_{sname}_{evname}(TO_VOID_PTR(ctx), ts{params}); /* commit event */ _commit_event(TO_VOID_PTR(ctx)); /* not tracing anymore */ ctx->parent.in_tracing_section = 0; }}''' _FUNC_GET_EVENT_SIZE_PROTO_BEGIN = '''static uint32_t _get_event_size_{sname}_{evname}( void *vctx''' _FUNC_GET_EVENT_SIZE_PROTO_END = ')' _FUNC_GET_EVENT_SIZE_BODY_BEGIN = '''{{ struct {prefix}ctx *ctx = FROM_VOID_PTR(struct {prefix}ctx, vctx); uint32_t at = ctx->at;''' _FUNC_GET_EVENT_SIZE_BODY_END = ''' return at - ctx->at; }''' _FUNC_SERIALIZE_STREAM_EVENT_HEADER_PROTO_BEGIN = '''static void _serialize_stream_event_header_{sname}( void *vctx, {clock_ctype} ts, uint32_t event_id''' _FUNC_SERIALIZE_STREAM_EVENT_HEADER_PROTO_END = ')' _FUNC_SERIALIZE_STREAM_EVENT_HEADER_BODY_BEGIN = '''{{ struct {prefix}ctx *ctx = FROM_VOID_PTR(struct {prefix}ctx, vctx);''' _FUNC_SERIALIZE_STREAM_EVENT_HEADER_BODY_END = '}' _FUNC_SERIALIZE_STREAM_EVENT_CONTEXT_PROTO_BEGIN = '''static void _serialize_stream_event_context_{sname}( void *vctx''' _FUNC_SERIALIZE_STREAM_EVENT_CONTEXT_PROTO_END = ')' _FUNC_SERIALIZE_STREAM_EVENT_CONTEXT_BODY_BEGIN = '''{{ struct {prefix}ctx *ctx = FROM_VOID_PTR(struct {prefix}ctx, vctx);''' _FUNC_SERIALIZE_STREAM_EVENT_CONTEXT_BODY_END = '}' _FUNC_SERIALIZE_EVENT_PROTO_BEGIN = '''static void _serialize_event_{sname}_{evname}( void *vctx, {clock_ctype} ts''' _FUNC_SERIALIZE_EVENT_PROTO_END = ')' _FUNC_SERIALIZE_EVENT_BODY_BEGIN = '''{{ struct {prefix}ctx *ctx = FROM_VOID_PTR(struct {prefix}ctx, vctx);''' _FUNC_SERIALIZE_EVENT_BODY_END = '}' _HEADER_BEGIN = '''#ifndef _{ucprefix}H #define _{ucprefix}H /* * The MIT License (MIT) * * Copyright (c) 2015-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. * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * The following C code was generated by barectf {version} * on {date}. * * For more details, see . */ #include #include "{bitfield_header_filename}" #ifdef __cplusplus extern "C" {{ #endif {prefix_def} {default_stream_def} {default_stream_trace_defs} struct {prefix}ctx; uint32_t {prefix}packet_size(void *ctx); int {prefix}packet_is_full(void *ctx); int {prefix}packet_is_empty(void *ctx); uint32_t {prefix}packet_events_discarded(void *ctx); uint8_t *{prefix}packet_buf(void *ctx); void {prefix}packet_set_buf(void *ctx, uint8_t *buf, uint32_t buf_size); uint32_t {prefix}packet_buf_size(void *ctx); int {prefix}packet_is_open(void *ctx); int {prefix}is_in_tracing_section(void *ctx); volatile const int *{prefix}is_in_tracing_section_ptr(void *ctx); int {prefix}is_tracing_enabled(void *ctx); void {prefix}enable_tracing(void *ctx, int enable);''' _HEADER_END = '''#ifdef __cplusplus }} #endif #endif /* _{ucprefix}H */ ''' _C_SRC = '''/* * The MIT License (MIT) * * Copyright (c) 2015-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. * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * The following C code was generated by barectf {version} * on {date}. * * For more details, see . */ #include #include #include #include "{header_filename}" #define _ALIGN(_at, _align) \\ do {{ \\ (_at) = ((_at) + ((_align) - 1)) & -(_align); \\ }} while (0) #ifdef __cplusplus # define TO_VOID_PTR(_value) static_cast(_value) # define FROM_VOID_PTR(_type, _value) static_cast<_type *>(_value) #else # define TO_VOID_PTR(_value) ((void *) (_value)) # define FROM_VOID_PTR(_type, _value) ((_type *) (_value)) #endif #define _BITS_TO_BYTES(_x) ((_x) >> 3) #define _BYTES_TO_BITS(_x) ((_x) << 3) union f2u {{ float f; uint32_t u; }}; union d2u {{ double f; uint64_t u; }}; uint32_t {prefix}packet_size(void *ctx) {{ return FROM_VOID_PTR(struct {prefix}ctx, ctx)->packet_size; }} int {prefix}packet_is_full(void *ctx) {{ struct {prefix}ctx *cctx = FROM_VOID_PTR(struct {prefix}ctx, ctx); return cctx->at == cctx->packet_size; }} int {prefix}packet_is_empty(void *ctx) {{ struct {prefix}ctx *cctx = FROM_VOID_PTR(struct {prefix}ctx, ctx); return cctx->at <= cctx->off_content; }} uint32_t {prefix}packet_events_discarded(void *ctx) {{ return FROM_VOID_PTR(struct {prefix}ctx, ctx)->events_discarded; }} uint8_t *{prefix}packet_buf(void *ctx) {{ return FROM_VOID_PTR(struct {prefix}ctx, ctx)->buf; }} uint32_t {prefix}packet_buf_size(void *ctx) {{ struct {prefix}ctx *cctx = FROM_VOID_PTR(struct {prefix}ctx, ctx); return _BITS_TO_BYTES(cctx->packet_size); }} void {prefix}packet_set_buf(void *ctx, uint8_t *buf, uint32_t buf_size) {{ struct {prefix}ctx *cctx = FROM_VOID_PTR(struct {prefix}ctx, ctx); cctx->buf = buf; cctx->packet_size = _BYTES_TO_BITS(buf_size); }} int {prefix}packet_is_open(void *ctx) {{ return FROM_VOID_PTR(struct {prefix}ctx, ctx)->packet_is_open; }} int {prefix}is_in_tracing_section(void *ctx) {{ return FROM_VOID_PTR(struct {prefix}ctx, ctx)->in_tracing_section; }} volatile const int *{prefix}is_in_tracing_section_ptr(void *ctx) {{ return &FROM_VOID_PTR(struct {prefix}ctx, ctx)->in_tracing_section; }} int {prefix}is_tracing_enabled(void *ctx) {{ return FROM_VOID_PTR(struct {prefix}ctx, ctx)->is_tracing_enabled; }} void {prefix}enable_tracing(void *ctx, int enable) {{ FROM_VOID_PTR(struct {prefix}ctx, ctx)->is_tracing_enabled = enable; }} static void _write_cstring(struct {prefix}ctx *ctx, const char *src) {{ uint32_t sz = strlen(src) + 1; memcpy(&ctx->buf[_BITS_TO_BYTES(ctx->at)], src, sz); ctx->at += _BYTES_TO_BITS(sz); }} static int _reserve_event_space(void *vctx, uint32_t ev_size) {{ struct {prefix}ctx *ctx = FROM_VOID_PTR(struct {prefix}ctx, vctx); /* event _cannot_ fit? */ if (ev_size > (ctx->packet_size - ctx->off_content)) {{ ctx->events_discarded++; return 0; }} /* packet is full? */ if ({prefix}packet_is_full(ctx)) {{ /* yes: is back-end full? */ if (ctx->cbs.is_backend_full(ctx->data)) {{ /* yes: discard event */ ctx->events_discarded++; return 0; }} /* back-end is not full: open new packet */ ctx->cbs.open_packet(ctx->data); }} /* event fits the current packet? */ if (ev_size > (ctx->packet_size - ctx->at)) {{ /* no: close packet now */ ctx->cbs.close_packet(ctx->data); /* is back-end full? */ if (ctx->cbs.is_backend_full(ctx->data)) {{ /* yes: discard event */ ctx->events_discarded++; return 0; }} /* back-end is not full: open new packet */ ctx->cbs.open_packet(ctx->data); assert(ev_size <= (ctx->packet_size - ctx->at)); }} return 1; }} static void _commit_event(void *vctx) {{ struct {prefix}ctx *ctx = FROM_VOID_PTR(struct {prefix}ctx, vctx); /* is packet full? */ if ({prefix}packet_is_full(ctx)) {{ /* yes: close it now */ ctx->cbs.close_packet(ctx->data); }} }}''' _BITFIELD = '''#ifndef _$PREFIX$BITFIELD_H #define _$PREFIX$BITFIELD_H /* * BabelTrace * * Bitfields read/write functions. * * Copyright 2010 - Mathieu Desnoyers * * 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 #ifdef __cplusplus # define CAST_PTR(_type, _value) \\ static_cast<_type>(static_cast(_value)) #else # define CAST_PTR(_type, _value) ((void *) (_value)) #endif #define $PREFIX$BYTE_ORDER $ENDIAN_DEF$ /* We can't shift a int from 32 bit, >> 32 and << 32 on int is undefined */ #define _$prefix$bt_piecewise_rshift(_vtype, _v, _shift) \\ do { \\ unsigned long ___shift = (_shift); \\ unsigned long sb = (___shift) / (sizeof(_v) * CHAR_BIT - 1); \\ unsigned long final = (___shift) % (sizeof(_v) * CHAR_BIT - 1); \\ \\ for (; sb; sb--) \\ _v >>= sizeof(_v) * CHAR_BIT - 1; \\ _v >>= final; \\ } while (0) /* * $prefix$bt_bitfield_write - write integer to a bitfield in native endianness * * Save integer to the bitfield, which starts at the "start" bit, has "len" * bits. * The inside of a bitfield is from high bits to low bits. * Uses native endianness. * For unsigned "v", pad MSB with 0 if bitfield is larger than v. * For signed "v", sign-extend v if bitfield is larger than v. * * On little endian, bytes are placed from the less significant to the most * significant. Also, consecutive bitfields are placed from lower bits to higher * bits. * * On big endian, bytes are places from most significant to less significant. * Also, consecutive bitfields are placed from higher to lower bits. */ #define _$prefix$bt_bitfield_write_le(_ptr, type, _start, _length, _vtype, _v) \\ do { \\ _vtype __v = (_v); \\ type *__ptr = CAST_PTR(type *, _ptr); \\ unsigned long __start = (_start), __length = (_length); \\ type mask, cmask; \\ unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \\ unsigned long start_unit, end_unit, this_unit; \\ unsigned long end, cshift; /* cshift is "complement shift" */ \\ \\ if (!__length) \\ break; \\ \\ end = __start + __length; \\ start_unit = __start / ts; \\ end_unit = (end + (ts - 1)) / ts; \\ \\ /* Trim v high bits */ \\ if (__length < sizeof(__v) * CHAR_BIT) \\ __v &= ~((~(_vtype) 0) << __length); \\ \\ /* We can now append v with a simple "or", shift it piece-wise */ \\ this_unit = start_unit; \\ if (start_unit == end_unit - 1) { \\ mask = ~((~(type) 0) << (__start % ts)); \\ if (end % ts) \\ mask |= (~(type) 0) << (end % ts); \\ cmask = (type) __v << (__start % ts); \\ cmask &= ~mask; \\ __ptr[this_unit] &= mask; \\ __ptr[this_unit] |= cmask; \\ break; \\ } \\ if (__start % ts) { \\ cshift = __start % ts; \\ mask = ~((~(type) 0) << cshift); \\ cmask = (type) __v << cshift; \\ cmask &= ~mask; \\ __ptr[this_unit] &= mask; \\ __ptr[this_unit] |= cmask; \\ _$prefix$bt_piecewise_rshift(_vtype, __v, ts - cshift); \\ __start += ts - cshift; \\ this_unit++; \\ } \\ for (; this_unit < end_unit - 1; this_unit++) { \\ __ptr[this_unit] = (type) __v; \\ _$prefix$bt_piecewise_rshift(_vtype, __v, ts); \\ __start += ts; \\ } \\ if (end % ts) { \\ mask = (~(type) 0) << (end % ts); \\ cmask = (type) __v; \\ cmask &= ~mask; \\ __ptr[this_unit] &= mask; \\ __ptr[this_unit] |= cmask; \\ } else \\ __ptr[this_unit] = (type) __v; \\ } while (0) #define _$prefix$bt_bitfield_write_be(_ptr, type, _start, _length, _vtype, _v) \\ do { \\ _vtype __v = (_v); \\ type *__ptr = CAST_PTR(type *, _ptr); \\ unsigned long __start = (_start), __length = (_length); \\ type mask, cmask; \\ unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \\ unsigned long start_unit, end_unit, this_unit; \\ unsigned long end, cshift; /* cshift is "complement shift" */ \\ \\ if (!__length) \\ break; \\ \\ end = __start + __length; \\ start_unit = __start / ts; \\ end_unit = (end + (ts - 1)) / ts; \\ \\ /* Trim v high bits */ \\ if (__length < sizeof(__v) * CHAR_BIT) \\ __v &= ~((~(_vtype) 0) << __length); \\ \\ /* We can now append v with a simple "or", shift it piece-wise */ \\ this_unit = end_unit - 1; \\ if (start_unit == end_unit - 1) { \\ mask = ~((~(type) 0) << ((ts - (end % ts)) % ts)); \\ if (__start % ts) \\ mask |= (~((type) 0)) << (ts - (__start % ts)); \\ cmask = (type) __v << ((ts - (end % ts)) % ts); \\ cmask &= ~mask; \\ __ptr[this_unit] &= mask; \\ __ptr[this_unit] |= cmask; \\ break; \\ } \\ if (end % ts) { \\ cshift = end % ts; \\ mask = ~((~(type) 0) << (ts - cshift)); \\ cmask = (type) __v << (ts - cshift); \\ cmask &= ~mask; \\ __ptr[this_unit] &= mask; \\ __ptr[this_unit] |= cmask; \\ _$prefix$bt_piecewise_rshift(_vtype, __v, cshift); \\ end -= cshift; \\ this_unit--; \\ } \\ for (; (long) this_unit >= (long) start_unit + 1; this_unit--) { \\ __ptr[this_unit] = (type) __v; \\ _$prefix$bt_piecewise_rshift(_vtype, __v, ts); \\ end -= ts; \\ } \\ if (__start % ts) { \\ mask = (~(type) 0) << (ts - (__start % ts)); \\ cmask = (type) __v; \\ cmask &= ~mask; \\ __ptr[this_unit] &= mask; \\ __ptr[this_unit] |= cmask; \\ } else \\ __ptr[this_unit] = (type) __v; \\ } while (0) /* * $prefix$bt_bitfield_write_le - write integer to a bitfield in little endian * $prefix$bt_bitfield_write_be - write integer to a bitfield in big endian */ #if ($PREFIX$BYTE_ORDER == LITTLE_ENDIAN) #define $prefix$bt_bitfield_write_le(ptr, type, _start, _length, _vtype, _v) \\ _$prefix$bt_bitfield_write_le(ptr, type, _start, _length, _vtype, _v) #define $prefix$bt_bitfield_write_be(ptr, type, _start, _length, _vtype, _v) \\ _$prefix$bt_bitfield_write_be(ptr, unsigned char, _start, _length, _vtype, _v) #elif ($PREFIX$BYTE_ORDER == BIG_ENDIAN) #define $prefix$bt_bitfield_write_le(ptr, type, _start, _length, _vtype, _v) \\ _$prefix$bt_bitfield_write_le(ptr, unsigned char, _start, _length, _vtype, _v) #define $prefix$bt_bitfield_write_be(ptr, type, _start, _length, _vtype, _v) \\ _$prefix$bt_bitfield_write_be(ptr, type, _start, _length, _vtype, _v) #else /* ($PREFIX$BYTE_ORDER == PDP_ENDIAN) */ #error "Byte order not supported" #endif #endif /* _$PREFIX$BITFIELD_H */ ''' barectf-2.3.0/barectf/tsdl182gen.py000066400000000000000000000253521317147435100170120ustar00rootroot00000000000000# The MIT License (MIT) # # Copyright (c) 2015 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. from barectf import metadata from barectf import codegen import datetime import barectf _bo_to_string_map = { metadata.ByteOrder.LE: 'le', metadata.ByteOrder.BE: 'be', } _encoding_to_string_map = { metadata.Encoding.NONE: 'none', metadata.Encoding.ASCII: 'ASCII', metadata.Encoding.UTF8: 'UTF8', } def _bo_to_string(bo): return _bo_to_string_map[bo] def _encoding_to_string(encoding): return _encoding_to_string_map[encoding] def _bool_to_string(b): return 'true' if b else 'false' def _gen_integer(t, cg): cg.add_line('integer {') cg.indent() cg.add_line('size = {};'.format(t.size)) cg.add_line('align = {};'.format(t.align)) cg.add_line('signed = {};'.format(_bool_to_string(t.signed))) cg.add_line('byte_order = {};'.format(_bo_to_string(t.byte_order))) cg.add_line('base = {};'.format(t.base)) cg.add_line('encoding = {};'.format(_encoding_to_string(t.encoding))) if t.property_mappings: clock_name = t.property_mappings[0].object.name cg.add_line('map = clock.{}.value;'.format(clock_name)) cg.unindent() cg.add_line('}') def _gen_float(t, cg): cg.add_line('floating_point {') cg.indent() cg.add_line('exp_dig = {};'.format(t.exp_size)) cg.add_line('mant_dig = {};'.format(t.mant_size)) cg.add_line('align = {};'.format(t.align)) cg.add_line('byte_order = {};'.format(_bo_to_string(t.byte_order))) cg.unindent() cg.add_line('}') def _gen_enum(t, cg): cg.add_line('enum : ') cg.add_glue() _gen_type(t.value_type, cg) cg.append_to_last_line(' {') cg.indent() for label, (mn, mx) in t.members.items(): if mn == mx: rg = str(mn) else: rg = '{} ... {}'.format(mn, mx) line = '"{}" = {},'.format(label, rg) cg.add_line(line) cg.unindent() cg.add_line('}') def _gen_string(t, cg): cg.add_line('string {') cg.indent() cg.add_line('encoding = {};'.format(_encoding_to_string(t.encoding))) cg.unindent() cg.add_line('}') def _find_deepest_array_element_type(t): if type(t) is metadata.Array: return _find_deepest_array_element_type(t.element_type) return t def _fill_array_lengths(t, lengths): if type(t) is metadata.Array: lengths.append(t.length) _fill_array_lengths(t.element_type, lengths) def _gen_struct_variant_entry(name, t, cg): real_t = _find_deepest_array_element_type(t) _gen_type(real_t, cg) cg.append_to_last_line(' {}'.format(name)) # array lengths = [] _fill_array_lengths(t, lengths) if lengths: for length in reversed(lengths): cg.append_to_last_line('[{}]'.format(length)) cg.append_to_last_line(';') def _gen_struct(t, cg): cg.add_line('struct {') cg.indent() for field_name, field_type in t.fields.items(): _gen_struct_variant_entry(field_name, field_type, cg) cg.unindent() if not t.fields: cg.add_glue() cg.add_line('}} align({})'.format(t.min_align)) def _gen_variant(t, cg): cg.add_line('variant <{}> {{'.format(t.tag)) cg.indent() for type_name, type_type in t.types.items(): _gen_struct_variant_entry(type_name, type_type, cg) cg.unindent() if not t.types: cg.add_glue() cg.add_line('}') _type_to_gen_type_func = { metadata.Integer: _gen_integer, metadata.FloatingPoint: _gen_float, metadata.Enum: _gen_enum, metadata.String: _gen_string, metadata.Struct: _gen_struct, metadata.Variant: _gen_variant, } def _gen_type(t, cg): _type_to_gen_type_func[type(t)](t, cg) def _gen_entity(name, t, cg): cg.add_line('{} := '.format(name)) cg.add_glue() _gen_type(t, cg) cg.append_to_last_line(';') def _gen_start_block(name, cg): cg.add_line('{} {{'.format(name)) cg.indent() def _gen_end_block(cg): cg.unindent() cg.add_line('};') cg.add_empty_line() def _gen_trace_block(meta, cg): trace = meta.trace _gen_start_block('trace', cg) cg.add_line('major = 1;') cg.add_line('minor = 8;') line = 'byte_order = {};'.format(_bo_to_string(trace.byte_order)) cg.add_line(line) if trace.uuid is not None: line = 'uuid = "{}";'.format(trace.uuid) cg.add_line(line) if trace.packet_header_type is not None: _gen_entity('packet.header', trace.packet_header_type, cg) _gen_end_block(cg) def _escape_literal_string(s): esc = s.replace('\\', '\\\\') esc = esc.replace('\n', '\\n') esc = esc.replace('\r', '\\r') esc = esc.replace('\t', '\\t') esc = esc.replace('"', '\\"') return esc def _gen_env_block(meta, cg): env = meta.env if not env: return _gen_start_block('env', cg) for name, value in env.items(): if type(value) is int: value_string = str(value) else: value_string = '"{}"'.format(_escape_literal_string(value)) cg.add_line('{} = {};'.format(name, value_string)) _gen_end_block(cg) def _gen_clock_block(clock, cg): _gen_start_block('clock', cg) cg.add_line('name = {};'.format(clock.name)) if clock.description is not None: desc = _escape_literal_string(clock.description) cg.add_line('description = "{}";'.format(desc)) if clock.uuid is not None: cg.add_line('uuid = "{}";'.format(clock.uuid)) cg.add_line('freq = {};'.format(clock.freq)) cg.add_line('offset_s = {};'.format(clock.offset_seconds)) cg.add_line('offset = {};'.format(clock.offset_cycles)) cg.add_line('precision = {};'.format(clock.error_cycles)) cg.add_line('absolute = {};'.format(_bool_to_string(clock.absolute))) _gen_end_block(cg) def _gen_clock_blocks(meta, cg): clocks = meta.clocks for clock in clocks.values(): _gen_clock_block(clock, cg) def _gen_stream_block(meta, stream, cg): cg.add_cc_line(stream.name.replace('/', '')) _gen_start_block('stream', cg) if meta.trace.packet_header_type is not None: if 'stream_id' in meta.trace.packet_header_type.fields: cg.add_line('id = {};'.format(stream.id)) if stream.packet_context_type is not None: _gen_entity('packet.context', stream.packet_context_type, cg) if stream.event_header_type is not None: _gen_entity('event.header', stream.event_header_type, cg) if stream.event_context_type is not None: _gen_entity('event.context', stream.event_context_type, cg) _gen_end_block(cg) def _gen_event_block(meta, stream, ev, cg): _gen_start_block('event', cg) cg.add_line('name = "{}";'.format(ev.name)) cg.add_line('id = {};'.format(ev.id)) if meta.trace.packet_header_type is not None: if 'stream_id' in meta.trace.packet_header_type.fields: cg.add_line('stream_id = {};'.format(stream.id)) cg.append_cc_to_last_line(stream.name.replace('/', '')) if ev.log_level is not None: add_fmt = '' if ev.log_level.name is not None: name = ev.log_level.name.replace('*/', '') add_fmt = ' /* {} */'.format(name) fmt = 'loglevel = {};' + add_fmt cg.add_line(fmt.format(ev.log_level.value)) if ev.context_type is not None: _gen_entity('context', ev.context_type, cg) if ev.payload_type is not None: _gen_entity('fields', ev.payload_type, cg) else: fake_payload = metadata.Struct() fake_payload.min_align = 8 _gen_entity('fields', fake_payload, cg) _gen_end_block(cg) def _gen_streams_events_blocks(meta, cg): for stream in meta.streams.values(): _gen_stream_block(meta, stream, cg) for ev in stream.events.values(): _gen_event_block(meta, stream, ev, cg) def from_metadata(meta): cg = codegen.CodeGenerator('\t') # version/magic cg.add_line('/* CTF 1.8 */') cg.add_empty_line() cg.add_line('''/* * The MIT License (MIT) * * Copyright (c) 2015-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. * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *''') v = barectf.__version__ line = ' * The following TSDL code was generated by barectf v{}'.format(v) cg.add_line(line) now = datetime.datetime.now() line = ' * on {}.'.format(now) cg.add_line(line) cg.add_line(' *') cg.add_line(' * For more details, see .') cg.add_line(' */') cg.add_empty_line() # trace block _gen_trace_block(meta, cg) # environment _gen_env_block(meta, cg) # clocks _gen_clock_blocks(meta, cg) # streams and contained events _gen_streams_events_blocks(meta, cg) return cg.code barectf-2.3.0/doc/000077500000000000000000000000001317147435100136755ustar00rootroot00000000000000barectf-2.3.0/doc/examples/000077500000000000000000000000001317147435100155135ustar00rootroot00000000000000barectf-2.3.0/doc/examples/.gitignore000066400000000000000000000000601317147435100174770ustar00rootroot00000000000000barectf.c barectf.h barectf-bitfield.h metadata barectf-2.3.0/doc/examples/barectf-tracepoint/000077500000000000000000000000001317147435100212675ustar00rootroot00000000000000barectf-2.3.0/doc/examples/barectf-tracepoint/.gitignore000066400000000000000000000002111317147435100232510ustar00rootroot00000000000000barectf-tracepoint-barectf-linux-fs barectf-tracepoint-barectf-qemu-arm-uart barectf-tracepoint-lttng-ust ctf-linux-fs ctf-qemu-arm-uart barectf-2.3.0/doc/examples/barectf-tracepoint/Makefile000066400000000000000000000024471317147435100227360ustar00rootroot00000000000000# The MIT License (MIT) # # Copyright (c) 2014-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. .PHONY: all clean all: make -f Makefile.barectf-linux-fs make -f Makefile.lttng-ust clean: make -f Makefile.barectf-linux-fs clean make -f Makefile.lttng-ust clean barectf-2.3.0/doc/examples/barectf-tracepoint/Makefile.barectf-linux-fs000066400000000000000000000040371317147435100261030ustar00rootroot00000000000000# 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. BARECTF ?= barectf RM = rm -rf MKDIR = mkdir -p PLATFORM_DIR = ../../../platforms/linux-fs EXTRA_DIR = ../../../extra CFLAGS = -O2 -Wall -pedantic -I$(PLATFORM_DIR) -I$(EXTRA_DIR) -I. VERSION = linux-fs TARGET = barectf-tracepoint-barectf-$(VERSION) OBJS = $(TARGET).o barectf-$(VERSION).o barectf-platform-linux-fs.o TRACEDIR = ctf-$(VERSION) .PHONY: all clean all: $(TARGET) $(TRACEDIR): $(MKDIR) $@ $(TARGET): $(OBJS) $(CC) -o $@ $^ $(TRACEDIR)/metadata barectf-bitfield.h barectf.h barectf.c: config.yaml $(TRACEDIR) $(BARECTF) $< -m $(TRACEDIR) barectf-$(VERSION).o: barectf.c $(CC) -o $@ $(CFLAGS) -c $< barectf-platform-linux-fs.o: $(PLATFORM_DIR)/barectf-platform-linux-fs.c $(CC) $(CFLAGS) -c $< $(TARGET).o: barectf-tracepoint.c barectf-tracepoint-$(VERSION).h barectf.h barectf-bitfield.h $(CC) -o $@ $(CFLAGS) -c $< clean: $(RM) $(TARGET) $(OBJS) $(TRACEDIR) $(RM) barectf.h barectf-bitfield.h barectf.c barectf-2.3.0/doc/examples/barectf-tracepoint/Makefile.barectf-qemu-arm-uart000066400000000000000000000043201317147435100270260ustar00rootroot00000000000000# 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. BARECTF ?= barectf ARCH = arm-none-eabi RM = rm -rf MKDIR = mkdir -p CC = $(ARCH)-gcc VERSION = qemu-arm-uart CPU=arm926ej-s EXTRA_DIR = ../../../extra CFLAGS = -DWITH_QEMU_ARM_UART=1 -ffunction-sections -mcpu=$(CPU) -O2 -Wall -pedantic -I$(EXTRA_DIR) -I. LDFLAGS= -T barectf-platform-$(VERSION).ld -lc -lnosys TARGET = barectf-tracepoint-barectf-$(VERSION) OBJS = $(TARGET).o barectf-$(VERSION).o barectf-platform-$(VERSION).o TRACEDIR = ctf-$(VERSION) .PHONY: all clean sim all: $(TARGET) $(TRACEDIR): $(MKDIR) $@ $(TARGET): $(OBJS) $(CC) -o $@ $^ $(LDFLAGS) $(TRACEDIR)/metadata barectf-bitfield.h barectf.h barectf.c: config.yaml $(TRACEDIR) $(BARECTF) $< -m $(TRACEDIR) barectf-$(VERSION).o: barectf.c $(CC) -o $@ $(CFLAGS) -c $< barectf-platform-$(VERSION).o: barectf-platform-$(VERSION).c $(CC) $(CFLAGS) -c $< $(TARGET).o: barectf-tracepoint.c barectf-tracepoint-$(VERSION).h barectf.h barectf-bitfield.h $(CC) -o $@ $(CFLAGS) -c $< clean: $(RM) $(TARGET) $(OBJS) $(TRACEDIR) $(RM) barectf.h barectf-bitfield.h barectf.c sim: $(TARGET) ./barectf-tracepoint-barectf-qemu-arm-uart.sh barectf-2.3.0/doc/examples/barectf-tracepoint/Makefile.lttng-ust000066400000000000000000000030441317147435100246700ustar00rootroot00000000000000# 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. RM = rm -rf CFLAGS := -O2 -Wall -pedantic $(CFLAGS) LDFLAGS := -llttng-ust -ldl $(LDFLAGS) TARGET = barectf-tracepoint-lttng-ust OBJS = $(TARGET).o tp.o .PHONY: all clean all: $(TARGET) $(TARGET): $(OBJS) $(CC) -o $@ $^ $(LDFLAGS) tp.o: tp.c $(CC) -c $(CFLAGS) -I. $< $(TARGET).o: barectf-tracepoint.c barectf-tracepoint-lttng-ust.h tp.h $(CC) -c -o $@ $(CFLAGS) -DWITH_LTTNG_UST=1 $< clean: $(RM) $(TARGET) $(OBJS) barectf-2.3.0/doc/examples/barectf-tracepoint/README.md000066400000000000000000000102471317147435100225520ustar00rootroot00000000000000# Example using `barectf-tracepoint.h` This example is based on the [linux-fs-simple example](../linux-fs-simple) example, but it uses the `tracepoint()` macro defined in [`barectf-tracepoint.h`](../../../extra/barectf-tracepoint.h) instead of calling the generated tracing functions directly. This example also shows the compatibility with [LTTng-UST](http://lttng.org/) that this `barectf-tracepoint.h` allows. This example also includes a QEMU ARM target to simulate barectf used by a true bare-metal application. All the targets of this example use the same application source: [`barectf-tracepoint.c`](barectf-tracepoint.c). ## barectf tracing ### linux-fs platform #### Building Do: make -f Makefile.barectf-linux-fs #### Running Run this example: ./barectf-tracepoint-barectf-linux-fs The complete CTF trace is written to the `ctf-linux-fs` directory. You may run the example with any arguments; they will be recorded, as string fields in the events of the binary stream, e.g.: ./barectf-tracepoint-barectf-linux-fs this argument and this one will be recorded ### QEMU ARM platform #### Building To build this example, you need an ARM cross-compiler toolchain (`gcc-arm-none-eabi`, `binutils-arm-none-eabi`, and `libnewlib-arm-none-eabi` Ubuntu packages), then do: make -f Makefile.barectf-qemu-arm-uart #### Running To run this example, you need `qemu-system-arm` (`qemu-system-arm` Ubuntu package). Run this example: make -f Makefile.barectf-qemu-arm-uart sim The complete CTF trace is written to the `ctf-qemu-arm-uart` directory. #### What happens when running? When you run this example, here's what happens: 1. The `barectf-tracepoint-barectf-qemu-arm-uart.sh` Bash script is executed. 2. This Bash script executes `qemu-system-arm` with the appropriate options to simulate the bare-metal application on an ARM system. The simulated board is a Versatile platform baseboard from ARM. The simulated CPU is an ARM926EJ-S. This is a 2001 ARM9 core implementing the ARMv5TE architecture. QEMU is set to execute the `barectf-tracepoint-barectf-qemu-arm-uart` ELF file (previously built), and to connect the board's first UART with QEMU's standard input/output streams, and the board's second UART to the `ctf-qemu-arm-uart/stream` file (output only). The Bash script reads each line printed by QEMU, and kills the QEMU process when it reads the ending line written by the bare-metal application. 3. QEMU starts. Eventually, the bare-metal application's `main()` function is called. 4. `main()` calls `init_tracing()`, which for this example, calls `barectf_platform_qemu_arm_uart_init()`. This is a custom barectf platform created specifically for this example. The platform initializes a barectf context to get its clock source from a timer on the simulated board, and to flush its packets by writing the bytes to the second UART (which is connected to the `ctf-qemu-arm-uart/stream` file by QEMU). The platform uses a global buffer of 4 kiB to hold the current packet. 5. `main()` calls `trace_stuff()` which contains the `tracepoint()` macro invocations. Events are recorded to the current packet by the barectf machinery. When this packet is full, it is flushed by the platform to the second UART. 6. `main()` calls `fini_tracing()`, which calls `barectf_platform_qemu_arm_uart_fini()`, which prints the ending line that `barectf-tracepoint-barectf-qemu-arm-uart.sh` is waiting for to kill QEMU. ## LTTng-UST tracing ### Building Make sure [LTTng-UST](http://lttng.org/) is installed. Do: make -f Makefile.lttng-ust ### Running Create an LTTng tracing session: lttng create my-session Enable the events of this example: lttng enable-event --userspace 'barectf_tp:*' Start tracing: lttng start Run this example: ./barectf-tracepoint-lttng-ust You may run the example with any arguments; they will be recorded, as string fields in the events of the binary stream, e.g.: ./barectf-tracepoint-lttng-ust this argument and this one will be recorded Stop tracing and inspect the recorded events: lttng stop lttng view barectf-2.3.0/doc/examples/barectf-tracepoint/barectf-platform-qemu-arm-uart.c000066400000000000000000000065461317147435100273710ustar00rootroot00000000000000/* * 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 #include "barectf-platform-qemu-arm-uart.h" #define BUF_SIZE 4096 #define TIMER_CTRL_32BIT (1 << 1) #define TIMER_CTRL_ENABLE (1 << 7) volatile uint32_t * const uart0 = (uint32_t *) 0x101f1000; volatile uint32_t * const uart1 = (uint32_t *) 0x101f2000; volatile uint32_t * const timer0_ctrl = (uint32_t *) 0x101e2008; volatile uint32_t * const timer0_value = (uint32_t *) 0x101e2004; static struct barectf_default_ctx barectf_ctx; static uint8_t buf[BUF_SIZE]; static uint64_t get_clock(void* data) { return (uint64_t) -*timer0_value; } static void flush_packet(void) { size_t i; /* flush packet to UART 1 */ for (i = 0; i < BUF_SIZE; ++i) { *uart1 = (uint32_t) buf[i]; } } static int is_backend_full(void *data) { return 0; } static void open_packet(void *data) { barectf_default_open_packet(&barectf_ctx); } static void close_packet(void *data) { /* close packet now */ barectf_default_close_packet(&barectf_ctx); /* flush current packet */ flush_packet(); } void barectf_platform_qemu_arm_uart_init(void) { struct barectf_platform_callbacks cbs = { .default_clock_get_value = get_clock, .is_backend_full = is_backend_full, .open_packet = open_packet, .close_packet = close_packet, }; /* enable/start timer (clock source) */ *timer0_ctrl |= TIMER_CTRL_32BIT | TIMER_CTRL_ENABLE; /* initialize barectf context */ barectf_init(&barectf_ctx, buf, BUF_SIZE, cbs, NULL); /* open first packet */ open_packet(NULL); /* indicate that tracing is starting */ puts("tracing: starting"); } void barectf_platform_qemu_arm_uart_fini(void) { /* close last packet if it contains at least one event */ if (barectf_packet_is_open(&barectf_ctx) && !barectf_packet_is_empty(&barectf_ctx)) { close_packet(NULL); } /* indicate that tracing is done */ puts("tracing: done"); } struct barectf_default_ctx *barectf_platform_qemu_arm_uart_get_barectf_ctx() { return &barectf_ctx; } #define STDOUT 1 #define STDERR 2 /* custom write "syscall" for newlib's stdio: write to UART 0 */ int _write(int file, char *ptr, int len) { if (file == STDOUT || file == STDERR) { int i; for (i = 0; i < len; i++) { *uart0 = (uint32_t) ptr[i]; } } return 0; } barectf-2.3.0/doc/examples/barectf-tracepoint/barectf-platform-qemu-arm-uart.h000066400000000000000000000027331317147435100273700ustar00rootroot00000000000000#ifndef _BARECTF_PLATFORM_QEMU_ARM_UART #define _BARECTF_PLATFORM_QEMU_ARM_UART /* * 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 void barectf_platform_qemu_arm_uart_init(void); void barectf_platform_qemu_arm_uart_fini(void); struct barectf_default_ctx *barectf_platform_qemu_arm_uart_get_barectf_ctx(void); #endif /* _BARECTF_PLATFORM_QEMU_ARM_UART */ barectf-2.3.0/doc/examples/barectf-tracepoint/barectf-platform-qemu-arm-uart.ld000066400000000000000000000033631317147435100275400ustar00rootroot00000000000000/* * 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. */ MEMORY { SDRAM (XRW) : ORIGIN = 0x00000000, LENGTH = 0x08000000 } /* heap size */ heap_size = 0x10000; /* define stack base (grows downwards), used in newlib's crt0.S */ __stack = ORIGIN(SDRAM) + LENGTH(SDRAM); /* libc's entry point */ ENTRY(_mainCRTStartup); SECTIONS { /* QEMU starts executing at 0x10000 */ . = 0x10000; .text : { *(.text) *(.text.*) } > SDRAM .data : { *(.data) *(.data.*) } > SDRAM .bss : { __bss_start__ = .; *(.bss) *(.bss.*) *(COMMON) __bss_end__ = .; } > SDRAM /* "end" symbol needed by newlib's _sbrk */ end = .; } barectf-2.3.0/doc/examples/barectf-tracepoint/barectf-tracepoint-barectf-qemu-arm-uart.sh000077500000000000000000000026751317147435100315130ustar00rootroot00000000000000#!/usr/bin/env bash # 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. qemu-system-arm -M versatilepb -m 128M -nographic -monitor none \ -kernel barectf-tracepoint-barectf-qemu-arm-uart \ -serial stdio -serial file:ctf-qemu-arm-uart/stream | { while read line; do echo "$line" if [ x"$line" = x"tracing: done" ]; then pkill -nf file:ctf-qemu-arm-uart fi done } barectf-2.3.0/doc/examples/barectf-tracepoint/barectf-tracepoint-linux-fs.h000066400000000000000000000046301317147435100267620ustar00rootroot00000000000000#ifndef _BARECTF_TRACEPOINT_LINUX_FS #define _BARECTF_TRACEPOINT_LINUX_FS /* * 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 generated barectf header file: this contains the prefix and * default stream name to be used by the tracepoint() macro. */ #include "barectf.h" /* define how the context is to be found by tracepoint() calls */ #define BARECTF_TRACEPOINT_CTX (global_barectf_ctx) /* then include this: */ #include /* global barectf context (default stream) */ static struct barectf_default_ctx *global_barectf_ctx; /* global barectf platform context */ static struct barectf_platform_linux_fs_ctx *global_barectf_platform_ctx; /* init function for this version */ static void init_tracing(void) { /* initialize platform */ global_barectf_platform_ctx = barectf_platform_linux_fs_init(512, "ctf-linux-fs", 1, 2, 7); if (!global_barectf_platform_ctx) { fprintf(stderr, "Error: could not initialize platform\n"); exit(1); } global_barectf_ctx = barectf_platform_linux_fs_get_barectf_ctx( global_barectf_platform_ctx); } /* finalization function for this version */ static void fini_tracing(void) { /* finalize platform */ barectf_platform_linux_fs_fini(global_barectf_platform_ctx); } #endif /* _BARECTF_TRACEPOINT_LINUX_FS */ barectf-2.3.0/doc/examples/barectf-tracepoint/barectf-tracepoint-lttng-ust.h000066400000000000000000000026651317147435100271640ustar00rootroot00000000000000#ifndef _BARECTF_TRACEPOINT_LTTNG_UST #define _BARECTF_TRACEPOINT_LTTNG_UST /* * 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. */ /* tracepoint provider header */ #include "tp.h" /* empty init_tracing() and fini_tracing() function for this version */ #define init_tracing() #define fini_tracing() #endif /* _BARECTF_TRACEPOINT_LTTNG_UST */ barectf-2.3.0/doc/examples/barectf-tracepoint/barectf-tracepoint-qemu-arm-uart.h000066400000000000000000000041431317147435100277110ustar00rootroot00000000000000#ifndef _BARECTF_TRACEPOINT_QEMU_ARM_UART #define _BARECTF_TRACEPOINT_QEMU_ARM_UART /* * 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 generated barectf header file: this contains the prefix and * default stream name to be used by the tracepoint() macro. */ #include "barectf.h" /* define how the context is to be found by tracepoint() calls */ #define BARECTF_TRACEPOINT_CTX (global_barectf_ctx) /* then include this: */ #include /* global barectf context (default stream) */ static struct barectf_default_ctx *global_barectf_ctx; /* init function for this version */ static void init_tracing(void) { /* initialize platform */ barectf_platform_qemu_arm_uart_init(); global_barectf_ctx = barectf_platform_qemu_arm_uart_get_barectf_ctx(); } /* finalization function for this version */ static void fini_tracing(void) { /* finalize platform */ barectf_platform_qemu_arm_uart_fini(); } #endif /* _BARECTF_TRACEPOINT_QEMU_ARM_UART */ barectf-2.3.0/doc/examples/barectf-tracepoint/barectf-tracepoint.c000066400000000000000000000047041317147435100252140ustar00rootroot00000000000000/* * 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 #include #if defined(WITH_LTTNG_UST) #include "barectf-tracepoint-lttng-ust.h" #elif defined(WITH_QEMU_ARM_UART) #include "barectf-tracepoint-qemu-arm-uart.h" #else #include "barectf-tracepoint-linux-fs.h" #endif enum state_t { NEW, TERMINATED, READY, RUNNING, WAITING, }; static void trace_stuff(int argc, char *argv[]) { int i; const char *str; /* record 40000 events */ for (i = 0; i < 5000; ++i) { str = argv[i % argc]; tracepoint(barectf_tp, simple_uint32, i * 1500); tracepoint(barectf_tp, simple_int16, -i * 2); tracepoint(barectf_tp, simple_float, (float) i / 1.23); tracepoint(barectf_tp, simple_string, str); tracepoint(barectf_tp, simple_enum, RUNNING); tracepoint(barectf_tp, a_few_fields, -1, 301, -3.14159, str, NEW); tracepoint(barectf_tp, bit_packed_integers, 1, -1, 3, -2, 2, 7, 23, -55, 232); tracepoint(barectf_tp, simple_enum, TERMINATED); } } #define NUM_STRINGS 5 static char *strings[] = { "orange", "mandarine", "lemon", "lime", "grapefruit", }; int main(int argc, char *argv[]) { init_tracing(); if (argc <= 1) { /* use static strings if there's nothing interesting in argv */ argc = NUM_STRINGS; argv = strings; } trace_stuff(argc, argv); fini_tracing(); return 0; } barectf-2.3.0/doc/examples/barectf-tracepoint/config.yaml000066400000000000000000000102451317147435100234220ustar00rootroot00000000000000# 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. version: '2.2' options: gen-prefix-def: true gen-default-stream-def: true metadata: $include: - stdint.yaml - stdfloat.yaml - stdmisc.yaml - lttng-ust-log-levels.yaml type-aliases: clock-int: $inherit: uint64 property-mappings: - type: clock name: default property: value state: class: enum value-type: uint8 members: - NEW - TERMINATED - READY - RUNNING - WAITING clocks: default: freq: 1000000000 offset: seconds: 1434072888 $return-ctype: uint64_t trace: $include: trace-basic.yaml byte-order: le streams: default: $default: true packet-context-type: class: struct fields: timestamp_begin: clock-int timestamp_end: clock-int packet_size: uint32 content_size: uint32 events_discarded: uint32 event-header-type: class: struct fields: timestamp: clock-int id: uint16 events: barectf_tp_simple_uint32: log-level: CRIT payload-type: class: struct fields: value: uint32 barectf_tp_simple_int16: payload-type: class: struct fields: value: int16 barectf_tp_simple_float: payload-type: class: struct fields: value: float barectf_tp_simple_string: log-level: WARNING payload-type: class: struct fields: value: class: string barectf_tp_simple_enum: payload-type: class: struct fields: value: state barectf_tp_a_few_fields: payload-type: class: struct fields: int32: int32 uint16: uint16 dbl: double str: class: string state: state barectf_tp_bit_packed_integers: log-level: 513 payload-type: class: struct min-align: 8 fields: uint1: $inherit: uint8 size: 1 align: 1 int1: $inherit: int8 size: 1 align: 1 uint2: $inherit: uint8 size: 2 align: 1 int3: $inherit: int8 size: 3 align: 1 uint4: $inherit: uint8 size: 4 align: 1 int5: $inherit: int8 size: 5 align: 1 uint6: $inherit: uint8 size: 6 align: 1 int7: $inherit: int8 size: 7 align: 1 uint8: $inherit: uint8 align: 1 barectf-2.3.0/doc/examples/barectf-tracepoint/tp.c000066400000000000000000000023401317147435100220550ustar00rootroot00000000000000/* * 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. */ #define TRACEPOINT_CREATE_PROBES #define TRACEPOINT_DEFINE #include "tp.h" barectf-2.3.0/doc/examples/barectf-tracepoint/tp.h000066400000000000000000000066221317147435100220710ustar00rootroot00000000000000#undef TRACEPOINT_PROVIDER #define TRACEPOINT_PROVIDER barectf_tp #undef TRACEPOINT_INCLUDE #define TRACEPOINT_INCLUDE "./tp.h" #if !defined(_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ) #define _TP_H /* * 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 TRACEPOINT_EVENT( barectf_tp, simple_uint32, TP_ARGS( uint32_t, value ), TP_FIELDS( ctf_integer(uint32_t, value, value) ) ) TRACEPOINT_LOGLEVEL(barectf_tp, simple_uint32, TRACE_CRIT) TRACEPOINT_EVENT( barectf_tp, simple_int16, TP_ARGS( int16_t, value ), TP_FIELDS( ctf_integer(int16_t, value, value) ) ) TRACEPOINT_EVENT( barectf_tp, simple_float, TP_ARGS( float, value ), TP_FIELDS( ctf_float(float, value, value) ) ) TRACEPOINT_EVENT( barectf_tp, simple_string, TP_ARGS( const char *, value ), TP_FIELDS( ctf_string(value, value) ) ) TRACEPOINT_LOGLEVEL(barectf_tp, simple_string, TRACE_WARNING) TRACEPOINT_ENUM( barectf_tp, state, TP_ENUM_VALUES( ctf_enum_value("NEW", 0) ctf_enum_value("TERMINATED", 1) ctf_enum_value("READY", 2) ctf_enum_value("RUNNING", 3) ctf_enum_value("WAITING", 4) ) ) TRACEPOINT_EVENT( barectf_tp, simple_enum, TP_ARGS( int, value ), TP_FIELDS( ctf_enum(barectf_tp, state, int, value, value) ) ) TRACEPOINT_EVENT( barectf_tp, a_few_fields, TP_ARGS( int32_t, int32, uint16_t, int16, double, dbl, const char *, str, int, state ), TP_FIELDS( ctf_integer(int32_t, int32, int32) ctf_integer(int16_t, int16, int16) ctf_float(double, dbl, dbl) ctf_string(str, str) ctf_enum(barectf_tp, state, int, state, state) ) ) TRACEPOINT_EVENT( barectf_tp, bit_packed_integers, TP_ARGS( uint8_t, uint1, int8_t, int1, uint8_t, uint2, int8_t, int3, uint8_t, uint4, int8_t, int5, uint8_t, uint6, int8_t, int7, uint8_t, uint8 ), TP_FIELDS( ctf_integer(uint8_t, uint1, uint1) ctf_integer(int8_t, int1, int1) ctf_integer(uint8_t, uint2, uint2) ctf_integer(int8_t, int3, int3) ctf_integer(uint8_t, uint4, uint4) ctf_integer(int8_t, int5, int5) ctf_integer(uint8_t, uint6, uint6) ctf_integer(int8_t, int7, int7) ctf_integer(uint8_t, uint8, uint8) ) ) TRACEPOINT_LOGLEVEL(barectf_tp, bit_packed_integers, 513) #endif /* _TP_H */ #include barectf-2.3.0/doc/examples/linux-fs-simple/000077500000000000000000000000001317147435100205475ustar00rootroot00000000000000barectf-2.3.0/doc/examples/linux-fs-simple/.gitignore000066400000000000000000000000241317147435100225330ustar00rootroot00000000000000ctf linux-fs-simple barectf-2.3.0/doc/examples/linux-fs-simple/Makefile000066400000000000000000000035141317147435100222120ustar00rootroot00000000000000# 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. BARECTF ?= barectf RM = rm -rf MKDIR = mkdir PLATFORM_DIR = ../../../platforms/linux-fs CFLAGS = -O2 -Wall -pedantic -I$(PLATFORM_DIR) -I. TARGET = linux-fs-simple OBJS = $(TARGET).o barectf.o barectf-platform-linux-fs.o .PHONY: all view all: $(TARGET) ctf: $(MKDIR) ctf $(TARGET): $(OBJS) $(CC) -o $@ $^ ctf/metadata barectf-bitfield.h barectf.h barectf.c: config.yaml ctf $(BARECTF) $< -m ctf barectf.o: barectf.c $(CC) $(CFLAGS) -ansi -c $< barectf-platform-linux-fs.o: $(PLATFORM_DIR)/barectf-platform-linux-fs.c barectf.h $(CC) $(CFLAGS) -c $< $(TARGET).o: $(TARGET).c barectf.h barectf-bitfield.h $(CC) $(CFLAGS) -c $< clean: $(RM) $(TARGET) $(OBJS) ctf $(RM) barectf.h barectf-bitfield.h barectf.c barectf-2.3.0/doc/examples/linux-fs-simple/README.md000066400000000000000000000010411317147435100220220ustar00rootroot00000000000000# linux-fs-simple example This very simple example shows how to use the barectf [linux-fs platform](../../../platforms/linux-fs). ## Building Make sure you have the latest version of barectf installed. Build this example: make ## Running Run this example: ./linux-fs-simple The complete CTF trace is written to the `ctf` directory. You may run the example with any arguments; they will be recorded, as string fields in the events of the binary stream, e.g.: ./linux-fs-simple this argument and this one will be recorded barectf-2.3.0/doc/examples/linux-fs-simple/config.yaml000066400000000000000000000104141317147435100227000ustar00rootroot00000000000000# 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. version: '2.2' options: gen-prefix-def: true gen-default-stream-def: true metadata: $include: - stdint.yaml - stdfloat.yaml - stdmisc.yaml - lttng-ust-log-levels.yaml type-aliases: clock-int: $inherit: uint64 property-mappings: - type: clock name: default property: value state: class: enum value-type: uint8 members: - NEW - TERMINATED - READY - RUNNING - WAITING clocks: default: freq: 1000000000 offset: seconds: 1434072888 $return-ctype: uint64_t trace: $include: trace-basic.yaml byte-order: le streams: default: $default: true packet-context-type: class: struct fields: timestamp_begin: clock-int timestamp_end: clock-int packet_size: uint32 content_size: uint32 events_discarded: uint32 event-header-type: class: struct fields: timestamp: clock-int id: uint16 events: simple_uint32: log-level: CRIT payload-type: class: struct fields: value: uint32 simple_int16: payload-type: class: struct fields: value: int16 simple_float: payload-type: class: struct fields: value: float simple_string: log-level: WARNING payload-type: class: struct fields: value: class: string simple_enum: payload-type: class: struct fields: value: state context_no_payload: context-type: class: struct fields: a: uint32 b: string no_context_no_payload: {} a_few_fields: payload-type: class: struct fields: int32: int32 uint16: uint16 dbl: double str: class: string state: state bit_packed_integers: log-level: 513 payload-type: class: struct min-align: 8 fields: uint1: $inherit: uint8 size: 1 align: 1 int1: $inherit: int8 size: 1 align: 1 uint2: $inherit: uint8 size: 2 align: 1 int3: $inherit: int8 size: 3 align: 1 uint4: $inherit: uint8 size: 4 align: 1 int5: $inherit: int8 size: 5 align: 1 uint6: $inherit: uint8 size: 6 align: 1 int7: $inherit: int8 size: 7 align: 1 uint8: $inherit: uint8 align: 1 barectf-2.3.0/doc/examples/linux-fs-simple/linux-fs-simple.c000066400000000000000000000052041317147435100237500ustar00rootroot00000000000000/* * 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 #include #include #include enum state_t { NEW, TERMINATED, READY, RUNNING, WAITING, }; static void trace_stuff(struct barectf_default_ctx *ctx, int argc, char *argv[]) { int i; const char *str; /* record 40000 events */ for (i = 0; i < 5000; ++i) { barectf_trace_simple_uint32(ctx, i * 1500); barectf_trace_simple_int16(ctx, -i * 2); barectf_trace_simple_float(ctx, (float) i / 1.23); if (argc > 0) { str = argv[i % argc]; } else { str = "hello there!"; } barectf_trace_simple_string(ctx, str); barectf_trace_context_no_payload(ctx, i, "ctx"); barectf_trace_simple_enum(ctx, RUNNING); barectf_trace_a_few_fields(ctx, -1, 301, -3.14159, str, NEW); barectf_trace_bit_packed_integers(ctx, 1, -1, 3, -2, 2, 7, 23, -55, 232); barectf_trace_no_context_no_payload(ctx); barectf_trace_simple_enum(ctx, TERMINATED); } } int main(int argc, char *argv[]) { struct barectf_platform_linux_fs_ctx *platform_ctx; /* initialize platform */ platform_ctx = barectf_platform_linux_fs_init(512, "ctf", 1, 2, 7); if (!platform_ctx) { fprintf(stderr, "Error: could not initialize platform\n"); return 1; } /* trace stuff (will create/write packets as it runs) */ trace_stuff(barectf_platform_linux_fs_get_barectf_ctx(platform_ctx), argc, argv); /* finalize platform */ barectf_platform_linux_fs_fini(platform_ctx); return 0; } barectf-2.3.0/doc/examples/parallella/000077500000000000000000000000001317147435100176245ustar00rootroot00000000000000barectf-2.3.0/doc/examples/parallella/Makefile000066400000000000000000000042001317147435100212600ustar00rootroot00000000000000# The MIT License (MIT) # # Copyright (c) 2015 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. CROSS_COMPILE ?= e- BARECTF ?= barectf RM = rm -rf MKDIR = mkdir CC=$(CROSS_COMPILE)gcc LD=$(CC) OBJCOPY=$(CROSS_COMPILE)objcopy ESDK=$(EPIPHANY_HOME) ELDF=$(ESDK)/bsps/current/fast.ldf PLATFORM_DIR = ../../../platforms/parallella CFLAGS = -O2 -Wall -pedantic -I$(PLATFORM_DIR) -I. LDFLAGS = -T $(ELDF) -le-lib TARGET = parallella OBJS = $(TARGET).o barectf.o barectf-platform-parallella.o .PHONY: all view clean all: $(TARGET).srec ctf: $(MKDIR) ctf $(TARGET): $(OBJS) $(LD) -o $@ $^ $(LDFLAGS) $(TARGET).srec: $(TARGET) $(OBJCOPY) --srec-forceS3 --output-target srec $< $@ ctf/metadata barectf-bitfield.h barectf.h barectf.c: config.yaml ctf barectf $< -m ctf barectf.o: barectf.c barectf.h barectf-bitfield.h $(CC) $(CFLAGS) -ansi -c $< barectf-platform-parallella.o: $(PLATFORM_DIR)/barectf-platform-parallella.c $(CC) $(CFLAGS) -c $< $(TARGET).o: $(TARGET).c barectf.h barectf-bitfield.h $(CC) $(CFLAGS) -c $< clean: $(RM) $(TARGET) $(TARGET).srec $(OBJS) ctf $(RM) barectf.h barectf-bitfield.h barectf.c barectf-2.3.0/doc/examples/parallella/README.md000066400000000000000000000013211317147435100211000ustar00rootroot00000000000000# Parallella example This example shows how to use the barectf [Parallella platform](../../../platforms/parallella). ## Building Make sure you have the latest version of barectf installed. Build this example: make ## Running Make sure the consumer application is running first (see the Parallella platform's [`README.md`](../../../platforms/parallella/README.md) file): e-reset ./consumer /path/to/the/ctf/directory/here Load and start this example on all 16 cores: e-loader -s parallella.srec 0 0 4 4 When you've had enough, kill the consumer with `SIGINT` (Ctrl+C) and reset the platform with `e-reset` to stop the Epiphany cores. The complete CTF trace is written to the `ctf` directory. barectf-2.3.0/doc/examples/parallella/config.yaml000066400000000000000000000060761317147435100217660ustar00rootroot00000000000000# The MIT License (MIT) # # Copyright (c) 2015-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. version: '2.1' metadata: $include: - stdint.yaml - stdfloat.yaml - stdmisc.yaml - lttng-ust-log-levels.yaml type-aliases: uint6: $inherit: bit-packed-uint8 size: 6 clock_int: $inherit: uint64 property-mappings: - type: clock name: default property: value state: class: enum value-type: uint8 members: - NEW - TERMINATED - READY - RUNNING - WAITING clocks: default: freq: 1000000000 offset: seconds: 1434580186 $return-ctype: uint64_t trace: $include: trace-basic.yaml byte-order: le streams: default: packet-context-type: class: struct fields: timestamp_begin: clock_int timestamp_end: clock_int packet_size: uint32 content_size: uint32 events_discarded: uint32 row: uint6 col: uint6 event-header-type: class: struct fields: timestamp: clock_int id: uint16 events: bit_packed_integers: payload-type: class: struct min-align: 8 fields: uint1: $inherit: uint8 size: 1 align: 1 int1: $inherit: int8 size: 1 align: 1 uint2: $inherit: uint8 size: 2 align: 1 int3: $inherit: int8 size: 3 align: 1 uint4: $inherit: uint8 size: 4 align: 1 int5: $inherit: int8 size: 5 align: 1 string_and_float: payload-type: class: struct fields: the_string: string the_float: float barectf-2.3.0/doc/examples/parallella/parallella.c000066400000000000000000000054641317147435100221120ustar00rootroot00000000000000/* * The MIT License (MIT) * * Copyright (c) 2015 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 "barectf.h" #include "barectf-platform-parallella.h" #define WAND_BIT (1 << 3) static void __attribute__((interrupt)) wand_trace_isr(int signum) { (void) signum; } static void sync(void) { uint32_t irq_state; /* enable WAND interrupt */ e_irq_global_mask(E_FALSE); e_irq_attach(WAND_BIT, wand_trace_isr); e_irq_mask(WAND_BIT, E_FALSE); /* WAND + IDLE */ __asm__ __volatile__("wand"); __asm__ __volatile__("idle"); /* acknowledge interrupt */ irq_state = e_reg_read(E_REG_STATUS); irq_state &= ~WAND_BIT; e_reg_write(E_REG_STATUS, irq_state); } int main(void) { struct barectf_default_ctx *barectf_ctx; static const char *strings[] = { "calories", "fat", "carbohydrate", "protein", }; uint8_t at = 0; /* initialize tracing platform */ if (tracing_init()) { /* init. error: do not trace */ return 1; } barectf_ctx = tracing_get_barectf_ctx(); /* synchronize all cores */ sync(); /* reset tracing clock value */ tracing_reset_clock(); /* trace */ for (;;) { int8_t b = (int8_t) at; size_t wait_count; barectf_default_trace_bit_packed_integers(barectf_ctx, at, -b, at * 2, -b * 2, at * 3, -b * 3); for (wait_count = 0; wait_count < 1000; ++wait_count) { __asm__ __volatile__("nop"); } barectf_default_trace_string_and_float(barectf_ctx, strings[at & 3], 0.1234 * (float) at); at++; #ifdef LOW_THROUGHPUT for (wait_count = 0; wait_count < 25000000; ++wait_count) { __asm__ __volatile__("nop"); } #endif /* LOW_THROUGHPUT */ } /* never executed here, but this is where this would normally go */ tracing_fini(); return 0; } barectf-2.3.0/doc/man/000077500000000000000000000000001317147435100144505ustar00rootroot00000000000000barectf-2.3.0/doc/man/.gitignore000066400000000000000000000000161317147435100164350ustar00rootroot00000000000000barectf.1.xml barectf-2.3.0/doc/man/Makefile000066400000000000000000000035051317147435100161130ustar00rootroot00000000000000# 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. # source SRC = barectf # config ASCIIDOC_CONF = asciidoc.conf XSL_FILES = \ manpage.xsl \ manpage-callouts.xsl \ manpage-bold-literal.xsl \ manpage-links.xsl XSL_SRC_FILES = $(addprefix xsl/,$(XSL_FILES)) # tools ASCIIDOC ?= asciidoc XMLTO ?= xmlto ADOC = $(ASCIIDOC) -f $(ASCIIDOC_CONF) -d manpage \ -a barectf_version=$(shell grep '^__version__' ../../barectf/__init__.py | grep -Po '\d+\.\d+\.\d+(?:-\w+)?') ADOC_DOCBOOK = $(ADOC) -b docbook XTO = $(XMLTO) -m $(firstword $(XSL_SRC_FILES)) man # recipes .PHONY: all all: $(SRC).1 $(SRC).1.xml: $(SRC).1.txt $(ASCIIDOC_CONF) $(ADOC_DOCBOOK) -o $@ $< $(SRC).1: $(SRC).1.xml $(XSL_SRC_FILES) $(XTO) $< .PHONY: clean clean: rm -f $(SRC).1 $(SRC).1.xml barectf-2.3.0/doc/man/asciidoc.conf000066400000000000000000000014371317147435100171020ustar00rootroot00000000000000[macros] (?su)[\\]?(?Poption):(?P-?-?[a-zA-Z0-9-]*)= (?su)[\\]?(?Pnloption):(?P-?-?[a-zA-Z0-9-]*)= :not:=not ifdef::doctype-manpage[] ifdef::backend-docbook[] [option-inlinemacro] {opt} [nloption-inlinemacro] {opt} [not-inlinemacro] NOT [header] template::[header-declarations] {mantitle} {manvolnum} barectf {barectf_version} barectf manual {manname} {manpurpose} endif::backend-docbook[] endif::doctype-manpage[] barectf-2.3.0/doc/man/barectf.1000066400000000000000000000133361317147435100161460ustar00rootroot00000000000000'\" t .\" Title: barectf .\" Author: [see the "AUTHORS" section] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 11/15/2016 .\" Manual: barectf manual .\" Source: barectf 2.2.1 .\" Language: English .\" .TH "BARECTF" "1" "11/15/2016" "barectf 2\&.2\&.1" "barectf manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" barectf \- Generate C99 code that can write native CTF packets .SH "SYNOPSIS" .sp .nf \fBbarectf\fR [\fB--prefix\fR=\fIPREFIX\fR] [\fB--dump-config\fR] [\fB--code-dir\fR=\fIPATH\fR] [\fB--headers-dir\fR=\fIPATH\fR] [\fB--metadata-dir\fR=\fIPATH\fR] [\fB-I\fR \fIPATH\fR]\&... [\fB--ignore-include-not-found\fR] \fICONFIG\fR .fi .SH "DESCRIPTION" .sp The \fBbarectf\fR command generates C99 code, that itself can write Common Trace Format packets natively, out of a YAML configuration input file \fICONFIG\fR\&. The full documentation of barectf is available on the project\(cqs website \&. .sp A prefix is used to scope the generated file names, as well as the generated function names, macro names, structure names, and so on\&. By default, this prefix is \fBbarectf_\fR\&. It can be overridden by the configuration file, and ultimately by the \fB--prefix\fR option\&. .sp By default, all generated C and CTF metadata files are written to the current working directory\&. The \fB--code-dir\fR, \fB--headers-dir\fR, and \fB--metadata-dir\fR options are used to control where the generated files should go\&. .sp You can add directories to be searched into for inclusion files, before the default search directories, by using the \fB-I\fR option one or more times\&. .sp By default, if an inclusion file is not found while processing the configuration file \fICONFIG\fR, an error is emitted\&. You can instruct \fBbarectf\fR to continue silently instead by providing the \fB--ignore-include-not-found\fR option\&. .sp To view the effective YAML configuration file used for generating the C and CTF metadata files, after having processed all inclusion files, use the \fB--dump-config\fR option\&. .SH "OPTIONS" .PP \fB-c\fR \fIPATH\fR, \fB--code-dir\fR=\fIPATH\fR .RS 4 Write C source files to directory \fIPATH\fR instead of the current working directory\&. .RE .PP \fB--dump-config\fR .RS 4 Dump the effective YAML configuration file, after all inclusions are processed, to the standard output\&. .RE .PP \fB-H\fR \fIPATH\fR, \fB--headers-dir\fR=\fIPATH\fR .RS 4 Write C header files to directory \fIPATH\fR instead of the current working directory\&. .RE .PP \fB--ignore-include-not-found\fR .RS 4 Do not consider as an error inclusion files that are not found: continue silently\&. .RE .PP \fB-I\fR \fIPATH\fR, \fB--include-dir\fR=\fIPATH\fR .RS 4 Prepend \fIPATH\fR to the list of directories to search into for include files\&. The default list of directories is the current working directory, followed by the directory containing the provided, "standard" inclusion files\&. .RE .PP \fB-m\fR \fIPATH\fR, \fB--metadata-dir\fR=\fIPATH\fR .RS 4 Write CTF metadata file to directory \fIPATH\fR instead of the current working directory\&. .RE .PP \fB-p\fR \fIPREFIX\fR, \fB--prefix\fR=\fIPREFIX\fR .RS 4 Override the configuration file\(cqs prefix with \fIPREFIX\fR\&. This prefix is used in file names, function names, macro names, structure names, and the rest\&. When not specified in the configuration file, the default prefix is \fBbarectf_\fR\&. .RE .PP \fB-h\fR, \fB--help\fR .RS 4 Show command help\&. .RE .PP \fB--version\fR .RS 4 Show the command\(cqs version\&. .RE .SH "EXIT STATUS" .PP \fB0\fR .RS 4 Success .RE .PP \fBNot 0\fR .RS 4 Error .RE .SH "BUGS" .sp Please report any bug or usability issue as a GitHub issue \&. .SH "RESOURCES" .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Project\(cqs website .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Continuous integration .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} Mailing list for support and development: \fBlttng-dev@lists.lttng.org\fR (prefix the subject message with \fB[barectf]\fR) .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} IRC channel : \fB#lttng\fR on \fBirc.oftc.net\fR (\fBeepp\fR is barectf\(cqs author and maintainer) .RE .SH "COPYRIGHT" .sp Copyright (c) 2014\-2016 Philippe Proulx \&. .sp barectf is distributed under the MIT License \&. .SH "AUTHORS" .sp barectf was originally written by and is maintained by, as of this version, Philippe Proulx \&. Other, nice people have since contributed to the project\&. .sp barectf is supported by EfficiOS \&. barectf-2.3.0/doc/man/barectf.1.txt000066400000000000000000000100251317147435100167540ustar00rootroot00000000000000barectf(1) ========== NAME ---- barectf - Generate C99 code that can write native CTF packets SYNOPSIS -------- [verse] *barectf* [option:--prefix='PREFIX'] [option:--dump-config] [option:--code-dir='PATH'] [option:--headers-dir='PATH'] [option:--metadata-dir='PATH'] [option:-I 'PATH']... [option:--ignore-include-not-found] 'CONFIG' DESCRIPTION ----------- The `barectf` command generates C99 code, that itself can write http://diamon.org/ctf[Common Trace Format] packets natively, out of a YAML configuration input file 'CONFIG'. The full documentation of barectf is available on the http://barectf.org[project's website]. A prefix is used to scope the generated file names, as well as the generated function names, macro names, structure names, and so on. By default, this prefix is `barectf_`. It can be overridden by the configuration file, and ultimately by the option:--prefix option. By default, all generated C and CTF metadata files are written to the current working directory. The option:--code-dir, option:--headers-dir, and option:--metadata-dir options are used to control where the generated files should go. You can add directories to be searched into for inclusion files, before the default search directories, by using the option:-I option one or more times. By default, if an inclusion file is not found while processing the configuration file 'CONFIG', an error is emitted. You can instruct `barectf` to continue silently instead by providing the option:--ignore-include-not-found option. To view the effective YAML configuration file used for generating the C and CTF metadata files, after having processed all inclusion files, use the option:--dump-config option. OPTIONS ------- option:-c 'PATH', option:--code-dir='PATH':: Write C source files to directory 'PATH' instead of the current working directory. option:--dump-config:: Dump the effective YAML configuration file, after all inclusions are processed, to the standard output. option:-H 'PATH', option:--headers-dir='PATH':: Write C header files to directory 'PATH' instead of the current working directory. option:--ignore-include-not-found:: Do not consider as an error inclusion files that are not found: continue silently. option:-I 'PATH', option:--include-dir='PATH':: Prepend 'PATH' to the list of directories to search into for include files. The default list of directories is the current working directory, followed by the directory containing the provided, "standard" inclusion files. option:-m 'PATH', option:--metadata-dir='PATH':: Write CTF metadata file to directory 'PATH' instead of the current working directory. option:-p 'PREFIX', option:--prefix='PREFIX':: Override the configuration file's prefix with 'PREFIX'. This prefix is used in file names, function names, macro names, structure names, and the rest. When not specified in the configuration file, the default prefix is `barectf_`. option:-h, option:--help:: Show command help. option:--version:: Show the command's version. EXIT STATUS ----------- *0*:: Success *Not 0*:: Error BUGS ---- Please report any bug or usability issue as a https://github.com/efficios/barectf/issues[GitHub issue]. RESOURCES --------- * http://barectf.org[Project's website] * http://ci.lttng.org/job/barectf[Continuous integration] * http://lists.lttng.org[Mailing list] for support and development: `lttng-dev@lists.lttng.org` (prefix the subject message with `[barectf]`) * irc://irc.oftc.net/lttng[IRC channel]: `#lttng` on `irc.oftc.net` (`eepp` is barectf's author and maintainer) COPYRIGHT --------- Copyright (c) 2014-2016 mailto:pproulx@efficios.com[Philippe Proulx]. barectf is distributed under the https://github.com/efficios/barectf/blob/master/LICENSE[MIT License]. AUTHORS ------- barectf was originally written by and is maintained by, as of this version, mailto:pproulx@efficios.com[Philippe Proulx]. Other, nice people have since contributed to the project. barectf is supported by http://www.efficios.com/[EfficiOS]. barectf-2.3.0/doc/man/xsl/000077500000000000000000000000001317147435100152565ustar00rootroot00000000000000barectf-2.3.0/doc/man/xsl/manpage-bold-literal.xsl000066400000000000000000000003771317147435100217750ustar00rootroot00000000000000 \fB \fR barectf-2.3.0/doc/man/xsl/manpage-callouts.xsl000066400000000000000000000012511317147435100212410ustar00rootroot00000000000000 sp br barectf-2.3.0/doc/man/xsl/manpage-links.xsl000066400000000000000000000006111317147435100205320ustar00rootroot00000000000000 <> \fI\fR barectf-2.3.0/doc/man/xsl/manpage.xsl000066400000000000000000000005161317147435100174200ustar00rootroot00000000000000 0 barectf-2.3.0/extra/000077500000000000000000000000001317147435100142535ustar00rootroot00000000000000barectf-2.3.0/extra/barectf-tracepoint.h000066400000000000000000000050751317147435100202070ustar00rootroot00000000000000#ifndef _BARECTF_TRACEPOINT_H #define _BARECTF_TRACEPOINT_H /* * 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. */ /* get prefix */ #ifdef BARECTF_TRACEPOINT_PREFIX # define _BARECTF_TRACEPOINT_PREFIX BARECTF_TRACEPOINT_PREFIX #else # ifdef _BARECTF_PREFIX # define _BARECTF_TRACEPOINT_PREFIX _BARECTF_PREFIX # else # error You need to define BARECTF_TRACEPOINT_PREFIX in order to use this header. # endif #endif /* get stream name to use */ #ifdef BARECTF_TRACEPOINT_STREAM # define _BARECTF_TRACEPOINT_STREAM BARECTF_TRACEPOINT_STREAM #else # ifdef _BARECTF_DEFAULT_STREAM # define _BARECTF_TRACEPOINT_STREAM _BARECTF_DEFAULT_STREAM # else # error You need to define BARECTF_TRACEPOINT_STREAM in order to use this header. # endif #endif /* get context to use */ #ifndef BARECTF_TRACEPOINT_CTX # error You need to define BARECTF_TRACEPOINT_CTX in order to use this header. #endif /* * Combines 6 token. Inspired by __TP_COMBINE_TOKENS4() in * . See sections 6.10.3 and 6.10.3.1 of * ISO/IEC 9899:1999. */ #define __COMBINE_TOKENS6(_a, _b, _c, _d, _e, _f) \ _a ## _b ## _c ## _d ## _e ## _f #define _COMBINE_TOKENS6(_a, _b, _c, _d, _e, _f) \ __COMBINE_TOKENS6(_a, _b, _c, _d, _e, _f) /* tracepoint() used by the user */ #undef tracepoint #define tracepoint(_prov_name, _tp_name, ...) \ _COMBINE_TOKENS6(_BARECTF_TRACEPOINT_PREFIX, _BARECTF_TRACEPOINT_STREAM, _trace_, _prov_name, _, _tp_name)(BARECTF_TRACEPOINT_CTX, ##__VA_ARGS__) #endif /* _BARECTF_TRACEPOINT_H */ barectf-2.3.0/platforms/000077500000000000000000000000001317147435100151375ustar00rootroot00000000000000barectf-2.3.0/platforms/linux-fs/000077500000000000000000000000001317147435100167045ustar00rootroot00000000000000barectf-2.3.0/platforms/linux-fs/README.md000066400000000000000000000013221317147435100201610ustar00rootroot00000000000000# barectf linux-fs platform This is a very simple barectf platform, written for demonstration purposes, which writes the binary packets to a stream file on the file system. This platform can also simulate a full back-end from time to time, with a configurable ratio. ## Requirements * barectf prefix: `barectf_` * No custom trace packet header fields * A single stream named `default`, with no custom stream packet context fields * One clock named `default` returning `uint64_t`. ## Files * `barectf-platform-linux-fs.h`: include this in your application * `barectf-platform-linux-fs.c`: link your application with this ## Using See [`barectf-platform-linux-fs.h`](barectf-platform-linux-fs.h). barectf-2.3.0/platforms/linux-fs/barectf-platform-linux-fs.c000066400000000000000000000106051317147435100240450ustar00rootroot00000000000000/* * barectf linux-fs platform * * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation * Copyright (c) 2015 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 #include #include "barectf-platform-linux-fs.h" #ifdef __cplusplus # define TO_VOID_PTR(_value) static_cast(_value) # define FROM_VOID_PTR(_type, _value) static_cast<_type *>(_value) #else # define TO_VOID_PTR(_value) ((void *) (_value)) # define FROM_VOID_PTR(_type, _value) ((_type *) (_value)) #endif struct barectf_platform_linux_fs_ctx { struct barectf_default_ctx ctx; FILE *fh; int simulate_full_backend; unsigned int full_backend_rand_lt; unsigned int full_backend_rand_max; }; static uint64_t get_clock(void* data) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return ts.tv_sec * 1000000000ULL + ts.tv_nsec; } static void write_packet(struct barectf_platform_linux_fs_ctx *ctx) { size_t nmemb = fwrite(barectf_packet_buf(&ctx->ctx), barectf_packet_buf_size(&ctx->ctx), 1, ctx->fh); assert(nmemb == 1); } static int is_backend_full(void *data) { struct barectf_platform_linux_fs_ctx *ctx = FROM_VOID_PTR(struct barectf_platform_linux_fs_ctx, data); if (ctx->simulate_full_backend) { if (rand() % ctx->full_backend_rand_max < ctx->full_backend_rand_lt) { return 1; } } return 0; } static void open_packet(void *data) { struct barectf_platform_linux_fs_ctx *ctx = FROM_VOID_PTR(struct barectf_platform_linux_fs_ctx, data); barectf_default_open_packet(&ctx->ctx); } static void close_packet(void *data) { struct barectf_platform_linux_fs_ctx *ctx = FROM_VOID_PTR(struct barectf_platform_linux_fs_ctx, data); /* close packet now */ barectf_default_close_packet(&ctx->ctx); /* write packet to file */ write_packet(ctx); } struct barectf_platform_linux_fs_ctx *barectf_platform_linux_fs_init( unsigned int buf_size, const char *trace_dir, int simulate_full_backend, unsigned int full_backend_rand_lt, unsigned int full_backend_rand_max) { char stream_path[256]; uint8_t *buf; struct barectf_platform_linux_fs_ctx *ctx; struct barectf_platform_callbacks cbs; cbs.default_clock_get_value = get_clock; cbs.is_backend_full = is_backend_full; cbs.open_packet = open_packet; cbs.close_packet = close_packet; ctx = FROM_VOID_PTR(struct barectf_platform_linux_fs_ctx, malloc(sizeof(*ctx))); if (!ctx) { return NULL; } buf = FROM_VOID_PTR(uint8_t, malloc(buf_size)); if (!buf) { free(ctx); return NULL; } memset(buf, 0, buf_size); sprintf(stream_path, "%s/stream", trace_dir); ctx->fh = fopen(stream_path, "wb"); if (!ctx->fh) { free(ctx); free(buf); return NULL; } ctx->simulate_full_backend = simulate_full_backend; ctx->full_backend_rand_lt = full_backend_rand_lt; ctx->full_backend_rand_max = full_backend_rand_max; barectf_init(&ctx->ctx, buf, buf_size, cbs, ctx); open_packet(ctx); return ctx; } void barectf_platform_linux_fs_fini(struct barectf_platform_linux_fs_ctx *ctx) { if (barectf_packet_is_open(&ctx->ctx) && !barectf_packet_is_empty(&ctx->ctx)) { close_packet(ctx); } fclose(ctx->fh); free(barectf_packet_buf(&ctx->ctx)); free(ctx); } struct barectf_default_ctx *barectf_platform_linux_fs_get_barectf_ctx( struct barectf_platform_linux_fs_ctx *ctx) { return &ctx->ctx; } barectf-2.3.0/platforms/linux-fs/barectf-platform-linux-fs.h000066400000000000000000000052321317147435100240520ustar00rootroot00000000000000#ifndef _BARECTF_PLATFORM_LINUX_FS_H #define _BARECTF_PLATFORM_LINUX_FS_H /* * barectf linux-fs platform * * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation * Copyright (c) 2015 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 #ifdef __cplusplus extern "C" { #endif struct barectf_platform_linux_fs_ctx; /** * Initializes the platform. * * @param buf_size Packet size (bytes) * @param trace_dir Trace directory * @param simulate_full_backend 1 to simulate a full back-end sometimes * @param full_backend_rand_lt Back-end will be "full" when a random * value is lower than this parameter * if \p simulate_full_backend is 1 * @param full_backend_rand_max Maximum random value for full back-end * simulation when \p simulate_full_backend * is 1 * @returns Platform context */ struct barectf_platform_linux_fs_ctx *barectf_platform_linux_fs_init( unsigned int buf_size, const char *trace_dir, int simulate_full_backend, unsigned int full_backend_rand_max, unsigned int full_backend_rand_lt); /** * Finalizes the platform. * * @param ctx Platform context */ void barectf_platform_linux_fs_fini(struct barectf_platform_linux_fs_ctx *ctx); /** * Returns the barectf stream-specific context of a given platform context. * * This context is what barectf tracing functions need. * * @param ctx Platform context * @returns barectf stream-specific context */ struct barectf_default_ctx *barectf_platform_linux_fs_get_barectf_ctx( struct barectf_platform_linux_fs_ctx *ctx); #ifdef __cplusplus } #endif #endif /* _BARECTF_PLATFORM_LINUX_FS_H */ barectf-2.3.0/platforms/parallella/000077500000000000000000000000001317147435100172505ustar00rootroot00000000000000barectf-2.3.0/platforms/parallella/README.md000066400000000000000000000051771317147435100205410ustar00rootroot00000000000000# barectf Parallella platform This platform targets the [Parallella](http://parallella.org/) system. This platform implements a ring buffer of packets in shared memory between the Epiphany cores and the ARM host. A consumer application on the host side is responsible for consuming the packets produced by the Epiphany cores and for writing them to the file system. ## Requirements * Possessing a Parallella board * ESDK 2015.1 * barectf prefix: `barectf_` * A single stream named `default` * One clock named `default`, returning `uint64_t`, and having a frequency of 1000000000 Hz The `default` stream must have in its packet context two unsigned integers with a size of at least 6 bits named `row` and `col` which will hold the row and column numbers of the Epiphany core producing this packet. Example of packet context: ```yaml class: struct fields: timestamp_begin: clock_int timestamp_end: clock_int packet_size: uint32 content_size: uint32 events_discarded: uint32 row: uint6 col: uint6 ``` ## Files * `barectf-platform-parallella.h`: include this in your application running on Epiphany cores * `barectf-platform-parallella-config.h`: platform parameters * `barectf-platform-parallella-common.h`: definitions, data structures, and functions shared by the platform and the consumer application * `barectf-platform-parallella.c`: link your application with this * `consumer/consumer.c`: consumer application * `consumer/Makefile`: consumer application Makefile ## Using ### Platform API See [`barectf-platform-parallella.h`](barectf-platform-parallella.h). ### Consumer application #### Building Do: make in the [`consumer`](consumer) directory to build the consumer application. The optional `CROSS_COMPILE` environment variable specifies a cross-compiling toolchain prefix. #### Running Accepted arguments are: * `-v`: enable verbose mode * Unnamed argument: output directory of stream files (default: `ctf`) Example: ./consumer -v /path/to/my-trace The output directory should also contain the `metadata` file produced by the `barectf` command-line tool to form a complete CTF trace. Start the consumer application _before_ starting the Epiphany cores running the platform and your application. To make sure your Epiphany application is not running, use the `e-reset` command. Stop the consumer application by killing it with the `SIGINT` signal (Ctrl+C). Stop the consumer application _before_ resetting the platform with `e-reset` (once the Epiphany application is started). When killed with `SIGINT`, the consumer application will finish writing any incomplete packet, then quit. barectf-2.3.0/platforms/parallella/barectf-platform-parallella-common.h000066400000000000000000000037731317147435100262600ustar00rootroot00000000000000#ifndef _BARECTF_PLATFORM_PARALLELLA_COMMON_H #define _BARECTF_PLATFORM_PARALLELLA_COMMON_H /* * barectf Parallella platform * * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation * Copyright (c) 2015 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 "barectf-platform-parallella-config.h" struct ringbuf { uint32_t consumer_index; uint32_t producer_index; uint8_t packets[RINGBUF_SZ][PACKET_SZ]; #ifdef DEBUG char error_buf[256]; #endif }; #define CORES_COUNT (CORES_ROWS * CORES_COLS) #define SMEM_SZ (sizeof(struct ringbuf) * CORES_COUNT) static inline unsigned int rowcol2index(unsigned int row, unsigned int col) { return row * CORES_COLS + col; } static inline volatile struct ringbuf *get_ringbuf(void *base, unsigned int row, unsigned int col) { unsigned int index = rowcol2index(row, col); volatile struct ringbuf *ringbufs = (struct ringbuf *) base; return &ringbufs[index]; } #endif /* _BARECTF_PLATFORM_PARALLELLA_COMMON_H */ barectf-2.3.0/platforms/parallella/barectf-platform-parallella-config.h000066400000000000000000000037731317147435100262350ustar00rootroot00000000000000#ifndef _BARECTF_PLATFORM_PARALLELLA_CONFIG_H #define _BARECTF_PLATFORM_PARALLELLA_CONFIG_H /* * barectf Parallella platform * * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation * Copyright (c) 2015 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. */ /* barectf Parallella platform parameters */ /* cores/row (4 for the Parallella) */ #define CORES_ROWS 4 /* cores/row (4 for the Parallella) */ #define CORES_COLS 4 /* packet size (must be a power of two) */ #ifndef PACKET_SZ #define PACKET_SZ 256 #endif /* ring buffer size (at least 2) */ #ifndef RINGBUF_SZ #define RINGBUF_SZ 4 #endif /* shared memory region name */ #ifndef SMEM_NAME #define SMEM_NAME "barectf-tracing" #endif /* backend check timeout (cycles) */ #ifndef BACKEND_CHECK_TIMEOUT #define BACKEND_CHECK_TIMEOUT (10000000ULL) #endif /* consumer poll delay (µs) */ #ifndef CONSUMER_POLL_DELAY #define CONSUMER_POLL_DELAY (5000) #endif #endif /* _BARECTF_PLATFORM_PARALLELLA_CONFIG_H */ barectf-2.3.0/platforms/parallella/barectf-platform-parallella.c000066400000000000000000000150331317147435100247550ustar00rootroot00000000000000/* * barectf Parallella platform * * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation * Copyright (c) 2015 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 "barectf-platform-parallella-common.h" #include "barectf-platform-parallella.h" #include "barectf.h" static struct tracing_ctx { struct barectf_default_ctx barectf_ctx; volatile struct ringbuf *ringbuf; uint64_t last_backend_check; uint64_t clock_high; e_memseg_t smem; /* * Use a producer index's shadow in local memory to avoid * reading the old value of the producer index in shared memory * after having incremented it. * * NEVER read or write the producer index or its shadow * directly: always use get_prod_index() and incr_prod_index(). */ uint32_t producer_index_shadow; unsigned int row, col; uint8_t local_packet[PACKET_SZ]; uint8_t initialized; uint8_t backend_wait_period; } g_tracing_ctx; struct barectf_default_ctx *tracing_get_barectf_ctx(void) { return &g_tracing_ctx.barectf_ctx; } static inline void incr_prod_index(struct tracing_ctx *tracing_ctx) { tracing_ctx->producer_index_shadow++; tracing_ctx->ringbuf->producer_index = tracing_ctx->producer_index_shadow; } static inline uint32_t get_prod_index(struct tracing_ctx *tracing_ctx) { return tracing_ctx->producer_index_shadow; } static uint64_t get_clock(void* data) { struct tracing_ctx *tracing_ctx = data; uint64_t low = (uint64_t) ((uint32_t) (E_CTIMER_MAX - e_ctimer_get(E_CTIMER_1))); return tracing_ctx->clock_high | low; } static int is_backend_full(void *data) { struct tracing_ctx *tracing_ctx = data; int check_shared = 0; int full; /* are we in a back-end checking waiting period? */ if (tracing_ctx->backend_wait_period) { /* yes: check if we may check in shared memory now */ uint64_t cur_clock = get_clock(data); if (cur_clock - tracing_ctx->last_backend_check >= BACKEND_CHECK_TIMEOUT) { /* check in shared memory */ check_shared = 1; tracing_ctx->last_backend_check = cur_clock; } } else { /* no: check in shared memory */ check_shared = 1; } if (check_shared) { full = (get_prod_index(tracing_ctx) - tracing_ctx->ringbuf->consumer_index) == RINGBUF_SZ; tracing_ctx->backend_wait_period = full; if (full) { tracing_ctx->last_backend_check = get_clock(data); } } else { /* no shared memory checking: always considered full */ full = 1; } return full; } static void open_packet(void *data) { struct tracing_ctx *tracing_ctx = data; barectf_default_open_packet(&tracing_ctx->barectf_ctx, tracing_ctx->row, tracing_ctx->col); } static void close_packet(void *data) { struct tracing_ctx *tracing_ctx = data; void *dst; unsigned int index; /* close packet now */ barectf_default_close_packet(&tracing_ctx->barectf_ctx); /* * We know for sure that there is space in the back-end (ring * buffer) for this packet, so "upload" it to shared memory now. */ index = get_prod_index(tracing_ctx) & (RINGBUF_SZ - 1); dst = (void *) &(tracing_ctx->ringbuf->packets[index][0]); memcpy(dst, tracing_ctx->local_packet, PACKET_SZ); /* update producer index after copy */ incr_prod_index(tracing_ctx); } static struct barectf_platform_callbacks cbs = { .default_clock_get_value = get_clock, .is_backend_full = is_backend_full, .open_packet = open_packet, .close_packet = close_packet, }; static void __attribute__((interrupt)) timer1_trace_isr() { /* CTIMER1 reaches 0: reset to max value and start */ g_tracing_ctx.clock_high += (1ULL << 32); e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX); e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK); return; } static void init_clock(void) { /* stop and reset CTIMER1 */ e_ctimer_stop(E_CTIMER_1); e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX); g_tracing_ctx.clock_high = 0; /* enable CTIMER1 interrupt */ e_irq_global_mask(E_FALSE); e_irq_attach(E_TIMER1_INT, timer1_trace_isr); e_irq_mask(E_TIMER1_INT, E_FALSE); } static void stop_clock(void) { e_ctimer_stop(E_CTIMER_1); e_irq_mask(E_TIMER1_INT, E_TRUE); } void tracing_reset_clock(void) { e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX); g_tracing_ctx.clock_high = 0; g_tracing_ctx.backend_wait_period = 0; g_tracing_ctx.last_backend_check = 0; e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK); } int tracing_init(void) { e_coreid_t coreid; if (g_tracing_ctx.initialized) { /* already initialized */ return 0; } barectf_init(&g_tracing_ctx.barectf_ctx, g_tracing_ctx.local_packet, PACKET_SZ, cbs, &g_tracing_ctx); /* zero local packet */ memset(g_tracing_ctx.local_packet, 0, PACKET_SZ); /* attach to shared memory */ if (e_shm_attach(&g_tracing_ctx.smem, SMEM_NAME) != E_OK) { return -1; } /* get core's row and column */ coreid = e_get_coreid(); e_coords_from_coreid(coreid, &g_tracing_ctx.row, &g_tracing_ctx.col); /* get core's ring buffer */ g_tracing_ctx.ringbuf = get_ringbuf((void *) g_tracing_ctx.smem.ephy_base, g_tracing_ctx.row, g_tracing_ctx.col); /* initialize tracing clock */ init_clock(); /* start tracing clock */ tracing_reset_clock(); /* open first packet */ open_packet(&g_tracing_ctx); /* acknowledge initialization */ g_tracing_ctx.initialized = 1; return 0; } void tracing_fini(void) { if (!g_tracing_ctx.initialized) { /* not initialized yet */ return; } /* close last packet if open and not empty */ if (barectf_packet_is_open(&g_tracing_ctx.barectf_ctx) && !barectf_packet_is_empty(&g_tracing_ctx.barectf_ctx)) { close_packet(&g_tracing_ctx); } /* stop CTIMER1 */ stop_clock(); } barectf-2.3.0/platforms/parallella/barectf-platform-parallella.h000066400000000000000000000034471317147435100247700ustar00rootroot00000000000000#ifndef _BARECTF_PLATFORM_PARALLELLA_H #define _BARECTF_PLATFORM_PARALLELLA_H /* * barectf Parallella platform * * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation * Copyright (c) 2015 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 "barectf.h" /** * Initializes the platform. */ int tracing_init(void); /** * Returns the barectf context to be used with tracing functions. */ struct barectf_default_ctx *tracing_get_barectf_ctx(void); /** * Resets the tracing clock to an absolute 0. * * This should be used immediately after a synchronization operation * on all executed Epiphany cores. */ void tracing_reset_clock(void); /** * Finalizes the platform. */ void tracing_fini(void); #endif /* _BARECTF_PLATFORM_PARALLELLA_H */ barectf-2.3.0/platforms/parallella/consumer/000077500000000000000000000000001317147435100211035ustar00rootroot00000000000000barectf-2.3.0/platforms/parallella/consumer/Makefile000066400000000000000000000027601317147435100225500ustar00rootroot00000000000000# The MIT License (MIT) # # Copyright (c) 2015 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. RM = rm -f CC = $(CROSS_COMPILE)gcc LD = $(CC) ESDK=$(EPIPHANY_HOME) CFLAGS = -O2 -std=c99 -I.. -I"$(ESDK)/tools/host/include" LDFLAGS = -L"$(ESDK)/tools/host/lib" -le-hal TARGET = consumer OBJS = $(TARGET).o .PHONY: all clean all: $(TARGET) $(TARGET): $(OBJS) $(LD) -o $@ $^ $(LDFLAGS) $(TARGET).o: $(TARGET).c $(CC) $(CFLAGS) -c $< clean: $(RM) $(TARGET) $(OBJS) barectf-2.3.0/platforms/parallella/consumer/consumer.c000066400000000000000000000176741317147435100231210ustar00rootroot00000000000000/* * barectf Parallella platform: consumer application * * Copyright (c) 2015 EfficiOS Inc. and Linux Foundation * Copyright (c) 2015 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. */ #define _BSD_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include "barectf-platform-parallella-common.h" #define mb() __asm__ __volatile__("dmb" : : : "memory") struct ctx { e_mem_t ringbufs_smem; int stream_fds[CORES_COUNT]; const char *trace_dir; int verbose; }; static volatile int quit = 0; static void sig_handler(int signo) { if (signo == SIGINT) { quit = 1; fprintf(stderr, "\nGot SIGINT: quitting\n"); } } static int try_consume_core_packet(struct ctx *ctx, unsigned int row, unsigned int col) { int stream_fd; size_t remaining; uint32_t producer_index; uint32_t consumer_index; uint32_t cons_packet_index; volatile uint8_t *packet_src; unsigned int index = rowcol2index(row, col); volatile struct ringbuf *ringbuf = get_ringbuf(ctx->ringbufs_smem.base, row, col); #ifdef DEBUG if (ringbuf->error_buf[0]) { printf("[%u, %u] %s\n", row, col, ringbuf->error_buf); } #endif /* DEBUG */ consumer_index = ringbuf->consumer_index; producer_index = ringbuf->producer_index; if (producer_index <= consumer_index) { return 0; } /* order producer index reading before packet reading */ mb(); /* index of first full packet within ring buffer */ cons_packet_index = consumer_index & (RINGBUF_SZ - 1); /* full packet data */ packet_src = ringbuf->packets[cons_packet_index]; /* append packet to stream file */ remaining = PACKET_SZ; if (ctx->verbose) { printf("Consuming one packet from ring buffer of core (%u, %u):\n", row, col); printf(" Producer index: %u\n", producer_index); printf(" Consumer index: %u\n", consumer_index); printf(" Consumer packet index: %u\n", cons_packet_index); } stream_fd = ctx->stream_fds[index]; for (;;) { ssize_t write_ret; write_ret = write(stream_fd, (uint8_t *) packet_src + (PACKET_SZ - remaining), remaining); assert(write_ret != 0); if (write_ret > 0) { remaining -= write_ret; } else if (write_ret == -1) { if (errno != EINTR) { /* other error */ fprintf(stderr, "Error: failed to write packet of core (%u, %u):\n", row, col); perror("write"); return -1; } } if (remaining == 0) { break; } } /* order packet reading before consumer index increment */ mb(); /* packet is consumed: update consumer index now */ ringbuf->consumer_index = consumer_index + 1; return 0; } static int consume(struct ctx *ctx) { int row, col, ret; if (ctx->verbose) { printf("Starting consumer\n"); } for (;;) { if (quit) { return 0; } for (row = 0; row < CORES_ROWS; ++row) { for (col = 0; col < CORES_COLS; ++col) { if (quit) { return 0; } ret = try_consume_core_packet(ctx, row, col); if (ret) { return ret; } } } /* busy-wait before the next check */ if (usleep(CONSUMER_POLL_DELAY) == -1) { if (errno != EINTR) { return -1; } } } } static void zero_ringbufs(struct ctx *ctx) { memset(ctx->ringbufs_smem.base, 0, SMEM_SZ); } static void close_stream_fds(struct ctx *ctx) { int i; for (i = 0; i < CORES_COUNT; ++i) { if (ctx->stream_fds[i] >= 0) { int fd = ctx->stream_fds[i]; if (close(fd) == -1) { fprintf(stderr, "Warning: could not close FD %d:\n", fd); perror("close"); } ctx->stream_fds[i] = -1; } } } static int open_stream_fd(struct ctx *ctx, unsigned int row, unsigned int col) { char filename[128]; unsigned int index = rowcol2index(row, col); sprintf(filename, "%s/stream-%u-%u", ctx->trace_dir, row, col); ctx->stream_fds[index] = open(filename, O_CREAT | O_WRONLY, 0644); if (ctx->stream_fds[index] == -1) { fprintf(stderr, "Error: could not open \"%s\" for writing\n", filename); close_stream_fds(ctx); return -1; } return 0; } static int open_stream_fds(struct ctx *ctx) { unsigned int row, col; for (row = 0; row < CORES_ROWS; ++row) { for (col = 0; col < CORES_COLS; ++col) { int ret = open_stream_fd(ctx, row, col); if (ret) { return ret; } } } return 0; } static void init_stream_fds(struct ctx *ctx) { unsigned int row, col; for (row = 0; row < CORES_ROWS; ++row) { for (col = 0; col < CORES_COLS; ++col) { ctx->stream_fds[rowcol2index(row, col)] = -1; } } } static int init(struct ctx *ctx) { int ret = 0; e_set_host_verbosity(H_D0); if (ctx->verbose) { printf("Initializing HAL\n"); } if (e_init(NULL) != E_OK) { fprintf(stderr, "Error: Epiphany HAL initialization failed\n"); ret = -1; goto error; } if (ctx->verbose) { printf("HAL initialized\n"); printf("Allocating %u bytes of shared memory in region \"%s\"\n", SMEM_SZ, SMEM_NAME); } ret = e_shm_alloc(&ctx->ringbufs_smem, SMEM_NAME, SMEM_SZ) != E_OK; if (ret != E_OK) { if (ctx->verbose) { printf("Allocation failed; attaching to shared memory region \"%s\"\n", SMEM_NAME); } ret = e_shm_attach(&ctx->ringbufs_smem, SMEM_NAME); } if (ret != E_OK) { fprintf(stderr, "Error: failed to attach to shared memory: %s\n", strerror(errno)); ret = -1; goto error_finalize; } zero_ringbufs(ctx); if (ctx->verbose) { printf("Creating CTF stream files in \"%s\"\n", ctx->trace_dir); } init_stream_fds(ctx); if (open_stream_fds(ctx)) { fprintf(stderr, "Error: failed to create CTF stream files\n"); ret = -1; goto error_finalize; } return 0; error_finalize: if (ctx->ringbufs_smem.base) { e_shm_release(SMEM_NAME); } e_finalize(); error: return ret; } static void fini(struct ctx *ctx) { if (ctx->verbose) { printf("Closing CTF stream files\n"); } close_stream_fds(ctx); if (ctx->verbose) { printf("Releasing shared memory region \"%s\"\n", SMEM_NAME); } e_shm_release(SMEM_NAME); if (ctx->verbose) { printf("Finalizing HAL\n"); } e_finalize(); } static int parse_arguments(int argc, char *argv[], struct ctx *ctx) { int i; if (argc > 3) { fprintf(stderr, "Error: the only accepted arguments are -v and a trace directory path\n"); return -1; } for (i = 1; i < argc; ++i) { const char *arg = argv[i]; if (strcmp(arg, "-v") == 0) { ctx->verbose = 1; } else { ctx->trace_dir = arg; } } if (!ctx->trace_dir) { ctx->trace_dir = "ctf"; } return 0; } int main(int argc, char *argv[]) { int ret = 0; struct ctx ctx; if (signal(SIGINT, sig_handler) == SIG_ERR) { fprintf(stderr, "Error: failed to register SIGINT handler\n"); ret = 1; goto end; } memset(&ctx, 0, sizeof(ctx)); if (parse_arguments(argc, argv, &ctx)) { ret = 1; goto end; } if (init(&ctx)) { ret = 1; goto end; } if (consume(&ctx)) { ret = 1; goto end_fini; } end_fini: fini(&ctx); end: return ret; } barectf-2.3.0/requirements.txt000066400000000000000000000000211317147435100164050ustar00rootroot00000000000000termcolor pyyaml barectf-2.3.0/setup.py000077500000000000000000000040461317147435100146510ustar00rootroot00000000000000#!/usr/bin/env python3 # # The MIT License (MIT) # # Copyright (c) 2014-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. from setuptools import setup import sys def _check_python3(): # make sure we run Python 3+ here v = sys.version_info if v.major < 3: sys.stderr.write('Sorry, barectf needs Python 3\n') sys.exit(1) _check_python3() import barectf setup(name='barectf', version=barectf.__version__, description='Generator of ANSI C tracers which output CTF', author='Philippe Proulx', author_email='eeppeliteloop@gmail.com', license='MIT', keywords='ctf generator tracing bare-metal bare-machine', url='http://barectf.org', packages=[ 'barectf', ], package_data={ 'barectf': [ 'include/*.yaml', ], }, install_requires=[ 'termcolor', 'pyyaml', ], entry_points={ 'console_scripts': [ 'barectf = barectf.cli:run' ], }) barectf-2.3.0/test-requirements.txt000066400000000000000000000000161317147435100173660ustar00rootroot00000000000000flake8>=2.5.0 barectf-2.3.0/tests/000077500000000000000000000000001317147435100142725ustar00rootroot00000000000000barectf-2.3.0/tests/bats/000077500000000000000000000000001317147435100152235ustar00rootroot00000000000000barectf-2.3.0/tests/bats/LICENSE000066400000000000000000000020421317147435100162260ustar00rootroot00000000000000Copyright (c) 2014 Sam Stephenson 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. barectf-2.3.0/tests/bats/bin/000077500000000000000000000000001317147435100157735ustar00rootroot00000000000000barectf-2.3.0/tests/bats/bin/bats000077700000000000000000000000001317147435100213442../libexec/batsustar00rootroot00000000000000barectf-2.3.0/tests/bats/libexec/000077500000000000000000000000001317147435100166365ustar00rootroot00000000000000barectf-2.3.0/tests/bats/libexec/bats000077500000000000000000000054201317147435100175160ustar00rootroot00000000000000#!/usr/bin/env bash set -e version() { echo "Bats 0.4.0" } usage() { version echo "Usage: bats [-c] [-p | -t] [ ...]" } help() { usage echo echo " is the path to a Bats test file, or the path to a directory" echo " containing Bats test files." echo echo " -c, --count Count the number of test cases without running any tests" echo " -h, --help Display this help message" echo " -p, --pretty Show results in pretty format (default for terminals)" echo " -t, --tap Show results in TAP format" echo " -v, --version Display the version number" echo echo " For more information, see https://github.com/sstephenson/bats" echo } resolve_link() { $(type -p greadlink readlink | head -1) "$1" } abs_dirname() { local cwd="$(pwd)" local path="$1" while [ -n "$path" ]; do cd "${path%/*}" local name="${path##*/}" path="$(resolve_link "$name" || true)" done pwd cd "$cwd" } expand_path() { { cd "$(dirname "$1")" 2>/dev/null local dirname="$PWD" cd "$OLDPWD" echo "$dirname/$(basename "$1")" } || echo "$1" } BATS_LIBEXEC="$(abs_dirname "$0")" export BATS_PREFIX="$(abs_dirname "$BATS_LIBEXEC")" export BATS_CWD="$(abs_dirname .)" export PATH="$BATS_LIBEXEC:$PATH" options=() arguments=() for arg in "$@"; do if [ "${arg:0:1}" = "-" ]; then if [ "${arg:1:1}" = "-" ]; then options[${#options[*]}]="${arg:2}" else index=1 while option="${arg:$index:1}"; do [ -n "$option" ] || break options[${#options[*]}]="$option" let index+=1 done fi else arguments[${#arguments[*]}]="$arg" fi done unset count_flag pretty [ -t 0 ] && [ -t 1 ] && pretty="1" [ -n "$CI" ] && pretty="" for option in "${options[@]}"; do case "$option" in "h" | "help" ) help exit 0 ;; "v" | "version" ) version exit 0 ;; "c" | "count" ) count_flag="-c" ;; "t" | "tap" ) pretty="" ;; "p" | "pretty" ) pretty="1" ;; * ) usage >&2 exit 1 ;; esac done if [ "${#arguments[@]}" -eq 0 ]; then usage >&2 exit 1 fi filenames=() for filename in "${arguments[@]}"; do if [ -d "$filename" ]; then shopt -s nullglob for suite_filename in "$(expand_path "$filename")"/*.bats; do filenames["${#filenames[@]}"]="$suite_filename" done shopt -u nullglob else filenames["${#filenames[@]}"]="$(expand_path "$filename")" fi done if [ "${#filenames[@]}" -eq 1 ]; then command="bats-exec-test" else command="bats-exec-suite" fi if [ -n "$pretty" ]; then extended_syntax_flag="-x" formatter="bats-format-tap-stream" else extended_syntax_flag="" formatter="cat" fi set -o pipefail execfail exec "$command" $count_flag $extended_syntax_flag "${filenames[@]}" | "$formatter" barectf-2.3.0/tests/bats/libexec/bats-exec-suite000077500000000000000000000017511317147435100215720ustar00rootroot00000000000000#!/usr/bin/env bash set -e count_only_flag="" if [ "$1" = "-c" ]; then count_only_flag=1 shift fi extended_syntax_flag="" if [ "$1" = "-x" ]; then extended_syntax_flag="-x" shift fi trap "kill 0; exit 1" int count=0 for filename in "$@"; do let count+="$(bats-exec-test -c "$filename")" done if [ -n "$count_only_flag" ]; then echo "$count" exit fi echo "1..$count" status=0 offset=0 for filename in "$@"; do index=0 { IFS= read -r # 1..n while IFS= read -r line; do case "$line" in "begin "* ) let index+=1 echo "${line/ $index / $(($offset + $index)) }" ;; "ok "* | "not ok "* ) [ -n "$extended_syntax_flag" ] || let index+=1 echo "${line/ $index / $(($offset + $index)) }" [ "${line:0:6}" != "not ok" ] || status=1 ;; * ) echo "$line" ;; esac done } < <( bats-exec-test $extended_syntax_flag "$filename" ) offset=$(($offset + $index)) done exit "$status" barectf-2.3.0/tests/bats/libexec/bats-exec-test000077500000000000000000000161341317147435100214210ustar00rootroot00000000000000#!/usr/bin/env bash set -e set -E set -T BATS_COUNT_ONLY="" if [ "$1" = "-c" ]; then BATS_COUNT_ONLY=1 shift fi BATS_EXTENDED_SYNTAX="" if [ "$1" = "-x" ]; then BATS_EXTENDED_SYNTAX="$1" shift fi BATS_TEST_FILENAME="$1" if [ -z "$BATS_TEST_FILENAME" ]; then echo "usage: bats-exec " >&2 exit 1 elif [ ! -f "$BATS_TEST_FILENAME" ]; then echo "bats: $BATS_TEST_FILENAME does not exist" >&2 exit 1 else shift fi BATS_TEST_DIRNAME="$(dirname "$BATS_TEST_FILENAME")" BATS_TEST_NAMES=() load() { local name="$1" local filename if [ "${name:0:1}" = "/" ]; then filename="${name}" else filename="$BATS_TEST_DIRNAME/${name}.bash" fi [ -f "$filename" ] || { echo "bats: $filename does not exist" >&2 exit 1 } source "${filename}" } run() { local e E T oldIFS [[ ! "$-" =~ e ]] || e=1 [[ ! "$-" =~ E ]] || E=1 [[ ! "$-" =~ T ]] || T=1 set +e set +E set +T output="$("$@" 2>&1)" status="$?" oldIFS=$IFS IFS=$'\n' lines=($output) [ -z "$e" ] || set -e [ -z "$E" ] || set -E [ -z "$T" ] || set -T IFS=$oldIFS } setup() { true } teardown() { true } skip() { BATS_TEST_SKIPPED=${1:-1} BATS_TEST_COMPLETED=1 exit 0 } bats_test_begin() { BATS_TEST_DESCRIPTION="$1" if [ -n "$BATS_EXTENDED_SYNTAX" ]; then echo "begin $BATS_TEST_NUMBER $BATS_TEST_DESCRIPTION" >&3 fi setup } bats_test_function() { local test_name="$1" BATS_TEST_NAMES["${#BATS_TEST_NAMES[@]}"]="$test_name" } bats_capture_stack_trace() { BATS_PREVIOUS_STACK_TRACE=( "${BATS_CURRENT_STACK_TRACE[@]}" ) BATS_CURRENT_STACK_TRACE=() local test_pattern=" $BATS_TEST_NAME $BATS_TEST_SOURCE" local setup_pattern=" setup $BATS_TEST_SOURCE" local teardown_pattern=" teardown $BATS_TEST_SOURCE" local frame local index=1 while frame="$(caller "$index")"; do BATS_CURRENT_STACK_TRACE["${#BATS_CURRENT_STACK_TRACE[@]}"]="$frame" if [[ "$frame" = *"$test_pattern" || \ "$frame" = *"$setup_pattern" || \ "$frame" = *"$teardown_pattern" ]]; then break else let index+=1 fi done BATS_SOURCE="$(bats_frame_filename "${BATS_CURRENT_STACK_TRACE[0]}")" BATS_LINENO="$(bats_frame_lineno "${BATS_CURRENT_STACK_TRACE[0]}")" } bats_print_stack_trace() { local frame local index=1 local count="${#@}" for frame in "$@"; do local filename="$(bats_trim_filename "$(bats_frame_filename "$frame")")" local lineno="$(bats_frame_lineno "$frame")" if [ $index -eq 1 ]; then echo -n "# (" else echo -n "# " fi local fn="$(bats_frame_function "$frame")" if [ "$fn" != "$BATS_TEST_NAME" ]; then echo -n "from function \`$fn' " fi if [ $index -eq $count ]; then echo "in test file $filename, line $lineno)" else echo "in file $filename, line $lineno," fi let index+=1 done } bats_print_failed_command() { local frame="$1" local status="$2" local filename="$(bats_frame_filename "$frame")" local lineno="$(bats_frame_lineno "$frame")" local failed_line="$(bats_extract_line "$filename" "$lineno")" local failed_command="$(bats_strip_string "$failed_line")" echo -n "# \`${failed_command}' " if [ $status -eq 1 ]; then echo "failed" else echo "failed with status $status" fi } bats_frame_lineno() { local frame="$1" local lineno="${frame%% *}" echo "$lineno" } bats_frame_function() { local frame="$1" local rest="${frame#* }" local fn="${rest%% *}" echo "$fn" } bats_frame_filename() { local frame="$1" local rest="${frame#* }" local filename="${rest#* }" if [ "$filename" = "$BATS_TEST_SOURCE" ]; then echo "$BATS_TEST_FILENAME" else echo "$filename" fi } bats_extract_line() { local filename="$1" local lineno="$2" sed -n "${lineno}p" "$filename" } bats_strip_string() { local string="$1" printf "%s" "$string" | sed -e "s/^[ "$'\t'"]*//" -e "s/[ "$'\t'"]*$//" } bats_trim_filename() { local filename="$1" local length="${#BATS_CWD}" if [ "${filename:0:length+1}" = "${BATS_CWD}/" ]; then echo "${filename:length+1}" else echo "$filename" fi } bats_debug_trap() { if [ "$BASH_SOURCE" != "$1" ]; then bats_capture_stack_trace fi } bats_error_trap() { BATS_ERROR_STATUS="$?" BATS_ERROR_STACK_TRACE=( "${BATS_PREVIOUS_STACK_TRACE[@]}" ) trap - debug } bats_teardown_trap() { trap "bats_exit_trap" exit local status=0 teardown >>"$BATS_OUT" 2>&1 || status="$?" if [ $status -eq 0 ]; then BATS_TEARDOWN_COMPLETED=1 elif [ -n "$BATS_TEST_COMPLETED" ]; then BATS_ERROR_STATUS="$status" BATS_ERROR_STACK_TRACE=( "${BATS_CURRENT_STACK_TRACE[@]}" ) fi bats_exit_trap } bats_exit_trap() { local status local skipped trap - err exit skipped="" if [ -n "$BATS_TEST_SKIPPED" ]; then skipped=" # skip" if [ "1" != "$BATS_TEST_SKIPPED" ]; then skipped+=" ($BATS_TEST_SKIPPED)" fi fi if [ -z "$BATS_TEST_COMPLETED" ] || [ -z "$BATS_TEARDOWN_COMPLETED" ]; then echo "not ok $BATS_TEST_NUMBER $BATS_TEST_DESCRIPTION" >&3 bats_print_stack_trace "${BATS_ERROR_STACK_TRACE[@]}" >&3 bats_print_failed_command "${BATS_ERROR_STACK_TRACE[${#BATS_ERROR_STACK_TRACE[@]}-1]}" "$BATS_ERROR_STATUS" >&3 sed -e "s/^/# /" < "$BATS_OUT" >&3 status=1 else echo "ok ${BATS_TEST_NUMBER}${skipped} ${BATS_TEST_DESCRIPTION}" >&3 status=0 fi rm -f "$BATS_OUT" exit "$status" } bats_perform_tests() { echo "1..$#" test_number=1 status=0 for test_name in "$@"; do "$0" $BATS_EXTENDED_SYNTAX "$BATS_TEST_FILENAME" "$test_name" "$test_number" || status=1 let test_number+=1 done exit "$status" } bats_perform_test() { BATS_TEST_NAME="$1" if [ "$(type -t "$BATS_TEST_NAME" || true)" = "function" ]; then BATS_TEST_NUMBER="$2" if [ -z "$BATS_TEST_NUMBER" ]; then echo "1..1" BATS_TEST_NUMBER="1" fi BATS_TEST_COMPLETED="" BATS_TEARDOWN_COMPLETED="" trap "bats_debug_trap \"\$BASH_SOURCE\"" debug trap "bats_error_trap" err trap "bats_teardown_trap" exit "$BATS_TEST_NAME" >>"$BATS_OUT" 2>&1 BATS_TEST_COMPLETED=1 else echo "bats: unknown test name \`$BATS_TEST_NAME'" >&2 exit 1 fi } if [ -z "$TMPDIR" ]; then BATS_TMPDIR="/tmp" else BATS_TMPDIR="${TMPDIR%/}" fi BATS_TMPNAME="$BATS_TMPDIR/bats.$$" BATS_PARENT_TMPNAME="$BATS_TMPDIR/bats.$PPID" BATS_OUT="${BATS_TMPNAME}.out" bats_preprocess_source() { BATS_TEST_SOURCE="${BATS_TMPNAME}.src" { tr -d '\r' < "$BATS_TEST_FILENAME"; echo; } | bats-preprocess > "$BATS_TEST_SOURCE" trap "bats_cleanup_preprocessed_source" err exit trap "bats_cleanup_preprocessed_source; exit 1" int } bats_cleanup_preprocessed_source() { rm -f "$BATS_TEST_SOURCE" } bats_evaluate_preprocessed_source() { if [ -z "$BATS_TEST_SOURCE" ]; then BATS_TEST_SOURCE="${BATS_PARENT_TMPNAME}.src" fi source "$BATS_TEST_SOURCE" } exec 3<&1 if [ "$#" -eq 0 ]; then bats_preprocess_source bats_evaluate_preprocessed_source if [ -n "$BATS_COUNT_ONLY" ]; then echo "${#BATS_TEST_NAMES[@]}" else bats_perform_tests "${BATS_TEST_NAMES[@]}" fi else bats_evaluate_preprocessed_source bats_perform_test "$@" fi barectf-2.3.0/tests/bats/libexec/bats-format-tap-stream000077500000000000000000000052421317147435100230610ustar00rootroot00000000000000#!/usr/bin/env bash set -e # Just stream the TAP output (sans extended syntax) if tput is missing command -v tput >/dev/null || exec grep -v "^begin " header_pattern='[0-9]+\.\.[0-9]+' IFS= read -r header if [[ "$header" =~ $header_pattern ]]; then count="${header:3}" index=0 failures=0 skipped=0 name="" count_column_width=$(( ${#count} * 2 + 2 )) else # If the first line isn't a TAP plan, print it and pass the rest through printf "%s\n" "$header" exec cat fi update_screen_width() { screen_width="$(tput cols)" count_column_left=$(( $screen_width - $count_column_width )) } trap update_screen_width WINCH update_screen_width begin() { go_to_column 0 printf_with_truncation $(( $count_column_left - 1 )) " %s" "$name" clear_to_end_of_line go_to_column $count_column_left printf "%${#count}s/${count}" "$index" go_to_column 1 } pass() { go_to_column 0 printf " ✓ %s" "$name" advance } skip() { local reason="$1" [ -z "$reason" ] || reason=": $reason" go_to_column 0 printf " - %s (skipped%s)" "$name" "$reason" advance } fail() { go_to_column 0 set_color 1 bold printf " ✗ %s" "$name" advance } log() { set_color 1 printf " %s\n" "$1" clear_color } summary() { printf "\n%d test%s" "$count" "$(plural "$count")" printf ", %d failure%s" "$failures" "$(plural "$failures")" if [ "$skipped" -gt 0 ]; then printf ", %d skipped" "$skipped" fi printf "\n" } printf_with_truncation() { local width="$1" shift local string="$(printf "$@")" if [ "${#string}" -gt "$width" ]; then printf "%s..." "${string:0:$(( $width - 4 ))}" else printf "%s" "$string" fi } go_to_column() { local column="$1" printf "\x1B[%dG" $(( $column + 1 )) } clear_to_end_of_line() { printf "\x1B[K" } advance() { clear_to_end_of_line echo clear_color } set_color() { local color="$1" local weight="$2" printf "\x1B[%d;%dm" $(( 30 + $color )) "$( [ "$weight" = "bold" ] && echo 1 || echo 22 )" } clear_color() { printf "\x1B[0m" } plural() { [ "$1" -eq 1 ] || echo "s" } _buffer="" buffer() { _buffer="${_buffer}$("$@")" } flush() { printf "%s" "$_buffer" _buffer="" } finish() { flush printf "\n" } trap finish EXIT while IFS= read -r line; do case "$line" in "begin "* ) let index+=1 name="${line#* $index }" buffer begin flush ;; "ok "* ) skip_expr="ok $index # skip (\(([^)]*)\))?" if [[ "$line" =~ $skip_expr ]]; then let skipped+=1 buffer skip "${BASH_REMATCH[2]}" else buffer pass fi ;; "not ok "* ) let failures+=1 buffer fail ;; "# "* ) buffer log "${line:2}" ;; esac done buffer summary barectf-2.3.0/tests/bats/libexec/bats-preprocess000077500000000000000000000021211317147435100216740ustar00rootroot00000000000000#!/usr/bin/env bash set -e encode_name() { local name="$1" local result="test_" if [[ ! "$name" =~ [^[:alnum:]\ _-] ]]; then name="${name//_/-5f}" name="${name//-/-2d}" name="${name// /_}" result+="$name" else local length="${#name}" local char i for ((i=0; i # # 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. barectf_assert_file_exists() { if [ ! -f "$1" ]; then echo "FATAL: "$1" does not exist" 1>&2 return 1 fi if ! which barectf > /dev/null; then echo "FATAL: cannot find barectf tool" 1>&2 return 1 fi } barectf_config_check_success() { pushd "$BATS_TEST_DIRNAME" >/dev/null if ! barectf_assert_file_exists "$1"; then popd >/dev/null return 1 fi run barectf "$1" popd >/dev/null if [ "$status" -ne 0 ]; then echo "Fail: exit code is $status" 1>&2 return 1 fi } barectf_config_check_fail() { pushd "$BATS_TEST_DIRNAME" >/dev/null if ! barectf_assert_file_exists "$1"; then popd >/dev/null return 1 fi run barectf "$1" if [ "$status" -eq 0 ]; then echo "Fail: exit code is 0" 1>&2 popd >/dev/null return 1 fi local find_output="$(find -iname '*.c' -o -iname '*.h' -o -iname metadata)" popd >/dev/null if [ -n "$find_output" ]; then echo "Fail: barectf generated files" 1>&2 return 1 fi } setup() { : } teardown() { rm -f *ctf.c *ctf.h *ctf.o *ctf-bitfield.h metadata } barectf-2.3.0/tests/config/fail/000077500000000000000000000000001317147435100164525ustar00rootroot00000000000000barectf-2.3.0/tests/config/fail/clock/000077500000000000000000000000001317147435100175455ustar00rootroot00000000000000barectf-2.3.0/tests/config/fail/clock/absolute-invalid-type.yaml000066400000000000000000000031351317147435100246540ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: my_clock: absolute: [] barectf-2.3.0/tests/config/fail/clock/description-invalid-type.yaml000066400000000000000000000031401317147435100253550ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: my_clock: description: 23 barectf-2.3.0/tests/config/fail/clock/ec-invalid-type.yaml000066400000000000000000000031451317147435100234260ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: my_clock: error-cycles: string barectf-2.3.0/tests/config/fail/clock/ec-invalid.yaml000066400000000000000000000031421317147435100224440ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: my_clock: error-cycles: -17 barectf-2.3.0/tests/config/fail/clock/fail.bats000066400000000000000000000064641317147435100213450ustar00rootroot00000000000000#!/usr/bin/env bats # 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. load ../../common @test 'unknown property in clock object makes barectf fail' { barectf_config_check_fail unknown-prop.yaml } @test 'wrong "freq" property type in clock object makes barectf fail' { barectf_config_check_fail freq-invalid-type.yaml } @test 'invalid "freq" property (0) in clock object makes barectf fail' { barectf_config_check_fail freq-0.yaml } @test 'invalid "freq" property (negative) in clock object makes barectf fail' { barectf_config_check_fail freq-neg.yaml } @test 'wrong "description" property type in clock object makes barectf fail' { barectf_config_check_fail description-invalid-type.yaml } @test 'wrong "uuid" property type in clock object makes barectf fail' { barectf_config_check_fail uuid-invalid-type.yaml } @test 'invalid "uuid" property in clock object makes barectf fail' { barectf_config_check_fail uuid-invalid.yaml } @test 'wrong "error-cycles" property type in clock object makes barectf fail' { barectf_config_check_fail ec-invalid-type.yaml } @test 'invalid "error-cycles" property in clock object makes barectf fail' { barectf_config_check_fail ec-invalid.yaml } @test 'wrong "offset" property type in clock object makes barectf fail' { barectf_config_check_fail offset-invalid-type.yaml } @test 'wrong "absolute" property type in clock object makes barectf fail' { barectf_config_check_fail absolute-invalid-type.yaml } @test 'unknown property in clock offset object makes barectf fail' { barectf_config_check_fail offset-unknown-prop.yaml } @test 'wrong "seconds" property type in clock offset object makes barectf fail' { barectf_config_check_fail offset-seconds-invalid-type.yaml } @test 'invalid "seconds" property in clock offset object makes barectf fail' { barectf_config_check_fail offset-seconds-neg.yaml } @test 'wrong "cycles" property type in clock offset object makes barectf fail' { barectf_config_check_fail offset-cycles-invalid-type.yaml } @test 'invalid "cycles" property in clock offset object makes barectf fail' { barectf_config_check_fail offset-cycles-neg.yaml } @test 'wrong "$return-ctype" property type in clock object makes barectf fail' { barectf_config_check_fail rct-invalid-type.yaml } barectf-2.3.0/tests/config/fail/clock/freq-0.yaml000066400000000000000000000031301317147435100215200ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: my_clock: freq: 0 barectf-2.3.0/tests/config/fail/clock/freq-invalid-type.yaml000066400000000000000000000031351317147435100237730ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: my_clock: freq: string barectf-2.3.0/tests/config/fail/clock/freq-neg.yaml000066400000000000000000000031321317147435100221340ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: my_clock: freq: -12 barectf-2.3.0/tests/config/fail/clock/offset-cycles-invalid-type.yaml000066400000000000000000000031571317147435100256100ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: my_clock: offset: cycles: string barectf-2.3.0/tests/config/fail/clock/offset-cycles-neg.yaml000066400000000000000000000031541317147435100237510ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: my_clock: offset: cycles: -17 barectf-2.3.0/tests/config/fail/clock/offset-invalid-type.yaml000066400000000000000000000031331317147435100243220ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: my_clock: offset: 23 barectf-2.3.0/tests/config/fail/clock/offset-seconds-invalid-type.yaml000066400000000000000000000031601317147435100257560ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: my_clock: offset: seconds: string barectf-2.3.0/tests/config/fail/clock/offset-seconds-neg.yaml000066400000000000000000000031551317147435100241260ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: my_clock: offset: seconds: -17 barectf-2.3.0/tests/config/fail/clock/offset-unknown-prop.yaml000066400000000000000000000031571317147435100244000ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: my_clock: offset: unknown: false barectf-2.3.0/tests/config/fail/clock/rct-invalid-type.yaml000066400000000000000000000031421317147435100236240ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: my_clock: $return-ctype: 23 barectf-2.3.0/tests/config/fail/clock/unknown-prop.yaml000066400000000000000000000031601317147435100231060ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: my_clock: freq: 1000 unknown: false barectf-2.3.0/tests/config/fail/clock/uuid-invalid-type.yaml000066400000000000000000000031321317147435100240010ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: my_clock: uuid: -17 barectf-2.3.0/tests/config/fail/clock/uuid-invalid.yaml000066400000000000000000000031331317147435100230230ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: my_clock: uuid: zoom barectf-2.3.0/tests/config/fail/config/000077500000000000000000000000001317147435100177175ustar00rootroot00000000000000barectf-2.3.0/tests/config/fail/config/fail.bats000066400000000000000000000054111317147435100215060ustar00rootroot00000000000000#!/usr/bin/env bats # 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. load ../../common @test 'unknown property in config object makes barectf fail' { barectf_config_check_fail unknown-prop.yaml } @test 'no "version" property in config object makes barectf fail' { barectf_config_check_fail version-no.yaml } @test 'wrong "version" property type in config object makes barectf fail' { barectf_config_check_fail version-invalid-type.yaml } @test 'invalid "version" property (1.9) in config object makes barectf fail' { barectf_config_check_fail version-invalid-19.yaml } @test 'invalid "version" property (2.3) in config object makes barectf fail' { barectf_config_check_fail version-invalid-23.yaml } @test 'wrong "prefix" property type in config object makes barectf fail' { barectf_config_check_fail prefix-invalid-type.yaml } @test 'no valid C identifier in "prefix" property type in config object makes barectf fail' { barectf_config_check_fail prefix-invalid-identifier.yaml } @test 'no "metadata" property in config object makes barectf fail' { barectf_config_check_fail metadata-no.yaml } @test 'wrong "metadata" property type in config object makes barectf fail' { barectf_config_check_fail metadata-invalid-type.yaml } @test 'wrong "options" property type in config object makes barectf fail' { barectf_config_check_fail options-invalid-type.yaml } @test 'wrong "gen-prefix-def" property type in config options object makes barectf fail' { barectf_config_check_fail options-gen-prefix-def-invalid-type.yaml } @test 'wrong "gen-default-stream-def" property type in config options object makes barectf fail' { barectf_config_check_fail options-gen-default-stream-def-invalid-type.yaml } barectf-2.3.0/tests/config/fail/config/metadata-invalid-type.yaml000066400000000000000000000022251317147435100247670ustar00rootroot00000000000000# 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. version: '2.1' metadata: 23 barectf-2.3.0/tests/config/fail/config/metadata-no.yaml000066400000000000000000000022071317147435100227760ustar00rootroot00000000000000# 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. version: '2.1' barectf-2.3.0/tests/config/fail/config/options-gen-default-stream-def-invalid-type.yaml000066400000000000000000000031301317147435100311140ustar00rootroot00000000000000# 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. version: '2.2' options: gen-default-stream-def: 23 metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/config/options-gen-prefix-def-invalid-type.yaml000066400000000000000000000031231317147435100274760ustar00rootroot00000000000000# 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. version: '2.2' options: gen-prefix-def: do it metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/config/options-invalid-type.yaml000066400000000000000000000031011317147435100246740ustar00rootroot00000000000000# 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. version: '2.2' options: false metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/config/options-unknown-prop.yaml000066400000000000000000000031071317147435100247520ustar00rootroot00000000000000# 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. version: '2.2' options: meow: mix metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/config/prefix-invalid-identifier.yaml000066400000000000000000000031101317147435100256370ustar00rootroot00000000000000# 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. version: '2.1' prefix: 'some prefix' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/config/prefix-invalid-type.yaml000066400000000000000000000030761317147435100245110ustar00rootroot00000000000000# 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. version: '2.1' prefix: -21 metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/config/unknown-prop.yaml000066400000000000000000000031011317147435100232530ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 unknown: false barectf-2.3.0/tests/config/fail/config/version-invalid-19.yaml000066400000000000000000000030621317147435100241440ustar00rootroot00000000000000# 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. version: '1.9' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/config/version-invalid-23.yaml000066400000000000000000000030621317147435100241370ustar00rootroot00000000000000# 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. version: '2.3' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/config/version-invalid-type.yaml000066400000000000000000000030601317147435100246720ustar00rootroot00000000000000# 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. version: 2.1 metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/config/version-no.yaml000066400000000000000000000030431317147435100227020ustar00rootroot00000000000000# 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. metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/event/000077500000000000000000000000001317147435100175735ustar00rootroot00000000000000barectf-2.3.0/tests/config/fail/event/ct-invalid-type.yaml000066400000000000000000000031151317147435100234700ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: context-type: 23 payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/event/ct-not-struct.yaml000066400000000000000000000031651317147435100232120ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: context-type: class: int size: 8 payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/event/fail.bats000066400000000000000000000043171317147435100213660ustar00rootroot00000000000000#!/usr/bin/env bats # 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. load ../../common @test 'unknown property in event object makes barectf fail' { barectf_config_check_fail unknown-prop.yaml } @test 'wrong "log-level" property type in event object makes barectf fail' { barectf_config_check_fail ll-invalid-type.yaml } @test 'non existing log level name as "log-level" property value in event object makes barectf fail' { barectf_config_check_fail ll-non-existing.yaml } @test 'wrong "context-type" property type in event object makes barectf fail' { barectf_config_check_fail ct-invalid-type.yaml } @test 'invalid "context-type" property field type (not a structure) in event object makes barectf fail' { barectf_config_check_fail ct-not-struct.yaml } @test 'wrong "payload-type" property type in event object makes barectf fail' { barectf_config_check_fail pt-invalid-type.yaml } @test 'invalid "payload-type" property field type (not a structure) in event object makes barectf fail' { barectf_config_check_fail pt-not-struct.yaml } @test 'empty event object makes barectf fail' { barectf_config_check_fail no-fields-at-all.yaml } barectf-2.3.0/tests/config/fail/event/ll-invalid-type.yaml000066400000000000000000000031141317147435100234700ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: log-level: true payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/event/ll-non-existing.yaml000066400000000000000000000031671317147435100235150ustar00rootroot00000000000000# 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. version: '2.1' metadata: $log-levels: EMERG: 0 WARNING: 23 type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: log-level: EME payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/event/no-fields-at-all.yaml000066400000000000000000000026441317147435100235150ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: {} barectf-2.3.0/tests/config/fail/event/pt-invalid-type.yaml000066400000000000000000000026751317147435100235170ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: -17 barectf-2.3.0/tests/config/fail/event/pt-not-struct.yaml000066400000000000000000000027241317147435100232270ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct barectf-2.3.0/tests/config/fail/event/unknown-prop.yaml000066400000000000000000000031131317147435100231320ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: unknown: false payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/include/000077500000000000000000000000001317147435100200755ustar00rootroot00000000000000barectf-2.3.0/tests/config/fail/include/cycle-sym.yaml000066400000000000000000000031261317147435100226700ustar00rootroot00000000000000# 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. version: '2.1' metadata: $include: inc-recursive-sym1.yaml type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/include/cycle.yaml000066400000000000000000000031221317147435100220560ustar00rootroot00000000000000# 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. version: '2.1' metadata: $include: inc-recursive1.yaml type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/include/fail.bats000066400000000000000000000042111317147435100216610ustar00rootroot00000000000000#!/usr/bin/env bats # 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. load ../../common @test 'wrong "$include" property type makes barectf fail' { barectf_config_check_fail invalid-type.yaml } @test 'non-existing file in "$include" property (string) makes barectf fail' { barectf_config_check_fail file-not-found.yaml } @test 'non-existing absolute file in "$include" property (string) makes barectf fail' { barectf_config_check_fail file-not-found-abs.yaml } @test 'non-existing file in "$include" property (array) makes barectf fail' { barectf_config_check_fail file-not-found-in-array.yaml } @test 'non-existing file in "$include" property (recursive) makes barectf fail' { barectf_config_check_fail file-not-found-recursive.yaml } @test 'cycle in include graph makes barectf fail' { barectf_config_check_fail cycle.yaml } @test 'cycle in include graph (with a symbolic link) makes barectf fail' { local symlink="$BATS_TEST_DIRNAME/inc-recursive-sym3.yaml" ln -fs inc-recursive-sym1.yaml "$symlink" barectf_config_check_fail cycle-sym.yaml rm -f "$symlink" } barectf-2.3.0/tests/config/fail/include/file-not-found-abs.yaml000066400000000000000000000031211317147435100243470ustar00rootroot00000000000000# 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. version: '2.1' metadata: $include: /path/to/not/found type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/include/file-not-found-in-array.yaml000066400000000000000000000031421317147435100253270ustar00rootroot00000000000000# 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. version: '2.1' metadata: $include: - inc-empty.yaml - yes.yaml type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/include/file-not-found-recursive.yaml000066400000000000000000000031251317147435100256150ustar00rootroot00000000000000# 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. version: '2.1' metadata: $include: inc-inc-not-found.yaml type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/include/file-not-found.yaml000066400000000000000000000031071317147435100236100ustar00rootroot00000000000000# 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. version: '2.1' metadata: $include: yes.yaml type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/include/inc-empty.yaml000066400000000000000000000021731317147435100226710ustar00rootroot00000000000000# 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. {} barectf-2.3.0/tests/config/fail/include/inc-inc-not-found.yaml000066400000000000000000000022131317147435100242060ustar00rootroot00000000000000# 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: yes.yaml barectf-2.3.0/tests/config/fail/include/inc-recursive-sym1.yaml000066400000000000000000000022321317147435100244250ustar00rootroot00000000000000# 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: inc-recursive-sym2.yaml barectf-2.3.0/tests/config/fail/include/inc-recursive-sym2.yaml000066400000000000000000000022321317147435100244260ustar00rootroot00000000000000# 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: inc-recursive-sym3.yaml barectf-2.3.0/tests/config/fail/include/inc-recursive1.yaml000066400000000000000000000022261317147435100236220ustar00rootroot00000000000000# 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: inc-recursive2.yaml barectf-2.3.0/tests/config/fail/include/inc-recursive2.yaml000066400000000000000000000022261317147435100236230ustar00rootroot00000000000000# 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: inc-recursive3.yaml barectf-2.3.0/tests/config/fail/include/inc-recursive3.yaml000066400000000000000000000022261317147435100236240ustar00rootroot00000000000000# 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: inc-recursive1.yaml barectf-2.3.0/tests/config/fail/include/include-include-replace.yaml000066400000000000000000000031601317147435100254360ustar00rootroot00000000000000# 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. version: '2.1' metadata: $include: inc-empty.yaml $include-replace: inc-empty.yaml type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/include/invalid-type.yaml000066400000000000000000000031011317147435100233610ustar00rootroot00000000000000# 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. version: '2.1' metadata: $include: 23 type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/include/replace-file-not-found-in-array.yaml000066400000000000000000000031521317147435100267410ustar00rootroot00000000000000# 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. version: '2.1' metadata: $include-replace: - inc-empty.yaml - yes.yaml type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/include/replace-file-not-found.yaml000066400000000000000000000031171317147435100252220ustar00rootroot00000000000000# 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. version: '2.1' metadata: $include-replace: yes.yaml type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/metadata/000077500000000000000000000000001317147435100202325ustar00rootroot00000000000000barectf-2.3.0/tests/config/fail/metadata/clocks-invalid-type.yaml000066400000000000000000000030771317147435100250060ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: 23 barectf-2.3.0/tests/config/fail/metadata/clocks-key-invalid-identifier.yaml000066400000000000000000000031371317147435100267320ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 clocks: 'some clock': freq: 1000 barectf-2.3.0/tests/config/fail/metadata/default-stream-invalid-type.yaml000066400000000000000000000031101317147435100264310ustar00rootroot00000000000000# 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. version: '2.2' metadata: $default-stream: 23 type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/metadata/default-stream-stream-default-duplicate.yaml000066400000000000000000000036451317147435100307260ustar00rootroot00000000000000# 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. version: '2.2' metadata: $default-stream: my_stream type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 other_stream: $default: true packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/metadata/default-stream-unknown-stream.yaml000066400000000000000000000031211317147435100270160ustar00rootroot00000000000000# 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. version: '2.2' metadata: $default-stream: some_stream type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/metadata/env-invalid-type.yaml000066400000000000000000000030741317147435100243150ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 env: 17 barectf-2.3.0/tests/config/fail/metadata/env-key-invalid-identifier.yaml000066400000000000000000000031231317147435100262370ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 env: 'yes sir miller': bug barectf-2.3.0/tests/config/fail/metadata/env-value-invalid-type.yaml000066400000000000000000000031411317147435100254220ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 env: yes-sir-miller: - a - b barectf-2.3.0/tests/config/fail/metadata/fail.bats000066400000000000000000000076761317147435100220400ustar00rootroot00000000000000#!/usr/bin/env bats # 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. load ../../common @test 'unknown property in metadata object makes barectf fail' { barectf_config_check_fail unknown-prop.yaml } @test 'wrong "env" property type in metadata object makes barectf fail' { barectf_config_check_fail env-invalid-type.yaml } @test 'invalid "env" key (invalid C identifier) in metadata object makes barectf fail' { barectf_config_check_fail env-key-invalid-identifier.yaml } @test 'invalid "env" value (not an int/string) in metadata object makes barectf fail' { barectf_config_check_fail env-value-invalid-type.yaml } @test 'wrong "clocks" property type in metadata object makes barectf fail' { barectf_config_check_fail clocks-invalid-type.yaml } @test 'invalid "clocks" key (invalid C identifier) in metadata object makes barectf fail' { barectf_config_check_fail clocks-key-invalid-identifier.yaml } @test 'wrong "$log-levels" property type in metadata object makes barectf fail' { barectf_config_check_fail ll-invalid-type.yaml } @test 'wrong "$log-levels" property value type in metadata object makes barectf fail' { barectf_config_check_fail ll-value-invalid-type.yaml } @test 'wrong "type-aliases" property type in metadata object makes barectf fail' { barectf_config_check_fail ta-invalid-type.yaml } @test 'no "trace" property in metadata object makes barectf fail' { barectf_config_check_fail trace-no.yaml } @test 'wrong "trace" property type in metadata object makes barectf fail' { barectf_config_check_fail trace-invalid-type.yaml } @test 'empty "trace" property in metadata object makes barectf fail' { barectf_config_check_fail trace-empty.yaml } @test 'no "streams" property in metadata object makes barectf fail' { barectf_config_check_fail streams-no.yaml } @test 'wrong "streams" property type in metadata object makes barectf fail' { barectf_config_check_fail streams-invalid-type.yaml } @test 'empty "streams" property in metadata object makes barectf fail' { barectf_config_check_fail streams-empty.yaml } @test 'invalid "streams" key (invalid C identifier) in metadata object makes barectf fail' { barectf_config_check_fail streams-key-invalid-identifier.yaml } @test 'multiple streams in metadata object with missing "stream_id" packet header type field makes barectf fail' { barectf_config_check_fail multiple-streams-trace-ph-no-stream-id.yaml } @test 'wrong "$default-stream" property type in metadata object makes barectf fail' { barectf_config_check_fail default-stream-invalid-type.yaml } @test 'non-existing stream name in "$default-stream" property makes barectf fail' { barectf_config_check_fail default-stream-unknown-stream.yaml } @test 'coexisting "$default-stream" property (metadata) and "$default: true" property (stream) with different names make barectf fail' { barectf_config_check_fail default-stream-stream-default-duplicate.yaml } barectf-2.3.0/tests/config/fail/metadata/ll-invalid-type.yaml000066400000000000000000000031071317147435100241310ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 $log-levels: hello barectf-2.3.0/tests/config/fail/metadata/ll-value-invalid-type.yaml000066400000000000000000000031341317147435100252430ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 $log-levels: 'yes sir miller': meow barectf-2.3.0/tests/config/fail/metadata/multiple-streams-trace-ph-no-stream-id.yaml000066400000000000000000000032461317147435100304300ustar00rootroot00000000000000# 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. version: '2.1' metadata: $include: - stdint.yaml - stdmisc.yaml type-aliases: pct: class: struct fields: packet_size: uint32 content_size: uint32 pt: class: struct fields: a: uint32 trace: byte-order: le packet-header-type: class: struct fields: magic: ctf-magic streams: s1: packet-context-type: pct events: ev1: payload-type: pt s2: packet-context-type: pct events: ev2: payload-type: pt barectf-2.3.0/tests/config/fail/metadata/streams-empty.yaml000066400000000000000000000022731317147435100237340ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: {} barectf-2.3.0/tests/config/fail/metadata/streams-invalid-type.yaml000066400000000000000000000023701317147435100252010ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: -17 barectf-2.3.0/tests/config/fail/metadata/streams-key-invalid-identifier.yaml000066400000000000000000000030661317147435100271330ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: 'some stream': packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/metadata/streams-no.yaml000066400000000000000000000022551317147435100232120ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le barectf-2.3.0/tests/config/fail/metadata/ta-invalid-type.yaml000066400000000000000000000030701317147435100241250ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: - uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/metadata/trace-empty.yaml000066400000000000000000000030421317147435100233470ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: {} streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/metadata/trace-invalid-type.yaml000066400000000000000000000030461317147435100246220ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: switch streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/metadata/trace-no.yaml000066400000000000000000000027321317147435100226320ustar00rootroot00000000000000# 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. version: '2.1' metadata: streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/metadata/unknown-prop.yaml000066400000000000000000000031031317147435100235700ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 unknown: false barectf-2.3.0/tests/config/fail/stream/000077500000000000000000000000001317147435100177455ustar00rootroot00000000000000barectf-2.3.0/tests/config/fail/stream/default-invalid-type.yaml000066400000000000000000000031051317147435100246570ustar00rootroot00000000000000# 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. version: '2.2' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: $default: 23 packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/ect-invalid-type.yaml000066400000000000000000000027211317147435100240110ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: event-context-type: 23 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/ect-not-struct.yaml000066400000000000000000000027441317147435100235330ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: event-context-type: class: string events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/eht-id-no-multiple-events.yaml000066400000000000000000000033661317147435100255600ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 my_other_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/eht-id-not-int.yaml000066400000000000000000000032641317147435100233760ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 event-header-type: class: struct fields: id: class: string events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/eht-id-too-small.yaml000066400000000000000000000042161317147435100237130ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 event-header-type: class: struct min-align: 8 fields: id: class: int size: 2 events: my_event: payload-type: class: struct fields: my_field: uint16 my_event2: payload-type: class: struct fields: my_field: uint16 my_event3: payload-type: class: struct fields: my_field: uint16 my_event4: payload-type: class: struct fields: my_field: uint16 my_event5: payload-type: class: struct fields: my_field: uint16 barectf-2.3.0/tests/config/fail/stream/eht-id-wrong-signed.yaml000066400000000000000000000033371317147435100244120ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 event-header-type: class: struct fields: id: class: int size: 16 signed: true events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/eht-invalid-type.yaml000066400000000000000000000027201317147435100240150ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: event-header-type: 23 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/eht-not-struct.yaml000066400000000000000000000027431317147435100235370ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: event-header-type: class: string events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/eht-timestamp-not-int.yaml000066400000000000000000000032731317147435100250050ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 event-header-type: class: struct fields: timestamp: class: string events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/eht-timestamp-wrong-pm.yaml000066400000000000000000000033151317147435100251600ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 event-header-type: class: struct fields: timestamp: class: int size: 16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/eht-timestamp-wrong-signed.yaml000066400000000000000000000035401317147435100260150ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 event-header-type: class: struct fields: timestamp: class: int size: 16 signed: true property-mappings: - type: clock name: my_clock property: value events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/events-empty.yaml000066400000000000000000000023301317147435100232670ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: {} barectf-2.3.0/tests/config/fail/stream/events-invalid-type.yaml000066400000000000000000000026241317147435100245440ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: 23.5 barectf-2.3.0/tests/config/fail/stream/events-key-invalid-identifier.yaml000066400000000000000000000030631317147435100264710ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: a_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: 'my event': payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/events-no.yaml000066400000000000000000000026171317147435100225550ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: class: int size: 16 content_size: class: int size: 16 barectf-2.3.0/tests/config/fail/stream/fail.bats000066400000000000000000000154571317147435100215470ustar00rootroot00000000000000#!/usr/bin/env bats # 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. load ../../common @test 'unknown property in stream object makes barectf fail' { barectf_config_check_fail unknown-prop.yaml } @test 'no "packet-context-type" property in stream object makes barectf fail' { barectf_config_check_fail pct-no.yaml } @test 'wrong "packet-context-type" property type in stream object makes barectf fail' { barectf_config_check_fail pct-invalid-type.yaml } @test 'invalid "packet-context-type" property field type (not a structure) in stream object makes barectf fail' { barectf_config_check_fail pct-not-struct.yaml } @test 'invalid "timestamp_begin" field type (not an integer) in packet context type makes barectf fail' { barectf_config_check_fail pct-tb-not-int.yaml } @test 'invalid "timestamp_begin" field type (signed) in packet context type makes barectf fail' { barectf_config_check_fail pct-tb-wrong-signed.yaml } @test 'invalid "timestamp_begin" field type (not mapped to a clock) in packet context type makes barectf fail' { barectf_config_check_fail pct-tb-wrong-pm.yaml } @test 'no "timestamp_begin" field with an existing "timestamp_end" field in packet context type makes barectf fail' { barectf_config_check_fail pct-te-yes-tb-no.yaml } @test 'invalid "timestamp_end" field type (not an integer) in packet context type makes barectf fail' { barectf_config_check_fail pct-te-not-int.yaml } @test 'invalid "timestamp_end" field type (signed) in packet context type makes barectf fail' { barectf_config_check_fail pct-te-wrong-signed.yaml } @test 'invalid "timestamp_end" field type (not mapped to a clock) in packet context type makes barectf fail' { barectf_config_check_fail pct-te-wrong-pm.yaml } @test 'no "timestamp_end" field with an existing "timestamp_begin" field in packet context type makes barectf fail' { barectf_config_check_fail pct-tb-yes-te-no.yaml } @test '"timestamp_begin" field and "timestamp_end" field are not mapped to the same clock in packet context type makes barectf fail' { barectf_config_check_fail pct-tb-te-different-clocks.yaml } @test 'invalid "packet_size" field type (not an integer) in packet context type makes barectf fail' { barectf_config_check_fail pct-ps-not-int.yaml } @test 'invalid "packet_size" field type (signed) in packet context type makes barectf fail' { barectf_config_check_fail pct-ps-wrong-signed.yaml } @test 'no "packet_size" field with an existing "content_size" field in packet context type makes barectf fail' { barectf_config_check_fail pct-cs-yes-ps-no.yaml } @test 'invalid "content_size" field type (not an integer) in packet context type makes barectf fail' { barectf_config_check_fail pct-cs-not-int.yaml } @test 'invalid "content_size" field type (signed) in packet context type makes barectf fail' { barectf_config_check_fail pct-cs-wrong-signed.yaml } @test 'no "content_size" field with an existing "packet_size" field in packet context type makes barectf fail' { barectf_config_check_fail pct-ps-yes-cs-no.yaml } @test '"content_size" field size greater than "packet_size" field size in packet context type makes barectf fail' { barectf_config_check_fail pct-cs-gt-ps.yaml } @test 'invalid "events_discarded" field type (not an integer) in packet context type makes barectf fail' { barectf_config_check_fail pct-ed-not-int.yaml } @test 'invalid "events_discarded" field type (signed) in packet context type makes barectf fail' { barectf_config_check_fail pct-ed-wrong-signed.yaml } @test 'wrong "event-header-type" property type in stream object makes barectf fail' { barectf_config_check_fail eht-invalid-type.yaml } @test 'invalid "event-header-type" property field type (not a structure) in stream object makes barectf fail' { barectf_config_check_fail eht-not-struct.yaml } @test 'invalid "timestamp" field type (not an integer) in event header type makes barectf fail' { barectf_config_check_fail eht-timestamp-not-int.yaml } @test 'invalid "timestamp" field type (signed) in event header type makes barectf fail' { barectf_config_check_fail eht-timestamp-wrong-signed.yaml } @test 'invalid "timestamp" field type (not mapped to a clock) in event header type makes barectf fail' { barectf_config_check_fail eht-timestamp-wrong-pm.yaml } @test 'invalid "id" field type (not an integer) in event header type makes barectf fail' { barectf_config_check_fail eht-id-not-int.yaml } @test 'invalid "id" field type (signed) in event header type makes barectf fail' { barectf_config_check_fail eht-id-wrong-signed.yaml } @test 'no event header type with multiple events in stream object makes barectf fail' { barectf_config_check_fail eht-id-no-multiple-events.yaml } @test '"id" field type size too small for the number of stream events in event header type makes barectf fail' { barectf_config_check_fail eht-id-too-small.yaml } @test 'wrong "event-context-type" property type in stream object makes barectf fail' { barectf_config_check_fail ect-invalid-type.yaml } @test 'invalid "event-context-type" property field type (not a structure) in stream object makes barectf fail' { barectf_config_check_fail ect-not-struct.yaml } @test 'no "events" property in stream object makes barectf fail' { barectf_config_check_fail events-no.yaml } @test 'wrong "events" property type in stream object makes barectf fail' { barectf_config_check_fail events-invalid-type.yaml } @test 'empty "events" property in stream object makes barectf fail' { barectf_config_check_fail events-empty.yaml } @test 'invalid "events" key (invalid C identifier) in metadata object makes barectf fail' { barectf_config_check_fail events-key-invalid-identifier.yaml } @test 'wrong "$default" property type in stream object makes barectf fail' { barectf_config_check_fail default-invalid-type.yaml } barectf-2.3.0/tests/config/fail/stream/pct-cs-gt-ps.yaml000066400000000000000000000032261317147435100230550ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: class: int size: 16 packet_size: class: int size: 8 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-cs-not-int.yaml000066400000000000000000000031051317147435100234070ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: class: string packet_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-cs-wrong-signed.yaml000066400000000000000000000032131317147435100244220ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: class: int size: 16 signed: true packet_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-cs-yes-ps-no.yaml000066400000000000000000000030241317147435100236510ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-ed-not-int.yaml000066400000000000000000000030531317147435100233740ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: events_discarded: class: string events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-ed-wrong-signed.yaml000066400000000000000000000031611317147435100244070ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: events_discarded: class: int size: 16 signed: true events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-invalid-type.yaml000066400000000000000000000027221317147435100240250ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: 23 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-no.yaml000066400000000000000000000027171317147435100220400ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-not-struct.yaml000066400000000000000000000027451317147435100235470ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: string events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-ps-not-int.yaml000066400000000000000000000031051317147435100234240ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: class: string content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-ps-wrong-signed.yaml000066400000000000000000000032131317147435100244370ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: class: int size: 16 signed: true content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-ps-yes-cs-no.yaml000066400000000000000000000030231317147435100236500ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-tb-not-int.yaml000066400000000000000000000031471317147435100234150ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 timestamp_begin: class: string events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-tb-te-different-clocks.yaml000066400000000000000000000037521317147435100256570ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} my_other_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 timestamp_begin: class: int size: 32 property-mappings: - type: clock name: my_clock property: value timestamp_end: class: int size: 32 property-mappings: - type: clock name: my_other_clock property: value events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-tb-wrong-pm.yaml000066400000000000000000000032241317147435100235670ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 timestamp_begin: class: int size: 16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-tb-wrong-signed.yaml000066400000000000000000000034471317147435100244330ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 timestamp_begin: class: int size: 16 signed: true property-mappings: - type: clock name: my_clock property: value events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-tb-yes-te-no.yaml000066400000000000000000000034161317147435100236440ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 timestamp_begin: class: int size: 32 property-mappings: - type: clock name: my_clock property: value events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-te-not-int.yaml000066400000000000000000000031451317147435100234160ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 timestamp_end: class: string events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-te-wrong-pm.yaml000066400000000000000000000032221317147435100235700ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 timestamp_end: class: int size: 16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-te-wrong-signed.yaml000066400000000000000000000034451317147435100244340ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 timestamp_end: class: int size: 16 signed: true property-mappings: - type: clock name: my_clock property: value events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/pct-te-yes-tb-no.yaml000066400000000000000000000034141317147435100236420ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 timestamp_end: class: int size: 32 property-mappings: - type: clock name: my_clock property: value events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/stream/unknown-prop.yaml000066400000000000000000000031061317147435100233060ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le streams: my_stream: unknown: true packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/000077500000000000000000000000001317147435100175505ustar00rootroot00000000000000barectf-2.3.0/tests/config/fail/trace/bo-invalid-type.yaml000066400000000000000000000030621317147435100234400ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: 23 streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/bo-invalid.yaml000066400000000000000000000030621317147435100224610ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: ze streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/bo-no.yaml000066400000000000000000000030421317147435100214450ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: {} streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/fail.bats000066400000000000000000000076151317147435100213470ustar00rootroot00000000000000#!/usr/bin/env bats # 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. load ../../common @test 'unknown property in trace object makes barectf fail' { barectf_config_check_fail unknown-prop.yaml } @test 'wrong "byte-order" property type in trace object makes barectf fail' { barectf_config_check_fail bo-invalid-type.yaml } @test 'no "byte-order" property in trace object makes barectf fail' { barectf_config_check_fail bo-no.yaml } @test 'invalid "byte-order" property in trace object makes barectf fail' { barectf_config_check_fail bo-invalid.yaml } @test 'invalid "packet-header-type" property field type (not a structure) in trace object makes barectf fail' { barectf_config_check_fail ph-not-struct.yaml } @test 'wrong "uuid" property type in trace object makes barectf fail' { barectf_config_check_fail uuid-invalid-type.yaml } @test 'invalid "uuid" property (invalid UUID format) in trace object makes barectf fail' { barectf_config_check_fail uuid-invalid-uuid.yaml } @test 'invalid "magic" field type (not an integer) in packet header type makes barectf fail' { barectf_config_check_fail ph-magic-not-int.yaml } @test 'invalid "magic" field type (wrong integer size) in packet header type makes barectf fail' { barectf_config_check_fail ph-magic-wrong-size.yaml } @test 'invalid "magic" field type (signed) in packet header type makes barectf fail' { barectf_config_check_fail ph-magic-wrong-signed.yaml } @test 'invalid "stream_id" field type (not an integer) in packet header type makes barectf fail' { barectf_config_check_fail ph-streamid-not-int.yaml } @test 'invalid "stream_id" field type (signed) in packet header type makes barectf fail' { barectf_config_check_fail ph-streamid-wrong-signed.yaml } @test '"stream_id" field type size too small for the number of trace streams in packet header type makes barectf fail' { barectf_config_check_fail ph-streamid-too-small.yaml } @test 'invalid "uuid" field type (not an array) in packet header type makes barectf fail' { barectf_config_check_fail ph-uuid-not-array.yaml } @test 'invalid "uuid" field type (wrong array length) in packet header type makes barectf fail' { barectf_config_check_fail ph-uuid-wrong-length.yaml } @test 'invalid "uuid" field type (element type is not an integer) in packet header type makes barectf fail' { barectf_config_check_fail ph-uuid-et-not-int.yaml } @test 'invalid "uuid" field type (wrong element type size) in packet header type makes barectf fail' { barectf_config_check_fail ph-uuid-et-wrong-size.yaml } @test 'invalid "uuid" field type (element type is signed) in packet header type makes barectf fail' { barectf_config_check_fail ph-uuid-et-wrong-signed.yaml } @test 'invalid "uuid" field type (wrong element type alignment) in packet header type makes barectf fail' { barectf_config_check_fail ph-uuid-et-wrong-align.yaml } barectf-2.3.0/tests/config/fail/trace/ph-magic-not-int.yaml000066400000000000000000000032231317147435100235070ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: be packet-header-type: class: struct fields: magic: class: string streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/ph-magic-wrong-signed.yaml000066400000000000000000000032721317147435100245260ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: be packet-header-type: class: struct fields: magic: class: int size: 32 signed: true streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/ph-magic-wrong-size.yaml000066400000000000000000000032431317147435100242250ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: be packet-header-type: class: struct fields: magic: class: int size: 16 streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/ph-not-struct.yaml000066400000000000000000000031521317147435100231640ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: be packet-header-type: class: int size: 32 streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/ph-streamid-not-int.yaml000066400000000000000000000032271317147435100242430ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: be packet-header-type: class: struct fields: stream_id: class: string streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/ph-streamid-too-small.yaml000066400000000000000000000064011317147435100245570ustar00rootroot00000000000000# 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. version: '2.1' metadata: clocks: my_clock: {} type-aliases: uint16: class: int size: 16 trace: byte-order: le packet-header-type: class: struct min-align: 8 fields: stream_id: class: int size: 2 streams: my_stream: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 event-header-type: class: struct min-align: 8 fields: id: uint16 events: my_event: payload-type: class: struct fields: my_field: uint16 my_stream2: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 event-header-type: class: struct min-align: 8 fields: id: uint16 events: my_event: payload-type: class: struct fields: my_field: uint16 my_stream3: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 event-header-type: class: struct min-align: 8 fields: id: uint16 events: my_event: payload-type: class: struct fields: my_field: uint16 my_stream4: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 event-header-type: class: struct min-align: 8 fields: id: uint16 events: my_event: payload-type: class: struct fields: my_field: uint16 my_stream5: packet-context-type: class: struct fields: content_size: uint16 packet_size: uint16 event-header-type: class: struct min-align: 8 fields: id: uint16 events: my_event: payload-type: class: struct fields: my_field: uint16 barectf-2.3.0/tests/config/fail/trace/ph-streamid-wrong-signed.yaml000066400000000000000000000032761317147435100252620ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: be packet-header-type: class: struct fields: stream_id: class: int size: 16 signed: true streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/ph-uuid-et-not-int.yaml000066400000000000000000000033471317147435100240120ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: uuid: auto byte-order: be packet-header-type: class: struct fields: uuid: class: array length: 16 element-type: class: string streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/ph-uuid-et-wrong-align.yaml000066400000000000000000000034161317147435100246430ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: uuid: auto byte-order: be packet-header-type: class: struct fields: uuid: class: array length: 16 element-type: class: int size: 8 align: 16 streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/ph-uuid-et-wrong-signed.yaml000066400000000000000000000034211317147435100250160ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: uuid: auto byte-order: be packet-header-type: class: struct fields: uuid: class: array length: 16 element-type: class: int size: 8 signed: true streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/ph-uuid-et-wrong-size.yaml000066400000000000000000000033701317147435100245220ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: uuid: auto byte-order: be packet-header-type: class: struct fields: uuid: class: array length: 16 element-type: class: int size: 4 streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/ph-uuid-not-array.yaml000066400000000000000000000032201317147435100237160ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: uuid: auto byte-order: be packet-header-type: class: struct fields: uuid: uint16 streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/ph-uuid-wrong-length.yaml000066400000000000000000000033701317147435100244230ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: uuid: auto byte-order: be packet-header-type: class: struct fields: uuid: class: array length: 17 element-type: class: int size: 8 streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/unknown-prop.yaml000066400000000000000000000031051317147435100231100ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: be unknown: false streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/uuid-invalid-type.yaml000066400000000000000000000030771317147435100240140ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: uuid: 12 byte-order: be streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/trace/uuid-invalid-uuid.yaml000066400000000000000000000031061317147435100237720ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: uuid: something byte-order: be streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/type-enum/000077500000000000000000000000001317147435100203755ustar00rootroot00000000000000barectf-2.3.0/tests/config/fail/type-enum/fail.bats000066400000000000000000000057301317147435100221700ustar00rootroot00000000000000#!/usr/bin/env bats # 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. load ../../common @test 'unknown property in enum type object makes barectf fail' { barectf_config_check_fail unknown-prop.yaml } @test 'no "value-type" property in enum type object makes barectf fail' { barectf_config_check_fail vt-no.yaml } @test 'wrong "value-type" property type in enum type object makes barectf fail' { barectf_config_check_fail vt-invalid-type.yaml } @test 'no "members" property in enum type object makes barectf fail' { barectf_config_check_fail members-no.yaml } @test 'wrong "members" property type in enum type object makes barectf fail' { barectf_config_check_fail members-invalid-type.yaml } @test 'empty "members" property in enum type object makes barectf fail' { barectf_config_check_fail members-empty.yaml } @test 'wrong "members" property element type in enum type object makes barectf fail' { barectf_config_check_fail members-el-invalid-type.yaml } @test 'unknown property in enum type member object makes barectf fail' { barectf_config_check_fail members-el-member-unknown-prop.yaml } @test 'wrong "label" property type in enum type member object makes barectf fail' { barectf_config_check_fail members-el-member-label-invalid-type.yaml } @test 'wrong "value" property type in enum type member object makes barectf fail' { barectf_config_check_fail members-el-member-value-invalid-type.yaml } @test '"value" property outside the unsigned value type range in enum type member object makes barectf fail' { barectf_config_check_fail members-el-member-value-outside-range-unsigned.yaml } @test '"value" property outside the signed value type range in enum type member object makes barectf fail' { barectf_config_check_fail members-el-member-value-outside-range-signed.yaml } @test 'overlapping members in enum type object makes barectf fail' { barectf_config_check_fail members-overlap.yaml } barectf-2.3.0/tests/config/fail/type-enum/members-el-invalid-type.yaml000066400000000000000000000030271317147435100257160ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: enum value-type: class: int size: 8 members: - HELLO - 23 - ZOOM barectf-2.3.0/tests/config/fail/type-enum/members-el-member-label-invalid-type.yaml000066400000000000000000000030731317147435100302410ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: enum value-type: class: int size: 8 members: - HELLO - label: 65 value: 6 - ZOOM barectf-2.3.0/tests/config/fail/type-enum/members-el-member-unknown-prop.yaml000066400000000000000000000031361317147435100272340ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: enum value-type: class: int size: 8 members: - HELLO - label: six value: 6 unknown: true - ZOOM barectf-2.3.0/tests/config/fail/type-enum/members-el-member-value-invalid-type.yaml000066400000000000000000000031011317147435100302660ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: enum value-type: class: int size: 8 members: - HELLO - label: label value: meow - ZOOM barectf-2.3.0/tests/config/fail/type-enum/members-el-member-value-outside-range-signed.yaml000066400000000000000000000031401317147435100317010ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: enum value-type: class: int size: 8 signed: true members: - HELLO - label: label value: -129 - ZOOM barectf-2.3.0/tests/config/fail/type-enum/members-el-member-value-outside-range-unsigned.yaml000066400000000000000000000031001317147435100322400ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: enum value-type: class: int size: 8 members: - HELLO - label: label value: 256 - ZOOM barectf-2.3.0/tests/config/fail/type-enum/members-empty.yaml000066400000000000000000000027201317147435100240500ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: enum value-type: class: int size: 8 members: [] barectf-2.3.0/tests/config/fail/type-enum/members-invalid-type.yaml000066400000000000000000000027241317147435100253230ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: enum value-type: class: int size: 8 members: string barectf-2.3.0/tests/config/fail/type-enum/members-no.yaml000066400000000000000000000026641317147435100233350ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: enum value-type: class: int size: 8 barectf-2.3.0/tests/config/fail/type-enum/members-overlap.yaml000066400000000000000000000031351317147435100243630ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: enum value-type: class: int size: 8 signed: true members: - HELLO - ZOOM - label: MAGOG value: 0 barectf-2.3.0/tests/config/fail/type-enum/unknown-prop.yaml000066400000000000000000000030061317147435100237350ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: enum value-type: class: int size: 8 members: - HELLO unknown: false barectf-2.3.0/tests/config/fail/type-enum/vt-invalid-type.yaml000066400000000000000000000026631317147435100243240ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: enum value-type: 23 members: - HELLO barectf-2.3.0/tests/config/fail/type-enum/vt-no.yaml000066400000000000000000000026241317147435100223300ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: enum members: - HELLO barectf-2.3.0/tests/config/fail/type-float/000077500000000000000000000000001317147435100205365ustar00rootroot00000000000000barectf-2.3.0/tests/config/fail/type-float/align-0.yaml000066400000000000000000000027051317147435100226550ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: float size: exp: 8 mant: 24 align: 0 barectf-2.3.0/tests/config/fail/type-float/align-3.yaml000066400000000000000000000027051317147435100226600ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: float size: exp: 8 mant: 24 align: 3 barectf-2.3.0/tests/config/fail/type-float/align-invalid-type.yaml000066400000000000000000000027121317147435100251210ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: float size: exp: 8 mant: 24 align: string barectf-2.3.0/tests/config/fail/type-float/bo-invalid-type.yaml000066400000000000000000000027131317147435100244300ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: float size: exp: 8 mant: 24 byte-order: 17 barectf-2.3.0/tests/config/fail/type-float/bo-invalid.yaml000066400000000000000000000027131317147435100234510ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: float size: exp: 8 mant: 24 byte-order: ze barectf-2.3.0/tests/config/fail/type-float/fail.bats000066400000000000000000000053171317147435100223320ustar00rootroot00000000000000#!/usr/bin/env bats # 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. load ../../common @test 'unknown property in float type object makes barectf fail' { barectf_config_check_fail unknown-prop.yaml } @test 'no "size" property in float type object makes barectf fail' { barectf_config_check_fail size-no.yaml } @test 'wrong "size" property type in float type object makes barectf fail' { barectf_config_check_fail size-invalid-type.yaml } @test 'unknown property in float type object "size" property makes barectf fail' { barectf_config_check_fail size-unknown-prop.yaml } @test 'no "exp" property in float type object "size" property makes barectf fail' { barectf_config_check_fail size-exp-no.yaml } @test 'no "mant" property in float type object "size" property makes barectf fail' { barectf_config_check_fail size-mant-no.yaml } @test 'sum of "mant" and "exp" properties of float type size object not a multiple of 32 property makes barectf fail' { barectf_config_check_fail size-exp-mant-wrong-sum.yaml } @test 'wrong "align" property type in float type object makes barectf fail' { barectf_config_check_fail align-invalid-type.yaml } @test 'invalid "align" property (0) in float type object makes barectf fail' { barectf_config_check_fail align-0.yaml } @test 'invalid "align" property (3) in float type object makes barectf fail' { barectf_config_check_fail align-3.yaml } @test 'wrong "byte-order" property type in float type object makes barectf fail' { barectf_config_check_fail bo-invalid-type.yaml } @test 'invalid "byte-order" property in float type object makes barectf fail' { barectf_config_check_fail bo-invalid.yaml } barectf-2.3.0/tests/config/fail/type-float/size-exp-mant-wrong-sum.yaml000066400000000000000000000026541317147435100260660ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: float size: exp: 5 mant: 21 barectf-2.3.0/tests/config/fail/type-float/size-exp-no.yaml000066400000000000000000000026231317147435100236030ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: float size: mant: 24 barectf-2.3.0/tests/config/fail/type-float/size-invalid-type.yaml000066400000000000000000000025771317147435100250120ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: float size: string barectf-2.3.0/tests/config/fail/type-float/size-mant-no.yaml000066400000000000000000000026211317147435100237440ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: float size: exp: 8 barectf-2.3.0/tests/config/fail/type-float/size-no.yaml000066400000000000000000000025421317147435100230110ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: float barectf-2.3.0/tests/config/fail/type-float/size-unknown-prop.yaml000066400000000000000000000027151317147435100250540ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: float size: exp: 8 mant: 24 unknown: false barectf-2.3.0/tests/config/fail/type-float/unknown-prop.yaml000066400000000000000000000027131317147435100241020ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: float size: exp: 8 mant: 24 unknown: false barectf-2.3.0/tests/config/fail/type-int/000077500000000000000000000000001317147435100202235ustar00rootroot00000000000000barectf-2.3.0/tests/config/fail/type-int/align-0.yaml000066400000000000000000000026221317147435100223400ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int size: 32 align: 0 barectf-2.3.0/tests/config/fail/type-int/align-3.yaml000066400000000000000000000026221317147435100223430ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int size: 32 align: 3 barectf-2.3.0/tests/config/fail/type-int/align-invalid-type.yaml000066400000000000000000000025761317147435100246160ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int align: string barectf-2.3.0/tests/config/fail/type-int/base-invalid-type.yaml000066400000000000000000000026241317147435100244300ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 base: 17.34 barectf-2.3.0/tests/config/fail/type-int/base-invalid.yaml000066400000000000000000000026251317147435100234520ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int size: 32 base: inval barectf-2.3.0/tests/config/fail/type-int/bo-invalid-type.yaml000066400000000000000000000026021317147435100241120ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int byte-order: 17.34 barectf-2.3.0/tests/config/fail/type-int/bo-invalid.yaml000066400000000000000000000026301317147435100231340ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int size: 32 byte-order: ze barectf-2.3.0/tests/config/fail/type-int/fail.bats000066400000000000000000000065131317147435100220160ustar00rootroot00000000000000#!/usr/bin/env bats # 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. load ../../common @test 'unknown property in int type object makes barectf fail' { barectf_config_check_fail unknown-prop.yaml } @test 'no "size" property in int type object makes barectf fail' { barectf_config_check_fail size-no.yaml } @test 'wrong "size" property type in int type object makes barectf fail' { barectf_config_check_fail size-invalid-type.yaml } @test 'invalid "size" property (0) in int type object makes barectf fail' { barectf_config_check_fail size-0.yaml } @test 'invalid "size" property (65) in int type object makes barectf fail' { barectf_config_check_fail size-65.yaml } @test 'wrong "signed" property type in int type object makes barectf fail' { barectf_config_check_fail signed-invalid-type.yaml } @test 'wrong "align" property type in int type object makes barectf fail' { barectf_config_check_fail align-invalid-type.yaml } @test 'invalid "align" property (0) in int type object makes barectf fail' { barectf_config_check_fail align-0.yaml } @test 'invalid "align" property (3) in int type object makes barectf fail' { barectf_config_check_fail align-3.yaml } @test 'wrong "base" property type in int type object makes barectf fail' { barectf_config_check_fail base-invalid-type.yaml } @test 'invalid "base" property in int type object makes barectf fail' { barectf_config_check_fail base-invalid.yaml } @test 'wrong "byte-order" property type in int type object makes barectf fail' { barectf_config_check_fail bo-invalid-type.yaml } @test 'invalid "byte-order" property in int type object makes barectf fail' { barectf_config_check_fail bo-invalid.yaml } @test 'wrong "property-mappings" property type in int type object makes barectf fail' { barectf_config_check_fail pm-invalid-type.yaml } @test 'invalid "property-mappings" property in int type object makes barectf fail' { barectf_config_check_fail pm-unknown-clock.yaml } @test 'invalid "property-mappings" property (invalid "type" property) in int type object makes barectf fail' { barectf_config_check_fail pm-type-invalid.yaml } @test 'invalid "property-mappings" property (invalid "property" property) in int type object makes barectf fail' { barectf_config_check_fail pm-property-invalid.yaml } barectf-2.3.0/tests/config/fail/type-int/pm-invalid-type.yaml000066400000000000000000000026111317147435100241260ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int property-mappings: hello barectf-2.3.0/tests/config/fail/type-int/pm-property-invalid.yaml000066400000000000000000000030341317147435100250310ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le clocks: my_clock: {} streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 property-mappings: - type: clock name: my_clock property: type barectf-2.3.0/tests/config/fail/type-int/pm-type-invalid.yaml000066400000000000000000000030321317147435100241240ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le clocks: my_clock: {} streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 property-mappings: - type: stream name: zala property: value barectf-2.3.0/tests/config/fail/type-int/pm-unknown-clock.yaml000066400000000000000000000030311317147435100243060ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le clocks: my_clock: {} streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 property-mappings: - type: clock name: zala property: value barectf-2.3.0/tests/config/fail/type-int/signed-invalid-type.yaml000066400000000000000000000025771317147435100247760ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int signed: string barectf-2.3.0/tests/config/fail/type-int/size-0.yaml000066400000000000000000000025701317147435100222220ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int size: 0 barectf-2.3.0/tests/config/fail/type-int/size-65.yaml000066400000000000000000000026221317147435100223130ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int size: 65 align: 8 barectf-2.3.0/tests/config/fail/type-int/size-invalid-type.yaml000066400000000000000000000025751317147435100244750ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int size: string barectf-2.3.0/tests/config/fail/type-int/size-no.yaml000066400000000000000000000025401317147435100224740ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int barectf-2.3.0/tests/config/fail/type-int/unknown-prop.yaml000066400000000000000000000026271317147435100235730ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 unknown: false barectf-2.3.0/tests/config/fail/type-string/000077500000000000000000000000001317147435100207375ustar00rootroot00000000000000barectf-2.3.0/tests/config/fail/type-string/fail.bats000066400000000000000000000024241317147435100225270ustar00rootroot00000000000000#!/usr/bin/env bats # 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. load ../../common @test 'unknown property in string type object makes barectf fail' { barectf_config_check_fail unknown-prop.yaml } barectf-2.3.0/tests/config/fail/type-string/unknown-prop.yaml000066400000000000000000000026021317147435100243000ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: string unknown: false barectf-2.3.0/tests/config/fail/type-struct/000077500000000000000000000000001317147435100207555ustar00rootroot00000000000000barectf-2.3.0/tests/config/fail/type-struct/fail.bats000066400000000000000000000037161317147435100225520ustar00rootroot00000000000000#!/usr/bin/env bats # 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. load ../../common @test 'unknown property in struct type object makes barectf fail' { barectf_config_check_fail unknown-prop.yaml } @test 'wrong "fields" property type in struct type object makes barectf fail' { barectf_config_check_fail fields-invalid-type.yaml } @test 'invalid field in "fields" property (invalid C identifier) in struct type object makes barectf fail' { barectf_config_check_fail fields-field-invalid-identifier.yaml } @test 'wrong "min-align" property type in struct type object makes barectf fail' { barectf_config_check_fail ma-invalid-type.yaml } @test 'invalid "min-align" property (0) in struct type object makes barectf fail' { barectf_config_check_fail ma-0.yaml } @test 'invalid "min-align" property (3) in struct type object makes barectf fail' { barectf_config_check_fail ma-3.yaml } barectf-2.3.0/tests/config/fail/type-struct/fields-field-invalid-identifier.yaml000066400000000000000000000025711317147435100277410ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: 'a field': class: int size: 1 barectf-2.3.0/tests/config/fail/type-struct/fields-invalid-type.yaml000066400000000000000000000024601317147435100255140ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: 23 barectf-2.3.0/tests/config/fail/type-struct/ma-0.yaml000066400000000000000000000024621317147435100223770ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct min-align: 0 barectf-2.3.0/tests/config/fail/type-struct/ma-3.yaml000066400000000000000000000024621317147435100224020ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct min-align: 3 barectf-2.3.0/tests/config/fail/type-struct/ma-invalid-type.yaml000066400000000000000000000024641317147435100246470ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct min-align: yes barectf-2.3.0/tests/config/fail/type-struct/unknown-prop.yaml000066400000000000000000000026221317147435100243200ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct unknown: true fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/type/000077500000000000000000000000001317147435100174335ustar00rootroot00000000000000barectf-2.3.0/tests/config/fail/type/fail.bats000066400000000000000000000031461317147435100212250ustar00rootroot00000000000000#!/usr/bin/env bats # 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. load ../../common @test 'type inheriting an unknown type alias makes barectf fail' { barectf_config_check_fail inherit-unknown.yaml } @test 'type inheriting a type alias defined after makes barectf fail' { barectf_config_check_fail inherit-forward.yaml } @test 'wrong type property type makes barectf fail' { barectf_config_check_fail invalid-type.yaml } @test 'no "class" property in type object makes barectf fail' { barectf_config_check_fail no-class.yaml } barectf-2.3.0/tests/config/fail/type/inherit-forward.yaml000066400000000000000000000027231317147435100234270ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: $inherit: meow size: 16 meow: class: int trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/type/inherit-unknown.yaml000066400000000000000000000026731317147435100234660ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: $inherit: unknown size: 16 trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/type/invalid-type.yaml000066400000000000000000000030251317147435100227240ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: an-int: 23 trace: byte-order: le streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/fail/type/no-class.yaml000066400000000000000000000025351317147435100220430ustar00rootroot00000000000000# 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. version: '2.1' metadata: trace: byte-order: le streams: my_stream: events: my_event: payload-type: class: struct fields: my_field: size: 8 barectf-2.3.0/tests/config/fail/yaml/000077500000000000000000000000001317147435100174145ustar00rootroot00000000000000barectf-2.3.0/tests/config/fail/yaml/fail.bats000066400000000000000000000023731317147435100212070ustar00rootroot00000000000000#!/usr/bin/env bats # 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. load ../../common @test 'invalid YAML input makes barectf fail' { barectf_config_check_fail invalid.yaml } barectf-2.3.0/tests/config/fail/yaml/invalid.yaml000066400000000000000000000030761317147435100217340ustar00rootroot00000000000000# 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. version: '2.1' metadata: type-aliases: uint16: class: int size: 16 trace: byte-order: le: - 23 streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 barectf-2.3.0/tests/config/pass/000077500000000000000000000000001317147435100165055ustar00rootroot00000000000000barectf-2.3.0/tests/config/pass/everything/000077500000000000000000000000001317147435100206715ustar00rootroot00000000000000barectf-2.3.0/tests/config/pass/everything/config.yaml000066400000000000000000000056271317147435100230340ustar00rootroot00000000000000# 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. version: '2.2' prefix: bctf_ options: gen-prefix-def: true gen-default-stream-def: true metadata: $include: - inc-metadata.yaml - stdmisc.yaml - lttng-ust-log-levels.yaml type-aliases: my-clock-int: $inherit: uint32 property-mappings: - type: clock name: some_clock property: value my-special-int: size: 19 base: hex $log-levels: couch: 0755 trace: $include: inc-trace.yaml byte-order: be clocks: some_clock: $include: inc-clock.yaml description: this is my favorite clock offset: cycles: 91827439187 absolute: null streams: my_stream: packet-context-type: class: struct fields: packet_size: uint16 content_size: uint16 timestamp_begin: my-clock-int timestamp_end: my-clock-int events: my_event: payload-type: class: struct fields: my_field: class: int size: 8 my_other_stream: $include: inc-stream.yaml packet-context-type: class: struct fields: packet_size: uint32 content_size: uint32 events_discarded: uint16 event-header-type: class: struct fields: id: uint8 timestamp: my-clock-int events: my_event: $include: inc-event.yaml context-type: null payload-type: class: struct fields: my_field: class: int size: 8 oh_henry_event: payload-type: class: struct fields: s1: string s2: string s3: string s4: string barectf-2.3.0/tests/config/pass/everything/inc-clock.yaml000066400000000000000000000023121317147435100234150ustar00rootroot00000000000000# 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. freq: 123456789 offset: seconds: 18 absolute: true $return-ctype: unsigned long barectf-2.3.0/tests/config/pass/everything/inc-event.yaml000066400000000000000000000023021317147435100234420ustar00rootroot00000000000000# 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. log-level: WARNING context-type: class: struct fields: fff: float barectf-2.3.0/tests/config/pass/everything/inc-metadata.yaml000066400000000000000000000033131317147435100241040ustar00rootroot00000000000000# 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: - stdint.yaml - stdfloat.yaml type-aliases: my-special-int: class: int size: 23 align: 2 struct32: class: struct min-align: 32 def-payload-type: $inherit: struct32 fields: haha: float hihi: uint32 huhu: uint16 hoho: double streams: my_other_stream: events: this_event: payload-type: class: struct fields: special: my-special-int more_special: $inherit: my-special-int align: 32 $log-levels: couch: 23 tv: 199 thread: 0x28aff barectf-2.3.0/tests/config/pass/everything/inc-stream.yaml000066400000000000000000000026321317147435100236220ustar00rootroot00000000000000# 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. event-context-type: class: struct fields: i: int32 f: float d: double s: string m: ctf-magic events: evev: payload-type: def-payload-type context_no_payload: context-type: class: struct fields: str: string no_context_no_payload: {} barectf-2.3.0/tests/config/pass/everything/inc-trace.yaml000066400000000000000000000023071317147435100234240ustar00rootroot00000000000000# 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: trace-basic.yaml packet-header-type: fields: soy_sauce: uint64 barectf-2.3.0/tests/config/pass/everything/pass.bats000066400000000000000000000045301317147435100225140ustar00rootroot00000000000000#!/usr/bin/env bats # 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. load ../../common @test 'config file using all features makes barectf pass' { barectf_config_check_success config.yaml [ -f metadata ] [ -f bctf.c ] [ -f bctf.h ] [ -f bctf-bitfield.h ] # test should be more extensive than that, but it's a start $CC -c bctf.c nm bctf.o | grep bctf_init nm bctf.o | grep bctf_my_other_stream_close_packet nm bctf.o | grep bctf_my_other_stream_open_packet nm bctf.o | grep bctf_my_other_stream_trace_context_no_payload nm bctf.o | grep bctf_my_other_stream_trace_evev nm bctf.o | grep bctf_my_other_stream_trace_my_event nm bctf.o | grep bctf_my_other_stream_trace_no_context_no_payload nm bctf.o | grep bctf_my_other_stream_trace_oh_henry_event nm bctf.o | grep bctf_my_other_stream_trace_this_event nm bctf.o | grep bctf_my_stream_close_packet nm bctf.o | grep bctf_my_stream_open_packet nm bctf.o | grep bctf_my_stream_trace_my_event nm bctf.o | grep bctf_packet_buf nm bctf.o | grep bctf_packet_buf_size nm bctf.o | grep bctf_packet_events_discarded nm bctf.o | grep bctf_packet_is_empty nm bctf.o | grep bctf_packet_is_full nm bctf.o | grep bctf_packet_is_open nm bctf.o | grep bctf_packet_set_buf nm bctf.o | grep bctf_packet_size } barectf-2.3.0/tests/test.bash000077500000000000000000000034551317147435100161220ustar00rootroot00000000000000#!/usr/bin/env bash # 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. test_dirs=( "config/fail/clock" "config/fail/config" "config/fail/event" "config/fail/include" "config/fail/metadata" "config/fail/stream" "config/fail/trace" "config/fail/type" "config/fail/type-enum" "config/fail/type-float" "config/fail/type-int" "config/fail/type-string" "config/fail/type-struct" "config/fail/yaml" "config/pass/everything" ) bats_bin="$(pwd)/bats/bin/bats" rc=0 if [ -z "${CC+x}" ]; then # default to gcc export CC=gcc fi for d in "${test_dirs[@]}"; do pushd "$d" >/dev/null $bats_bin "${@}" . if [ $? -ne 0 ]; then # latch error, but continue other tests rc=1 fi popd >/dev/null done exit $rc barectf-2.3.0/tox.ini000066400000000000000000000015761317147435100144540ustar00rootroot00000000000000[tox] minversion = 1.9 envlist = tests skipsdist = True toxworkdir = {env:TOXWORKDIR:.tox} [testenv] setenv = PYTHONPATH = {env:PYTHONPATH:} deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt usedevelop = true whitelist_externals = bash [testenv:tests] changedir = tests commands = bash ./test.bash -t [testenv:pep8] commands = flake8 [flake8] # E123, E125 skipped as they are invalid PEP-8. # also ignore E501 because barectf has very long lines show-source = True ignore = E123,E125,E501 builtins = _ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build [testenv:pylint-errors] deps = pylint >= 1.6 commands = pylint -f colorized -E barectf [testenv:pylint-warnings] deps = pylint >= 1.6 commands = pylint -f colorized -d all -e W -r n barectf [testenv:pylint-full] deps = pylint >= 1.6 commands = pylint -f colorized --disable=all -e R,E,W barectf