1 # The MIT License (MIT)
3 # Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 barectf_assert_file_exists
() {
24 if [ ! -f "$1" ]; then
25 echo "FATAL: "$1" does not exist" 1>&2
29 if ! which barectf
> /dev
/null
; then
30 echo "FATAL: cannot find barectf tool" 1>&2
35 barectf_config_check_success
() {
36 pushd "$BATS_TEST_DIRNAME" >/dev
/null
38 if ! barectf_assert_file_exists
"$1"; then
46 if [ "$status" -ne 0 ]; then
47 echo "Fail: exit code is $status" 1>&2
52 barectf_config_check_fail
() {
53 pushd "$BATS_TEST_DIRNAME" >/dev
/null
55 if ! barectf_assert_file_exists
"$1"; then
62 if [[ $output != *'Cannot create configuration'* ]]; then
63 echo "Fail: barectf does not print a configuration error" 1>&2
70 if [ "$status" -eq 0 ]; then
71 echo "Fail: exit code is 0" 1>&2
76 local find_output
="$(find -iname '*.c' -o -iname '*.h' -o -iname metadata)"
79 if [ -n "$find_output" ]; then
80 echo "Fail: barectf generated files" 1>&2
90 rm -f *ctf.c
*ctf.h
*ctf.o
*ctf-bitfield.h metadata