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 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`.
--- /dev/null
+Copyright (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.
--- /dev/null
+../libexec/bats
\ No newline at end of file
--- /dev/null
+#!/usr/bin/env bash
+set -e
+
+version() {
+ echo "Bats 0.4.0"
+}
+
+usage() {
+ version
+ echo "Usage: bats [-c] [-p | -t] <test> [<test> ...]"
+}
+
+help() {
+ usage
+ echo
+ echo " <test> 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"
--- /dev/null
+#!/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"
--- /dev/null
+#!/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 <filename>" >&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
--- /dev/null
+#!/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
--- /dev/null
+#!/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<length; i++)); do
+ char="${name:$i:1}"
+ if [ "$char" = " " ]; then
+ result+="_"
+ elif [[ "$char" =~ [[:alnum:]] ]]; then
+ result+="$char"
+ else
+ result+="$(printf -- "-%02x" \'"$char")"
+ fi
+ done
+ fi
+
+ echo "$result"
+}
+
+tests=()
+index=0
+pattern='^ *@test *([^ ].*) *\{ *(.*)$'
+
+while IFS= read -r line; do
+ let index+=1
+ if [[ "$line" =~ $pattern ]]; then
+ quoted_name="${BASH_REMATCH[1]}"
+ body="${BASH_REMATCH[2]}"
+ name="$(eval echo "$quoted_name")"
+ encoded_name="$(encode_name "$name")"
+ tests["${#tests[@]}"]="$encoded_name"
+ echo "${encoded_name}() { bats_test_begin ${quoted_name} ${index}; ${body}"
+ else
+ printf "%s\n" "$line"
+ fi
+done
+
+for test_name in "${tests[@]}"; do
+ echo "bats_test_function ${test_name}"
+done
--- /dev/null
+barectf_assert_file_exists() {
+ pushd "$BATS_TEST_DIRNAME"
+
+ if [ ! -f "$1" ]; then
+ echo "FATAL: "$1" does not exist" 1>&2
+ return 1
+ fi
+
+ run barectf "$1"
+ local rc=$?
+ popd
+ return $rc
+}
--- /dev/null
+fail/clock/barectf*.*
+fail/clock/metadata
+fail/config/barectf*.*
+fail/config/metadata
+fail/event/barectf*.*
+fail/event/metadata
+fail/include/barectf*.*
+fail/include/metadata
+fail/metadata/barectf*.*
+fail/metadata/metadata
+fail/stream/barectf*.*
+fail/stream/metadata
+fail/trace/barectf*.*
+fail/trace/metadata
+fail/type/barectf*.*
+fail/type/metadata
+fail/type-enum/barectf*.*
+fail/type-enum/metadata
+fail/type-float/barectf*.*
+fail/type-float/metadata
+fail/type-int/barectf*.*
+fail/type-int/metadata
+fail/type-string/barectf*.*
+fail/type-string/metadata
+fail/type-struct/barectf*.*
+fail/type-struct/metadata
+fail/yaml/barectf*.*
+fail/yaml/metadata
+pass/everything/*.c
+pass/everything/*.h
+pass/everything/metadata
--- /dev/null
+barectf_config_check_fail() {
+ if [ $status -eq 0 ]; then
+ echo "Fail: exit code is 0" 1>&2
+ return 1
+ fi
+
+ pushd "$BATS_TEST_DIRNAME"
+ local find_output="$(find -iname '*.c' -o -iname '*.h' -o -iname metadata)"
+ popd
+
+ 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
+}
--- /dev/null
+#ifndef _BARECTF_BITFIELD_H
+#define _BARECTF_BITFIELD_H
+
+/*
+ * BabelTrace
+ *
+ * Bitfields read/write functions.
+ *
+ * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdint.h> /* C99 5.2.4.2 Numerical limits */
+#include <limits.h>
+
+#define BARECTF_BYTE_ORDER LITTLE_ENDIAN
+
+/* We can't shift a int from 32 bit, >> 32 and << 32 on int is undefined */
+#define _barectf_bt_piecewise_rshift(_v, _shift) \
+__extension__ ({ \
+ __typeof__(_v) ___v = (_v); \
+ __typeof__(_shift) ___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; \
+})
+
+#define _barectf_bt_piecewise_lshift(_v, _shift) \
+__extension__ ({ \
+ __typeof__(_v) ___v = (_v); \
+ __typeof__(_shift) ___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; \
+})
+
+#define _barectf_bt_is_signed_type(type) ((type) -1 < (type) 0)
+
+#define _barectf_bt_unsigned_cast(type, v) \
+__extension__ ({ \
+ (sizeof(v) < sizeof(type)) ? \
+ ((type) (v)) & (~(~(type) 0 << (sizeof(v) * CHAR_BIT))) : \
+ (type) (v); \
+})
+
+/*
+ * barectf_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 _barectf_bt_bitfield_write_le(_ptr, type, _start, _length, _v) \
+do { \
+ __typeof__(_v) __v = (_v); \
+ type *__ptr = (void *) (_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 &= ~((~(__typeof__(__v)) 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; \
+ __v = _barectf_bt_piecewise_rshift(__v, ts - cshift); \
+ __start += ts - cshift; \
+ this_unit++; \
+ } \
+ for (; this_unit < end_unit - 1; this_unit++) { \
+ __ptr[this_unit] = (type) __v; \
+ __v = _barectf_bt_piecewise_rshift(__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 _barectf_bt_bitfield_write_be(_ptr, type, _start, _length, _v) \
+do { \
+ __typeof__(_v) __v = (_v); \
+ type *__ptr = (void *) (_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 &= ~((~(__typeof__(__v)) 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; \
+ __v = _barectf_bt_piecewise_rshift(__v, cshift); \
+ end -= cshift; \
+ this_unit--; \
+ } \
+ for (; (long) this_unit >= (long) start_unit + 1; this_unit--) { \
+ __ptr[this_unit] = (type) __v; \
+ __v = _barectf_bt_piecewise_rshift(__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)
+
+/*
+ * barectf_bt_bitfield_write_le - write integer to a bitfield in little endian
+ * barectf_bt_bitfield_write_be - write integer to a bitfield in big endian
+ */
+
+#if (BARECTF_BYTE_ORDER == LITTLE_ENDIAN)
+
+#define barectf_bt_bitfield_write_le(ptr, type, _start, _length, _v) \
+ _barectf_bt_bitfield_write_le(ptr, type, _start, _length, _v)
+
+#define barectf_bt_bitfield_write_be(ptr, type, _start, _length, _v) \
+ _barectf_bt_bitfield_write_be(ptr, unsigned char, _start, _length, _v)
+
+#elif (BARECTF_BYTE_ORDER == BIG_ENDIAN)
+
+#define barectf_bt_bitfield_write_le(ptr, type, _start, _length, _v) \
+ _barectf_bt_bitfield_write_le(ptr, unsigned char, _start, _length, _v)
+
+#define barectf_bt_bitfield_write_be(ptr, type, _start, _length, _v) \
+ _barectf_bt_bitfield_write_be(ptr, type, _start, _length, _v)
+
+#else /* (BARECTF_BYTE_ORDER == PDP_ENDIAN) */
+
+#error "Byte order not supported"
+
+#endif
+
+#endif /* _BARECTF_BITFIELD_H */
--- /dev/null
+/*
+ * The following C code was generated by barectf 2.1.0-dev
+ * on 2016-03-15T21:29:16.070651.
+ *
+ * For more details, see <https://github.com/efficios/barectf>.
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include <assert.h>
+
+#include "barectf.h"
+
+#define _ALIGN(_at, _align) \
+ do { \
+ (_at) = ((_at) + ((_align) - 1)) & -(_align); \
+ } while (0)
+
+#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 barectf_packet_size(void *ctx)
+{
+ return ((struct barectf_ctx *) ctx)->packet_size;
+}
+
+int barectf_packet_is_full(void *ctx)
+{
+ struct barectf_ctx *cctx = ctx;
+
+ return cctx->at == cctx->packet_size;
+}
+
+int barectf_packet_is_empty(void *ctx)
+{
+ struct barectf_ctx *cctx = ctx;
+
+ return cctx->at <= cctx->off_content;
+}
+
+uint32_t barectf_packet_events_discarded(void *ctx)
+{
+ return ((struct barectf_ctx *) ctx)->events_discarded;
+}
+
+uint8_t *barectf_packet_buf(void *ctx)
+{
+ return ((struct barectf_ctx *) ctx)->buf;
+}
+
+uint32_t barectf_packet_buf_size(void *ctx)
+{
+ return _BITS_TO_BYTES(((struct barectf_ctx *) ctx)->packet_size);
+}
+
+void barectf_packet_set_buf(void *ctx, uint8_t *buf, uint32_t buf_size)
+{
+ struct barectf_ctx *barectf_ctx = ctx;
+
+ barectf_ctx->buf = buf;
+ barectf_ctx->packet_size = _BYTES_TO_BITS(buf_size);
+}
+
+int barectf_packet_is_open(void *ctx)
+{
+ return ((struct barectf_ctx *) ctx)->packet_is_open;
+}
+
+static
+void _write_cstring(struct barectf_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 inline
+int _packet_is_full(struct barectf_ctx *ctx)
+{
+ return barectf_packet_is_full(ctx);
+}
+
+static
+int _reserve_event_space(struct barectf_ctx *ctx, uint32_t ev_size)
+{
+ /* event _cannot_ fit? */
+ if (ev_size > (ctx->packet_size - ctx->off_content)) {
+ ctx->events_discarded++;
+
+ return 0;
+ }
+
+ /* packet is full? */
+ if (barectf_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(struct barectf_ctx *ctx)
+{
+ /* is packet full? */
+ if (barectf_packet_is_full(ctx)) {
+ /* yes: close it now */
+ ctx->cbs.close_packet(ctx->data);
+ }
+}
+
+/* initialize context */
+void barectf_init(
+ void *ctx,
+ uint8_t *buf,
+ uint32_t buf_size,
+ struct barectf_platform_callbacks cbs,
+ void *data
+)
+{
+ struct barectf_ctx *barectf_ctx = ctx;
+ barectf_ctx->cbs = cbs;
+ barectf_ctx->data = data;
+ barectf_ctx->buf = buf;
+ barectf_ctx->packet_size = _BYTES_TO_BITS(buf_size);
+ barectf_ctx->at = 0;
+ barectf_ctx->events_discarded = 0;
+ barectf_ctx->packet_is_open = 0;
+}
+
+/* open packet for stream "default" */
+void barectf_default_open_packet(
+ struct barectf_default_ctx *ctx
+)
+{
+ uint64_t ts = ctx->parent.cbs.default_clock_get_value(ctx->parent.data);
+
+ /* do not open a packet that is already open */
+ if (ctx->parent.packet_is_open) {
+ return;
+ }
+
+ ctx->parent.at = 0;
+
+ /* trace packet header */
+ {
+ /* align structure */
+ _ALIGN(ctx->parent.at, 8);
+
+ /* "magic" field */
+ _ALIGN(ctx->parent.at, 8);
+ barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 32, 0xc1fc1fc1UL);
+ (&ctx->parent)->at += 32;
+
+ /* "uuid" field */
+ {
+ static uint8_t uuid[] = {
+ 127,
+ 53,
+ 26,
+ 32,
+ 235,
+ 22,
+ 17,
+ 229,
+ 140,
+ 48,
+ 36,
+ 119,
+ 3,
+ 138,
+ 62,
+ 196,
+ };
+
+ _ALIGN(ctx->parent.at, 8);
+ memcpy(&ctx->parent.buf[_BITS_TO_BYTES(ctx->parent.at)], uuid, 16);
+ ctx->parent.at += _BYTES_TO_BITS(16);
+ }
+
+ /* "stream_id" field */
+ _ALIGN(ctx->parent.at, 8);
+ barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 8, (uint8_t) 0);
+ (&ctx->parent)->at += 8;
+ }
+
+ /* stream packet context */
+ {
+ /* align structure */
+ _ALIGN(ctx->parent.at, 8);
+
+ /* "timestamp_begin" field */
+ _ALIGN(ctx->parent.at, 8);
+ barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 64, (uint64_t) ts);
+ (&ctx->parent)->at += 64;
+
+ /* "timestamp_end" field */
+ _ALIGN(ctx->parent.at, 8);
+ ctx->off_spc_timestamp_end = ctx->parent.at;
+ ctx->parent.at += 64;
+
+ /* "packet_size" field */
+ _ALIGN(ctx->parent.at, 8);
+ barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 32, (uint32_t) ctx->parent.packet_size);
+ (&ctx->parent)->at += 32;
+
+ /* "content_size" field */
+ _ALIGN(ctx->parent.at, 8);
+ ctx->off_spc_content_size = ctx->parent.at;
+ ctx->parent.at += 32;
+
+ /* "events_discarded" field */
+ _ALIGN(ctx->parent.at, 8);
+ ctx->off_spc_events_discarded = ctx->parent.at;
+ ctx->parent.at += 32;
+ }
+
+ ctx->parent.off_content = ctx->parent.at;
+
+ /* mark current packet as open */
+ ctx->parent.packet_is_open = 1;
+}
+
+/* close packet for stream "default" */
+void barectf_default_close_packet(struct barectf_default_ctx *ctx)
+{
+ uint64_t ts = ctx->parent.cbs.default_clock_get_value(ctx->parent.data);
+
+ /* do not close a packet that is not open */
+ if (!ctx->parent.packet_is_open) {
+ return;
+ }
+
+ /* save content size */
+ ctx->parent.content_size = ctx->parent.at;
+
+ /* "timestamp_end" field */
+ ctx->parent.at = ctx->off_spc_timestamp_end;
+ barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 64, (uint64_t) ts);
+ (&ctx->parent)->at += 64;
+
+ /* "content_size" field */
+ ctx->parent.at = ctx->off_spc_content_size;
+ barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 32, (uint32_t) ctx->parent.content_size);
+ (&ctx->parent)->at += 32;
+
+ /* "events_discarded" field */
+ ctx->parent.at = ctx->off_spc_events_discarded;
+ barectf_bt_bitfield_write_le(&(&ctx->parent)->buf[_BITS_TO_BYTES((&ctx->parent)->at)], uint8_t, 0, 32, (uint32_t) ctx->parent.events_discarded);
+ (&ctx->parent)->at += 32;
+
+ /* go back to end of packet */
+ ctx->parent.at = ctx->parent.packet_size;
+
+ /* mark packet as closed */
+ ctx->parent.packet_is_open = 0;
+}
+
+static void _serialize_stream_event_header_default(
+ struct barectf_ctx *ctx,
+ uint32_t event_id
+)
+{
+ uint64_t ts = ctx->cbs.default_clock_get_value(ctx->data);
+
+ {
+ /* align structure */
+ _ALIGN(ctx->at, 8);
+
+ /* "timestamp" field */
+ _ALIGN(ctx->at, 8);
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 64, (uint64_t) ts);
+ ctx->at += 64;
+
+ /* "id" field */
+ _ALIGN(ctx->at, 8);
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 16, (uint16_t) event_id);
+ ctx->at += 16;
+ }
+
+}
+
+static uint32_t _get_event_size_default_simple_uint32(
+ struct barectf_ctx *ctx,
+ uint32_t ep_value
+)
+{
+ uint32_t at = ctx->at;
+
+ /* stream event header */
+ {
+ /* align structure */
+ _ALIGN(at, 8);
+
+ /* "timestamp" field */
+ _ALIGN(at, 8);
+ at += 64;
+
+ /* "id" field */
+ _ALIGN(at, 8);
+ at += 16;
+ }
+
+ /* event payload */
+ {
+ /* align structure */
+ _ALIGN(at, 8);
+
+ /* "value" field */
+ _ALIGN(at, 8);
+ at += 32;
+ }
+
+ return at - ctx->at;
+}
+
+static void _serialize_event_default_simple_uint32(
+ struct barectf_ctx *ctx,
+ uint32_t ep_value
+)
+{
+ /* stream event header */
+ _serialize_stream_event_header_default(ctx, 0);
+
+ /* event payload */
+ {
+ /* align structure */
+ _ALIGN(ctx->at, 8);
+
+ /* "value" field */
+ _ALIGN(ctx->at, 8);
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 32, ep_value);
+ ctx->at += 32;
+ }
+
+}
+
+/* trace (stream "default", event "simple_uint32") */
+void barectf_default_trace_simple_uint32(
+ struct barectf_default_ctx *ctx,
+ uint32_t ep_value
+)
+{
+ uint32_t ev_size;
+
+ /* get event size */
+ ev_size = _get_event_size_default_simple_uint32((void *) ctx, ep_value);
+
+ /* do we have enough space to serialize? */
+ if (!_reserve_event_space((void *) ctx, ev_size)) {
+ /* no: forget this */
+ return;
+ }
+
+ /* serialize event */
+ _serialize_event_default_simple_uint32((void *) ctx, ep_value);
+
+ /* commit event */
+ _commit_event((void *) ctx);
+}
+
+static uint32_t _get_event_size_default_simple_int16(
+ struct barectf_ctx *ctx,
+ int16_t ep_value
+)
+{
+ uint32_t at = ctx->at;
+
+ /* stream event header */
+ {
+ /* align structure */
+ _ALIGN(at, 8);
+
+ /* "timestamp" field */
+ _ALIGN(at, 8);
+ at += 64;
+
+ /* "id" field */
+ _ALIGN(at, 8);
+ at += 16;
+ }
+
+ /* event payload */
+ {
+ /* align structure */
+ _ALIGN(at, 8);
+
+ /* "value" field */
+ _ALIGN(at, 8);
+ at += 16;
+ }
+
+ return at - ctx->at;
+}
+
+static void _serialize_event_default_simple_int16(
+ struct barectf_ctx *ctx,
+ int16_t ep_value
+)
+{
+ /* stream event header */
+ _serialize_stream_event_header_default(ctx, 1);
+
+ /* event payload */
+ {
+ /* align structure */
+ _ALIGN(ctx->at, 8);
+
+ /* "value" field */
+ _ALIGN(ctx->at, 8);
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 16, ep_value);
+ ctx->at += 16;
+ }
+
+}
+
+/* trace (stream "default", event "simple_int16") */
+void barectf_default_trace_simple_int16(
+ struct barectf_default_ctx *ctx,
+ int16_t ep_value
+)
+{
+ uint32_t ev_size;
+
+ /* get event size */
+ ev_size = _get_event_size_default_simple_int16((void *) ctx, ep_value);
+
+ /* do we have enough space to serialize? */
+ if (!_reserve_event_space((void *) ctx, ev_size)) {
+ /* no: forget this */
+ return;
+ }
+
+ /* serialize event */
+ _serialize_event_default_simple_int16((void *) ctx, ep_value);
+
+ /* commit event */
+ _commit_event((void *) ctx);
+}
+
+static uint32_t _get_event_size_default_simple_float(
+ struct barectf_ctx *ctx,
+ float ep_value
+)
+{
+ uint32_t at = ctx->at;
+
+ /* stream event header */
+ {
+ /* align structure */
+ _ALIGN(at, 8);
+
+ /* "timestamp" field */
+ _ALIGN(at, 8);
+ at += 64;
+
+ /* "id" field */
+ _ALIGN(at, 8);
+ at += 16;
+ }
+
+ /* event payload */
+ {
+ /* align structure */
+ _ALIGN(at, 32);
+
+ /* "value" field */
+ _ALIGN(at, 32);
+ at += 32;
+ }
+
+ return at - ctx->at;
+}
+
+static void _serialize_event_default_simple_float(
+ struct barectf_ctx *ctx,
+ float ep_value
+)
+{
+ /* stream event header */
+ _serialize_stream_event_header_default(ctx, 2);
+
+ /* event payload */
+ {
+ /* align structure */
+ _ALIGN(ctx->at, 32);
+
+ /* "value" field */
+ _ALIGN(ctx->at, 32);
+ union f2u f2u;
+
+ f2u.f = ep_value;
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 32, f2u.u);
+ ctx->at += 32;
+ }
+
+}
+
+/* trace (stream "default", event "simple_float") */
+void barectf_default_trace_simple_float(
+ struct barectf_default_ctx *ctx,
+ float ep_value
+)
+{
+ uint32_t ev_size;
+
+ /* get event size */
+ ev_size = _get_event_size_default_simple_float((void *) ctx, ep_value);
+
+ /* do we have enough space to serialize? */
+ if (!_reserve_event_space((void *) ctx, ev_size)) {
+ /* no: forget this */
+ return;
+ }
+
+ /* serialize event */
+ _serialize_event_default_simple_float((void *) ctx, ep_value);
+
+ /* commit event */
+ _commit_event((void *) ctx);
+}
+
+static uint32_t _get_event_size_default_simple_string(
+ struct barectf_ctx *ctx,
+ const char * ep_value
+)
+{
+ uint32_t at = ctx->at;
+
+ /* stream event header */
+ {
+ /* align structure */
+ _ALIGN(at, 8);
+
+ /* "timestamp" field */
+ _ALIGN(at, 8);
+ at += 64;
+
+ /* "id" field */
+ _ALIGN(at, 8);
+ at += 16;
+ }
+
+ /* event payload */
+ {
+ /* align structure */
+ _ALIGN(at, 8);
+
+ /* "value" field */
+ _ALIGN(at, 8);
+ at += _BYTES_TO_BITS(strlen(ep_value) + 1);
+ }
+
+ return at - ctx->at;
+}
+
+static void _serialize_event_default_simple_string(
+ struct barectf_ctx *ctx,
+ const char * ep_value
+)
+{
+ /* stream event header */
+ _serialize_stream_event_header_default(ctx, 3);
+
+ /* event payload */
+ {
+ /* align structure */
+ _ALIGN(ctx->at, 8);
+
+ /* "value" field */
+ _ALIGN(ctx->at, 8);
+ _write_cstring(ctx, ep_value);
+ }
+
+}
+
+/* trace (stream "default", event "simple_string") */
+void barectf_default_trace_simple_string(
+ struct barectf_default_ctx *ctx,
+ const char * ep_value
+)
+{
+ uint32_t ev_size;
+
+ /* get event size */
+ ev_size = _get_event_size_default_simple_string((void *) ctx, ep_value);
+
+ /* do we have enough space to serialize? */
+ if (!_reserve_event_space((void *) ctx, ev_size)) {
+ /* no: forget this */
+ return;
+ }
+
+ /* serialize event */
+ _serialize_event_default_simple_string((void *) ctx, ep_value);
+
+ /* commit event */
+ _commit_event((void *) ctx);
+}
+
+static uint32_t _get_event_size_default_simple_enum(
+ struct barectf_ctx *ctx,
+ uint8_t ep_value
+)
+{
+ uint32_t at = ctx->at;
+
+ /* stream event header */
+ {
+ /* align structure */
+ _ALIGN(at, 8);
+
+ /* "timestamp" field */
+ _ALIGN(at, 8);
+ at += 64;
+
+ /* "id" field */
+ _ALIGN(at, 8);
+ at += 16;
+ }
+
+ /* event payload */
+ {
+ /* align structure */
+ _ALIGN(at, 8);
+
+ /* "value" field */
+ _ALIGN(at, 8);
+ at += 8;
+ }
+
+ return at - ctx->at;
+}
+
+static void _serialize_event_default_simple_enum(
+ struct barectf_ctx *ctx,
+ uint8_t ep_value
+)
+{
+ /* stream event header */
+ _serialize_stream_event_header_default(ctx, 4);
+
+ /* event payload */
+ {
+ /* align structure */
+ _ALIGN(ctx->at, 8);
+
+ /* "value" field */
+ _ALIGN(ctx->at, 8);
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 8, ep_value);
+ ctx->at += 8;
+ }
+
+}
+
+/* trace (stream "default", event "simple_enum") */
+void barectf_default_trace_simple_enum(
+ struct barectf_default_ctx *ctx,
+ uint8_t ep_value
+)
+{
+ uint32_t ev_size;
+
+ /* get event size */
+ ev_size = _get_event_size_default_simple_enum((void *) ctx, ep_value);
+
+ /* do we have enough space to serialize? */
+ if (!_reserve_event_space((void *) ctx, ev_size)) {
+ /* no: forget this */
+ return;
+ }
+
+ /* serialize event */
+ _serialize_event_default_simple_enum((void *) ctx, ep_value);
+
+ /* commit event */
+ _commit_event((void *) ctx);
+}
+
+static uint32_t _get_event_size_default_a_few_fields(
+ struct barectf_ctx *ctx,
+ int32_t ep_int32,
+ uint16_t ep_uint16,
+ double ep_dbl,
+ const char * ep_str,
+ uint8_t ep_state
+)
+{
+ uint32_t at = ctx->at;
+
+ /* stream event header */
+ {
+ /* align structure */
+ _ALIGN(at, 8);
+
+ /* "timestamp" field */
+ _ALIGN(at, 8);
+ at += 64;
+
+ /* "id" field */
+ _ALIGN(at, 8);
+ at += 16;
+ }
+
+ /* event payload */
+ {
+ /* align structure */
+ _ALIGN(at, 64);
+
+ /* "int32" field */
+ _ALIGN(at, 8);
+ at += 32;
+
+ /* "uint16" field */
+ _ALIGN(at, 8);
+ at += 16;
+
+ /* "dbl" field */
+ _ALIGN(at, 64);
+ at += 64;
+
+ /* "str" field */
+ _ALIGN(at, 8);
+ at += _BYTES_TO_BITS(strlen(ep_str) + 1);
+
+ /* "state" field */
+ _ALIGN(at, 8);
+ at += 8;
+ }
+
+ return at - ctx->at;
+}
+
+static void _serialize_event_default_a_few_fields(
+ struct barectf_ctx *ctx,
+ int32_t ep_int32,
+ uint16_t ep_uint16,
+ double ep_dbl,
+ const char * ep_str,
+ uint8_t ep_state
+)
+{
+ /* stream event header */
+ _serialize_stream_event_header_default(ctx, 5);
+
+ /* event payload */
+ {
+ /* align structure */
+ _ALIGN(ctx->at, 64);
+
+ /* "int32" field */
+ _ALIGN(ctx->at, 8);
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 32, ep_int32);
+ ctx->at += 32;
+
+ /* "uint16" field */
+ _ALIGN(ctx->at, 8);
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 16, ep_uint16);
+ ctx->at += 16;
+
+ /* "dbl" field */
+ _ALIGN(ctx->at, 64);
+ union d2u d2u;
+
+ d2u.f = ep_dbl;
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 64, d2u.u);
+ ctx->at += 64;
+
+ /* "str" field */
+ _ALIGN(ctx->at, 8);
+ _write_cstring(ctx, ep_str);
+
+ /* "state" field */
+ _ALIGN(ctx->at, 8);
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 8, ep_state);
+ ctx->at += 8;
+ }
+
+}
+
+/* trace (stream "default", event "a_few_fields") */
+void barectf_default_trace_a_few_fields(
+ struct barectf_default_ctx *ctx,
+ int32_t ep_int32,
+ uint16_t ep_uint16,
+ double ep_dbl,
+ const char * ep_str,
+ uint8_t ep_state
+)
+{
+ uint32_t ev_size;
+
+ /* get event size */
+ ev_size = _get_event_size_default_a_few_fields((void *) ctx, ep_int32, ep_uint16, ep_dbl, ep_str, ep_state);
+
+ /* do we have enough space to serialize? */
+ if (!_reserve_event_space((void *) ctx, ev_size)) {
+ /* no: forget this */
+ return;
+ }
+
+ /* serialize event */
+ _serialize_event_default_a_few_fields((void *) ctx, ep_int32, ep_uint16, ep_dbl, ep_str, ep_state);
+
+ /* commit event */
+ _commit_event((void *) ctx);
+}
+
+static uint32_t _get_event_size_default_bit_packed_integers(
+ struct barectf_ctx *ctx,
+ uint8_t ep_uint1,
+ int8_t ep_int1,
+ uint8_t ep_uint2,
+ int8_t ep_int3,
+ uint8_t ep_uint4,
+ int8_t ep_int5,
+ uint8_t ep_uint6,
+ int8_t ep_int7,
+ uint8_t ep_uint8
+)
+{
+ uint32_t at = ctx->at;
+
+ /* stream event header */
+ {
+ /* align structure */
+ _ALIGN(at, 8);
+
+ /* "timestamp" field */
+ _ALIGN(at, 8);
+ at += 64;
+
+ /* "id" field */
+ _ALIGN(at, 8);
+ at += 16;
+ }
+
+ /* event payload */
+ {
+ /* align structure */
+ _ALIGN(at, 8);
+
+ /* "uint1" field */
+ at += 1;
+
+ /* "int1" field */
+ at += 1;
+
+ /* "uint2" field */
+ at += 2;
+
+ /* "int3" field */
+ at += 3;
+
+ /* "uint4" field */
+ at += 4;
+
+ /* "int5" field */
+ at += 5;
+
+ /* "uint6" field */
+ at += 6;
+
+ /* "int7" field */
+ at += 7;
+
+ /* "uint8" field */
+ at += 8;
+ }
+
+ return at - ctx->at;
+}
+
+static void _serialize_event_default_bit_packed_integers(
+ struct barectf_ctx *ctx,
+ uint8_t ep_uint1,
+ int8_t ep_int1,
+ uint8_t ep_uint2,
+ int8_t ep_int3,
+ uint8_t ep_uint4,
+ int8_t ep_int5,
+ uint8_t ep_uint6,
+ int8_t ep_int7,
+ uint8_t ep_uint8
+)
+{
+ /* stream event header */
+ _serialize_stream_event_header_default(ctx, 6);
+
+ /* event payload */
+ {
+ /* align structure */
+ _ALIGN(ctx->at, 8);
+
+ /* "uint1" field */
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 1, ep_uint1);
+ ctx->at += 1;
+
+ /* "int1" field */
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 1, 1, ep_int1);
+ ctx->at += 1;
+
+ /* "uint2" field */
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 2, 2, ep_uint2);
+ ctx->at += 2;
+
+ /* "int3" field */
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 4, 3, ep_int3);
+ ctx->at += 3;
+
+ /* "uint4" field */
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 7, 4, ep_uint4);
+ ctx->at += 4;
+
+ /* "int5" field */
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 3, 5, ep_int5);
+ ctx->at += 5;
+
+ /* "uint6" field */
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 0, 6, ep_uint6);
+ ctx->at += 6;
+
+ /* "int7" field */
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 6, 7, ep_int7);
+ ctx->at += 7;
+
+ /* "uint8" field */
+ barectf_bt_bitfield_write_le(&ctx->buf[_BITS_TO_BYTES(ctx->at)], uint8_t, 5, 8, ep_uint8);
+ ctx->at += 8;
+ }
+
+}
+
+/* trace (stream "default", event "bit_packed_integers") */
+void barectf_default_trace_bit_packed_integers(
+ struct barectf_default_ctx *ctx,
+ uint8_t ep_uint1,
+ int8_t ep_int1,
+ uint8_t ep_uint2,
+ int8_t ep_int3,
+ uint8_t ep_uint4,
+ int8_t ep_int5,
+ uint8_t ep_uint6,
+ int8_t ep_int7,
+ uint8_t ep_uint8
+)
+{
+ uint32_t ev_size;
+
+ /* get event size */
+ ev_size = _get_event_size_default_bit_packed_integers((void *) ctx, ep_uint1, ep_int1, ep_uint2, ep_int3, ep_uint4, ep_int5, ep_uint6, ep_int7, ep_uint8);
+
+ /* do we have enough space to serialize? */
+ if (!_reserve_event_space((void *) ctx, ev_size)) {
+ /* no: forget this */
+ return;
+ }
+
+ /* serialize event */
+ _serialize_event_default_bit_packed_integers((void *) ctx, ep_uint1, ep_int1, ep_uint2, ep_int3, ep_uint4, ep_int5, ep_uint6, ep_int7, ep_uint8);
+
+ /* commit event */
+ _commit_event((void *) ctx);
+}
--- /dev/null
+#ifndef _BARECTF_H
+#define _BARECTF_H
+
+/*
+ * The following C code was generated by barectf 2.1.0-dev
+ * on 2016-03-15T21:29:16.069818.
+ *
+ * For more details, see <https://github.com/efficios/barectf>.
+ */
+
+#include <stdint.h>
+
+#include "barectf-bitfield.h"
+
+struct barectf_ctx;
+
+uint32_t barectf_packet_size(void *ctx);
+int barectf_packet_is_full(void *ctx);
+int barectf_packet_is_empty(void *ctx);
+uint32_t barectf_packet_events_discarded(void *ctx);
+uint8_t *barectf_packet_buf(void *ctx);
+void barectf_packet_set_buf(void *ctx, uint8_t *buf, uint32_t buf_size);
+uint32_t barectf_packet_buf_size(void *ctx);
+int barectf_packet_is_open(void *ctx);
+
+/* barectf platform callbacks */
+struct barectf_platform_callbacks {
+ /* clock callbacks */
+ uint64_t (*default_clock_get_value)(void *);
+
+ /* is back-end full? */
+ int (*is_backend_full)(void *);
+
+ /* open packet */
+ void (*open_packet)(void *);
+
+ /* close packet */
+ void (*close_packet)(void *);
+};
+
+/* common barectf context */
+struct barectf_ctx {
+ /* platform callbacks */
+ struct barectf_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;
+};
+
+/* context for stream "default" */
+struct barectf_default_ctx {
+ /* parent */
+ struct barectf_ctx parent;
+
+ /* config-specific members follow */
+ uint32_t off_tph_magic;
+ uint32_t off_tph_uuid;
+ uint32_t off_tph_stream_id;
+ uint32_t off_spc_timestamp_begin;
+ uint32_t off_spc_timestamp_end;
+ uint32_t off_spc_packet_size;
+ uint32_t off_spc_content_size;
+ uint32_t off_spc_events_discarded;
+};
+
+/* initialize context */
+void barectf_init(
+ void *ctx,
+ uint8_t *buf,
+ uint32_t buf_size,
+ struct barectf_platform_callbacks cbs,
+ void *data
+);
+
+/* open packet for stream "default" */
+void barectf_default_open_packet(
+ struct barectf_default_ctx *ctx
+);
+
+/* close packet for stream "default" */
+void barectf_default_close_packet(struct barectf_default_ctx *ctx);
+
+/* trace (stream "default", event "simple_uint32") */
+void barectf_default_trace_simple_uint32(
+ struct barectf_default_ctx *ctx,
+ uint32_t ep_value
+);
+
+/* trace (stream "default", event "simple_int16") */
+void barectf_default_trace_simple_int16(
+ struct barectf_default_ctx *ctx,
+ int16_t ep_value
+);
+
+/* trace (stream "default", event "simple_float") */
+void barectf_default_trace_simple_float(
+ struct barectf_default_ctx *ctx,
+ float ep_value
+);
+
+/* trace (stream "default", event "simple_string") */
+void barectf_default_trace_simple_string(
+ struct barectf_default_ctx *ctx,
+ const char * ep_value
+);
+
+/* trace (stream "default", event "simple_enum") */
+void barectf_default_trace_simple_enum(
+ struct barectf_default_ctx *ctx,
+ uint8_t ep_value
+);
+
+/* trace (stream "default", event "a_few_fields") */
+void barectf_default_trace_a_few_fields(
+ struct barectf_default_ctx *ctx,
+ int32_t ep_int32,
+ uint16_t ep_uint16,
+ double ep_dbl,
+ const char * ep_str,
+ uint8_t ep_state
+);
+
+/* trace (stream "default", event "bit_packed_integers") */
+void barectf_default_trace_bit_packed_integers(
+ struct barectf_default_ctx *ctx,
+ uint8_t ep_uint1,
+ int8_t ep_int1,
+ uint8_t ep_uint2,
+ int8_t ep_int3,
+ uint8_t ep_uint4,
+ int8_t ep_int5,
+ uint8_t ep_uint6,
+ int8_t ep_int7,
+ uint8_t ep_uint8
+);
+
+#endif /* _BARECTF_H */
\ No newline at end of file
--- /dev/null
+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: []
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+#!/usr/bin/env bats
+
+load ../../../common
+load ../../common
+
+@test 'unknown property in clock object makes barectf fail' {
+ barectf_assert_file_exists unknown-prop.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "freq" property type in clock object makes barectf fail' {
+ barectf_assert_file_exists freq-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "freq" property (0) in clock object makes barectf fail' {
+ barectf_assert_file_exists freq-0.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "freq" property (negative) in clock object makes barectf fail' {
+ barectf_assert_file_exists freq-neg.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "description" property type in clock object makes barectf fail' {
+ barectf_assert_file_exists description-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "uuid" property type in clock object makes barectf fail' {
+ barectf_assert_file_exists uuid-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "uuid" property in clock object makes barectf fail' {
+ barectf_assert_file_exists uuid-invalid.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "error-cycles" property type in clock object makes barectf fail' {
+ barectf_assert_file_exists ec-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "error-cycles" property in clock object makes barectf fail' {
+ barectf_assert_file_exists ec-invalid.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "offset" property type in clock object makes barectf fail' {
+ barectf_assert_file_exists offset-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "absolute" property type in clock object makes barectf fail' {
+ barectf_assert_file_exists absolute-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'unknown property in clock offset object makes barectf fail' {
+ barectf_assert_file_exists offset-unknown-prop.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "seconds" property type in clock offset object makes barectf fail' {
+ barectf_assert_file_exists offset-seconds-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "seconds" property in clock offset object makes barectf fail' {
+ barectf_assert_file_exists offset-seconds-neg.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "cycles" property type in clock offset object makes barectf fail' {
+ barectf_assert_file_exists offset-cycles-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "cycles" property in clock offset object makes barectf fail' {
+ barectf_assert_file_exists offset-cycles-neg.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "$return-ctype" property type in clock object makes barectf fail' {
+ barectf_assert_file_exists rct-invalid-type.yaml
+ barectf_config_check_fail
+}
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+#!/usr/bin/env bats
+
+load ../../../common
+load ../../common
+
+@test 'unknown property in config object makes barectf fail' {
+ barectf_assert_file_exists unknown-prop.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "version" property in config object makes barectf fail' {
+ barectf_assert_file_exists version-no.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "version" property type in config object makes barectf fail' {
+ barectf_assert_file_exists version-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "version" property (1.9) in config object makes barectf fail' {
+ barectf_assert_file_exists version-invalid-19.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "version" property (2.2) in config object makes barectf fail' {
+ barectf_assert_file_exists version-invalid-22.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "prefix" property type in config object makes barectf fail' {
+ barectf_assert_file_exists prefix-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'no valid C identifier in "prefix" property type in config object makes barectf fail' {
+ barectf_assert_file_exists prefix-invalid-identifier.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "metadata" property in config object makes barectf fail' {
+ barectf_assert_file_exists metadata-no.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "metadata" property type in config object makes barectf fail' {
+ barectf_assert_file_exists metadata-invalid-type.yaml
+ barectf_config_check_fail
+}
--- /dev/null
+version: '2.1'
+metadata: 23
+
--- /dev/null
+version: '2.1'
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+version: '2.2'
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+#!/usr/bin/env bats
+
+load ../../../common
+load ../../common
+
+@test 'unknown property in event object makes barectf fail' {
+ barectf_assert_file_exists unknown-prop.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "log-level" property type in event object makes barectf fail' {
+ barectf_assert_file_exists ll-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'non existing log level name as "log-level" property value in event object makes barectf fail' {
+ barectf_assert_file_exists ll-non-existing.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "context-type" property type in event object makes barectf fail' {
+ barectf_assert_file_exists ct-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "context-type" property field type (not a structure) in event object makes barectf fail' {
+ barectf_assert_file_exists ct-not-struct.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "payload-type" property type in event object makes barectf fail' {
+ barectf_assert_file_exists pt-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "payload-type" property in event object makes barectf fail' {
+ barectf_assert_file_exists pt-no.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "payload-type" property field type (not a structure) in event object makes barectf fail' {
+ barectf_assert_file_exists pt-not-struct.yaml
+ barectf_config_check_fail
+}
+
+@test 'empty struct type as "payload-type" property in event object makes barectf fail' {
+ barectf_assert_file_exists pt-empty.yaml
+ barectf_config_check_fail
+}
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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: struct
+ fields:
+ allo: uint16
--- /dev/null
+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
+
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+#!/usr/bin/env bats
+
+load ../../../common
+load ../../common
+
+@test 'wrong "$include" property type makes barectf fail' {
+ barectf_assert_file_exists invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'non-existing file in "$include" property (string) makes barectf fail' {
+ barectf_assert_file_exists file-not-found.yaml
+ barectf_config_check_fail
+}
+
+@test 'non-existing absolute file in "$include" property (string) makes barectf fail' {
+ barectf_assert_file_exists file-not-found-abs.yaml
+ barectf_config_check_fail
+}
+
+@test 'non-existing file in "$include" property (array) makes barectf fail' {
+ barectf_assert_file_exists file-not-found-in-array.yaml
+ barectf_config_check_fail
+}
+
+@test 'non-existing file in "$include" property (recursive) makes barectf fail' {
+ barectf_assert_file_exists file-not-found-recursive.yaml
+ barectf_config_check_fail
+}
+
+@test 'cycle in include graph makes barectf fail' {
+ barectf_assert_file_exists cycle.yaml
+ barectf_config_check_fail
+}
+
+@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_assert_file_exists cycle-sym.yaml
+ barectf_config_check_fail
+ rm -f "$symlink"
+}
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+$include: yes.yaml
--- /dev/null
+$include: inc-recursive-sym2.yaml
--- /dev/null
+$include: inc-recursive-sym3.yaml
--- /dev/null
+$include: inc-recursive2.yaml
--- /dev/null
+$include: inc-recursive3.yaml
--- /dev/null
+$include: inc-recursive1.yaml
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+#!/usr/bin/env bats
+
+load ../../../common
+load ../../common
+
+@test 'unknown property in metadata object makes barectf fail' {
+ barectf_assert_file_exists unknown-prop.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "env" property type in metadata object makes barectf fail' {
+ barectf_assert_file_exists env-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "env" key (invalid C identifier) in metadata object makes barectf fail' {
+ barectf_assert_file_exists env-key-invalid-identifier.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "env" value (not an int/string) in metadata object makes barectf fail' {
+ barectf_assert_file_exists env-value-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "clocks" property type in metadata object makes barectf fail' {
+ barectf_assert_file_exists clocks-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "clocks" key (invalid C identifier) in metadata object makes barectf fail' {
+ barectf_assert_file_exists clocks-key-invalid-identifier.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "$log-levels" property type in metadata object makes barectf fail' {
+ barectf_assert_file_exists ll-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "$log-levels" property value type in metadata object makes barectf fail' {
+ barectf_assert_file_exists ll-value-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "type-aliases" property type in metadata object makes barectf fail' {
+ barectf_assert_file_exists ta-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "trace" property in metadata object makes barectf fail' {
+ barectf_assert_file_exists trace-no.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "trace" property type in metadata object makes barectf fail' {
+ barectf_assert_file_exists trace-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'empty "trace" property in metadata object makes barectf fail' {
+ barectf_assert_file_exists trace-empty.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "streams" property in metadata object makes barectf fail' {
+ barectf_assert_file_exists streams-no.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "streams" property type in metadata object makes barectf fail' {
+ barectf_assert_file_exists streams-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'empty "streams" property in metadata object makes barectf fail' {
+ barectf_assert_file_exists streams-empty.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "streams" key (invalid C identifier) in metadata object makes barectf fail' {
+ barectf_assert_file_exists streams-key-invalid-identifier.yaml
+ barectf_config_check_fail
+}
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+version: '2.1'
+metadata:
+ trace:
+ byte-order: le
+ streams: {}
--- /dev/null
+version: '2.1'
+metadata:
+ type-aliases:
+ uint16:
+ class: int
+ size: 16
+ trace:
+ byte-order: le
+ streams: -17
--- /dev/null
+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
--- /dev/null
+version: '2.1'
+metadata:
+ trace:
+ byte-order: le
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+version: '2.1'
+metadata:
+ trace:
+ byte-order: le
+ streams:
+ my_stream:
+ events: {}
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+#!/usr/bin/env bats
+
+load ../../../common
+load ../../common
+
+@test 'unknown property in stream object makes barectf fail' {
+ barectf_assert_file_exists unknown-prop.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "packet-context-type" property in stream object makes barectf fail' {
+ barectf_assert_file_exists pct-no.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "packet-context-type" property type in stream object makes barectf fail' {
+ barectf_assert_file_exists pct-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "packet-context-type" property field type (not a structure) in stream object makes barectf fail' {
+ barectf_assert_file_exists pct-not-struct.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "timestamp_begin" field type (not an integer) in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-tb-not-int.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "timestamp_begin" field type (signed) in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-tb-wrong-signed.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "timestamp_begin" field type (not mapped to a clock) in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-tb-wrong-pm.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "timestamp_begin" field with an existing "timestamp_end" field in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-te-yes-tb-no.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "timestamp_end" field type (not an integer) in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-te-not-int.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "timestamp_end" field type (signed) in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-te-wrong-signed.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "timestamp_end" field type (not mapped to a clock) in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-te-wrong-pm.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "timestamp_end" field with an existing "timestamp_begin" field in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-tb-yes-te-no.yaml
+ barectf_config_check_fail
+}
+
+@test '"timestamp_begin" field and "timestamp_end" field are not mapped to the same clock in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-tb-te-different-clocks.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "packet_size" field type (not an integer) in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-ps-not-int.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "packet_size" field type (signed) in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-ps-wrong-signed.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "packet_size" field with an existing "content_size" field in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-cs-yes-ps-no.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "content_size" field type (not an integer) in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-cs-not-int.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "content_size" field type (signed) in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-cs-wrong-signed.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "content_size" field with an existing "packet_size" field in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-ps-yes-cs-no.yaml
+ barectf_config_check_fail
+}
+
+@test '"content_size" field size greater than "packet_size" field size in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-cs-gt-ps.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "events_discarded" field type (not an integer) in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-ed-not-int.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "events_discarded" field type (signed) in packet context type makes barectf fail' {
+ barectf_assert_file_exists pct-ed-wrong-signed.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "event-header-type" property type in stream object makes barectf fail' {
+ barectf_assert_file_exists eht-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "event-header-type" property field type (not a structure) in stream object makes barectf fail' {
+ barectf_assert_file_exists eht-not-struct.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "timestamp" field type (not an integer) in event header type makes barectf fail' {
+ barectf_assert_file_exists eht-timestamp-not-int.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "timestamp" field type (signed) in event header type makes barectf fail' {
+ barectf_assert_file_exists eht-timestamp-wrong-signed.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "timestamp" field type (not mapped to a clock) in event header type makes barectf fail' {
+ barectf_assert_file_exists eht-timestamp-wrong-pm.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "id" field type (not an integer) in event header type makes barectf fail' {
+ barectf_assert_file_exists eht-id-not-int.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "id" field type (signed) in event header type makes barectf fail' {
+ barectf_assert_file_exists eht-id-wrong-signed.yaml
+ barectf_config_check_fail
+}
+
+@test 'no event header type with multiple events in stream object makes barectf fail' {
+ barectf_assert_file_exists eht-id-no-multiple-events.yaml
+ barectf_config_check_fail
+}
+
+@test '"id" field type size too small for the number of stream events in event header type makes barectf fail' {
+ barectf_assert_file_exists eht-id-too-small.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "event-context-type" property type in stream object makes barectf fail' {
+ barectf_assert_file_exists ect-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "event-context-type" property field type (not a structure) in stream object makes barectf fail' {
+ barectf_assert_file_exists ect-not-struct.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "events" property in stream object makes barectf fail' {
+ barectf_assert_file_exists events-no.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "events" property type in stream object makes barectf fail' {
+ barectf_assert_file_exists events-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'empty "events" property in stream object makes barectf fail' {
+ barectf_assert_file_exists events-empty.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "events" key (invalid C identifier) in metadata object makes barectf fail' {
+ barectf_assert_file_exists events-key-invalid-identifier.yaml
+ barectf_config_check_fail
+}
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+#!/usr/bin/env bats
+
+load ../../../common
+load ../../common
+
+@test 'unknown property in trace object makes barectf fail' {
+ barectf_assert_file_exists unknown-prop.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "byte-order" property type in trace object makes barectf fail' {
+ barectf_assert_file_exists bo-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "byte-order" property in trace object makes barectf fail' {
+ barectf_assert_file_exists bo-no.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "byte-order" property in trace object makes barectf fail' {
+ barectf_assert_file_exists bo-invalid.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "packet-header-type" property field type (not a structure) in trace object makes barectf fail' {
+ barectf_assert_file_exists ph-not-struct.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "uuid" property type in trace object makes barectf fail' {
+ barectf_assert_file_exists uuid-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "uuid" property (invalid UUID format) in trace object makes barectf fail' {
+ barectf_assert_file_exists uuid-invalid-uuid.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "magic" field type (not an integer) in packet header type makes barectf fail' {
+ barectf_assert_file_exists ph-magic-not-int.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "magic" field type (wrong integer size) in packet header type makes barectf fail' {
+ barectf_assert_file_exists ph-magic-wrong-size.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "magic" field type (signed) in packet header type makes barectf fail' {
+ barectf_assert_file_exists ph-magic-wrong-signed.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "stream_id" field type (not an integer) in packet header type makes barectf fail' {
+ barectf_assert_file_exists ph-streamid-not-int.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "stream_id" field type (signed) in packet header type makes barectf fail' {
+ barectf_assert_file_exists ph-streamid-wrong-signed.yaml
+ barectf_config_check_fail
+}
+
+@test '"stream_id" field type size too small for the number of trace streams in packet header type makes barectf fail' {
+ barectf_assert_file_exists ph-streamid-too-small.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "uuid" field type (not an array) in packet header type makes barectf fail' {
+ barectf_assert_file_exists ph-uuid-not-array.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "uuid" field type (wrong array length) in packet header type makes barectf fail' {
+ barectf_assert_file_exists ph-uuid-wrong-length.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "uuid" field type (element type is not an integer) in packet header type makes barectf fail' {
+ barectf_assert_file_exists ph-uuid-et-not-int.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "uuid" field type (wrong element type size) in packet header type makes barectf fail' {
+ barectf_assert_file_exists ph-uuid-et-wrong-size.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "uuid" field type (element type is signed) in packet header type makes barectf fail' {
+ barectf_assert_file_exists ph-uuid-et-wrong-signed.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "uuid" field type (wrong element type alignment) in packet header type makes barectf fail' {
+ barectf_assert_file_exists ph-uuid-et-wrong-align.yaml
+ barectf_config_check_fail
+}
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+#!/usr/bin/env bats
+
+load ../../../common
+load ../../common
+
+@test 'unknown property in enum type object makes barectf fail' {
+ barectf_assert_file_exists unknown-prop.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "value-type" property in enum type object makes barectf fail' {
+ barectf_assert_file_exists vt-no.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "value-type" property type in enum type object makes barectf fail' {
+ barectf_assert_file_exists vt-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "members" property in enum type object makes barectf fail' {
+ barectf_assert_file_exists members-no.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "members" property type in enum type object makes barectf fail' {
+ barectf_assert_file_exists members-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'empty "members" property in enum type object makes barectf fail' {
+ barectf_assert_file_exists members-empty.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "members" property element type in enum type object makes barectf fail' {
+ barectf_assert_file_exists members-el-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'unknown property in enum type member object makes barectf fail' {
+ barectf_assert_file_exists members-el-member-unknown-prop.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "label" property type in enum type member object makes barectf fail' {
+ barectf_assert_file_exists members-el-member-label-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "value" property type in enum type member object makes barectf fail' {
+ barectf_assert_file_exists members-el-member-value-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test '"value" property outside the unsigned value type range in enum type member object makes barectf fail' {
+ barectf_assert_file_exists members-el-member-value-outside-range-unsigned.yaml
+ barectf_config_check_fail
+}
+
+@test '"value" property outside the signed value type range in enum type member object makes barectf fail' {
+ barectf_assert_file_exists members-el-member-value-outside-range-signed.yaml
+ barectf_config_check_fail
+}
+
+@test 'overlapping members in enum type object makes barectf fail' {
+ barectf_assert_file_exists members-overlap.yaml
+ barectf_config_check_fail
+}
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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: []
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+#!/usr/bin/env bats
+
+load ../../../common
+load ../../common
+
+@test 'unknown property in float type object makes barectf fail' {
+ barectf_assert_file_exists unknown-prop.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "size" property in float type object makes barectf fail' {
+ barectf_assert_file_exists size-no.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "size" property type in float type object makes barectf fail' {
+ barectf_assert_file_exists size-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'unknown property in float type object "size" property makes barectf fail' {
+ barectf_assert_file_exists size-unknown-prop.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "exp" property in float type object "size" property makes barectf fail' {
+ barectf_assert_file_exists size-exp-no.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "mant" property in float type object "size" property makes barectf fail' {
+ barectf_assert_file_exists size-mant-no.yaml
+ barectf_config_check_fail
+}
+
+@test 'sum of "mant" and "exp" properties of float type size object not a multiple of 32 property makes barectf fail' {
+ barectf_assert_file_exists size-exp-mant-wrong-sum.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "align" property type in float type object makes barectf fail' {
+ barectf_assert_file_exists align-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "align" property (0) in float type object makes barectf fail' {
+ barectf_assert_file_exists align-0.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "align" property (3) in float type object makes barectf fail' {
+ barectf_assert_file_exists align-3.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "byte-order" property type in float type object makes barectf fail' {
+ barectf_assert_file_exists bo-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "byte-order" property in float type object makes barectf fail' {
+ barectf_assert_file_exists bo-invalid.yaml
+ barectf_config_check_fail
+}
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+version: '2.1'
+metadata:
+ trace:
+ byte-order: le
+ streams:
+ my_stream:
+ events:
+ my_event:
+ payload-type:
+ class: struct
+ fields:
+ my_field:
+ class: float
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+#!/usr/bin/env bats
+
+load ../../../common
+load ../../common
+
+@test 'unknown property in int type object makes barectf fail' {
+ barectf_assert_file_exists unknown-prop.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "size" property in int type object makes barectf fail' {
+ barectf_assert_file_exists size-no.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "size" property type in int type object makes barectf fail' {
+ barectf_assert_file_exists size-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "size" property (0) in int type object makes barectf fail' {
+ barectf_assert_file_exists size-0.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "size" property (65) in int type object makes barectf fail' {
+ barectf_assert_file_exists size-65.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "signed" property type in int type object makes barectf fail' {
+ barectf_assert_file_exists signed-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "align" property type in int type object makes barectf fail' {
+ barectf_assert_file_exists align-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "align" property (0) in int type object makes barectf fail' {
+ barectf_assert_file_exists align-0.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "align" property (3) in int type object makes barectf fail' {
+ barectf_assert_file_exists align-3.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "base" property type in int type object makes barectf fail' {
+ barectf_assert_file_exists base-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "base" property in int type object makes barectf fail' {
+ barectf_assert_file_exists base-invalid.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "byte-order" property type in int type object makes barectf fail' {
+ barectf_assert_file_exists bo-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "byte-order" property in int type object makes barectf fail' {
+ barectf_assert_file_exists bo-invalid.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "property-mappings" property type in int type object makes barectf fail' {
+ barectf_assert_file_exists pm-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "property-mappings" property in int type object makes barectf fail' {
+ barectf_assert_file_exists pm-unknown-clock.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "property-mappings" property (invalid "type" property) in int type object makes barectf fail' {
+ barectf_assert_file_exists pm-type-invalid.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "property-mappings" property (invalid "property" property) in int type object makes barectf fail' {
+ barectf_assert_file_exists pm-property-invalid.yaml
+ barectf_config_check_fail
+}
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+version: '2.1'
+metadata:
+ trace:
+ byte-order: le
+ streams:
+ my_stream:
+ events:
+ my_event:
+ payload-type:
+ class: struct
+ fields:
+ my_field:
+ class: int
--- /dev/null
+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
--- /dev/null
+#!/usr/bin/env bats
+
+load ../../../common
+load ../../common
+
+@test 'unknown property in string type object makes barectf fail' {
+ barectf_assert_file_exists unknown-prop.yaml
+ barectf_config_check_fail
+}
--- /dev/null
+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
--- /dev/null
+#!/usr/bin/env bats
+
+load ../../../common
+load ../../common
+
+@test 'unknown property in struct type object makes barectf fail' {
+ barectf_assert_file_exists unknown-prop.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "fields" property type in struct type object makes barectf fail' {
+ barectf_assert_file_exists fields-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid field in "fields" property (invalid C identifier) in struct type object makes barectf fail' {
+ barectf_assert_file_exists fields-field-invalid-identifier.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong "min-align" property type in struct type object makes barectf fail' {
+ barectf_assert_file_exists ma-invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "min-align" property (0) in struct type object makes barectf fail' {
+ barectf_assert_file_exists ma-0.yaml
+ barectf_config_check_fail
+}
+
+@test 'invalid "min-align" property (3) in struct type object makes barectf fail' {
+ barectf_assert_file_exists ma-3.yaml
+ barectf_config_check_fail
+}
--- /dev/null
+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
--- /dev/null
+version: '2.1'
+metadata:
+ trace:
+ byte-order: le
+ streams:
+ my_stream:
+ events:
+ my_event:
+ payload-type:
+ class: struct
+ fields: 23
--- /dev/null
+version: '2.1'
+metadata:
+ trace:
+ byte-order: le
+ streams:
+ my_stream:
+ events:
+ my_event:
+ payload-type:
+ class: struct
+ min-align: 0
--- /dev/null
+version: '2.1'
+metadata:
+ trace:
+ byte-order: le
+ streams:
+ my_stream:
+ events:
+ my_event:
+ payload-type:
+ class: struct
+ min-align: 3
--- /dev/null
+version: '2.1'
+metadata:
+ trace:
+ byte-order: le
+ streams:
+ my_stream:
+ events:
+ my_event:
+ payload-type:
+ class: struct
+ min-align: yes
--- /dev/null
+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
--- /dev/null
+#!/usr/bin/env bats
+
+load ../../../common
+load ../../common
+
+@test 'type inheriting an unknown type alias makes barectf fail' {
+ barectf_assert_file_exists inherit-unknown.yaml
+ barectf_config_check_fail
+}
+
+@test 'type inheriting a type alias defined after makes barectf fail' {
+ barectf_assert_file_exists inherit-forward.yaml
+ barectf_config_check_fail
+}
+
+@test 'wrong type property type makes barectf fail' {
+ barectf_assert_file_exists invalid-type.yaml
+ barectf_config_check_fail
+}
+
+@test 'no "class" property in type object makes barectf fail' {
+ barectf_assert_file_exists no-class.yaml
+ barectf_config_check_fail
+}
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+version: '2.1'
+metadata:
+ trace:
+ byte-order: le
+ streams:
+ my_stream:
+ events:
+ my_event:
+ payload-type:
+ class: struct
+ fields:
+ my_field:
+ size: 8
--- /dev/null
+#!/usr/bin/env bats
+
+load ../../../common
+load ../../common
+
+@test 'invalid YAML input makes barectf fail' {
+ barectf_assert_file_exists invalid.yaml
+ barectf_config_check_fail
+}
--- /dev/null
+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
--- /dev/null
+version: '2.1'
+prefix: bctf_
+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
--- /dev/null
+freq: 123456789
+offset:
+ seconds: 18
+absolute: true
+$return-ctype: unsigned long
--- /dev/null
+log-level: WARNING
+context-type:
+ class: struct
+ fields:
+ fff: float
--- /dev/null
+$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
--- /dev/null
+event-context-type:
+ class: struct
+ fields:
+ i: int32
+ f: float
+ d: double
+ s: string
+ m: ctf-magic
+events:
+ evev:
+ payload-type: def-payload-type
--- /dev/null
+$include: trace-basic.yaml
+packet-header-type:
+ fields:
+ soy_sauce: uint64
--- /dev/null
+#!/usr/bin/env bats
+
+load ../../../common
+load ../../common
+
+@test 'unknown property in config object makes barectf fail' {
+ barectf_assert_file_exists config.yaml
+ [ $status -eq 0 ]
+ [ -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_evev
+ nm bctf.o | grep bctf_my_other_stream_trace_my_event
+ 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
+}
--- /dev/null
+#!/usr/bin/env bash
+
+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
+ $bats_bin $@ .
+ popd
+
+ if [ $? -ne 0 ]; then
+ # latch error, but continue other tests
+ rc=1
+ fi
+done
+
+exit $rc