File: test_harness.sh

package info (click to toggle)
n2n 3.1.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,776 kB
  • sloc: ansic: 29,672; sh: 1,502; python: 621; makefile: 442; perl: 270; exp: 4
file content (47 lines) | stat: -rwxr-xr-x 1,110 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
#
# Run with the name of a test list file.
#
# This expects to find the tests in the tools dir or scripts dir and the
# expected results in the tests dir.

# boilerplate so we can support whaky cmake dirs
[ -z "$TOPDIR" ] && TOPDIR="."
[ -z "$BINDIR" ] && BINDIR="."
export TOPDIR
export BINDIR

if [ -z "$1" ]; then
    echo need test list filename
    exit 1
fi
TESTLIST="$1"
LISTDIR=$(dirname "$TESTLIST")

TESTS=$(sed -e "s/#.*//" "$TESTLIST")

# Actually run the tests
for i in $TESTS; do
    # Look in several places for the test program
    if [ -e "$BINDIR/$i" ]; then
        TEST="$BINDIR/$i"
    elif [ -e "$BINDIR/tools/$i" ]; then
        TEST="$BINDIR/tools/$i"
    elif [ -e "$LISTDIR/../scripts/$i" ]; then
        TEST="$LISTDIR/../scripts/$i"
    else
        echo "Could not find test $i"
        exit 1
    fi

    if [ ! -e "$LISTDIR/$i.expected" ]; then
        echo "Could not find testdata $LISTDIR/$i.expected"
        exit 1
    fi

    echo "$TEST >$LISTDIR/$i.out"
    set -e
    "$TEST" >"$LISTDIR/$i.out"
    cmp "$LISTDIR/$i.expected" "$LISTDIR/$i.out"
    set +e
done