Root/b2/test/Common

1#!/bin/bash -x
2#
3# Common - Elements shared by all regression tests for BOOM
4#
5# Written 2012 by Werner Almesberger
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12
13
14run_boom()
15{
16    if [ "`sed -n '/^!-/p;q' _in`" -o ! -s _in ]; then
17        args="-N dummy <(echo ';')"
18    else
19        args="-N h <(sed -n '/^!-/q;p' _in)"
20    fi
21    for n in c x p i s b X; do
22        for m in "" 1 2 3; do
23            if grep ^!-$n$m\$ _in >/dev/null; then
24                args="$args -N $n$m"
25                args="$args -$n \
26<(sed -n '0,/^!-$n$m/d;/^!-/q;p' _in)"
27            fi
28        done
29    done
30    eval $VALGRIND ../boom "$args" "$@"
31}
32
33
34tst()
35{
36    echo -n "$1: " 1>&2
37    shift
38    cat >_in
39    run_boom "$@" >_out 2>&1 || {
40        echo FAILED "($SCRIPT)" 1>&2
41        cat _out
42        exit 1
43    }
44}
45
46
47tst_fail()
48{
49    echo -n "$1: " 1>&2
50    shift
51    cat >_in
52    run_boom "$@" >_out 2>&1 && {
53        echo FAILED "($SCRIPT)" 1>&2
54        cat _out
55        exit 1
56    }
57    rm -f _in
58}
59
60
61expect()
62{
63    diff -u - "$@" _out >_diff || {
64        echo FAILED "($SCRIPT)" 1>&2
65        cat _diff 1>&2
66        exit 1
67    }
68    echo PASSED 1>&2
69    rm -f _in _out _diff
70    passed=`expr ${passed:-0} + 1`
71}
72

Archive Download this file

Branches:
master



interactive