File: test.sh

package info (click to toggle)
bgpdump 1.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 580 kB
  • sloc: ansic: 8,055; makefile: 118; sh: 96
file content (74 lines) | stat: -rwxr-xr-x 1,880 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh

FAILURES=0

DIR="${1:-.}"
BGPDUMP="${2:-./bgpdump}"

if [ ! -d "$DIR" ] ; then
    echo "Not a directory: $DIR"
    exit 2
fi

if [ -x "$(which gzcat)" ] ; then
    ZCAT=gzcat
elif [ -x "$(which zcat)" ] ; then
    ZCAT=zcat
else
    echo "Have neither zcat or gzcat"
    exit 2
fi

mkdir -p "$DIR/test_out"

echo "Running Regression Tests..."
for mrt in $(find "$DIR/test_data/" -maxdepth 1 -type f -printf '%f\n' | grep -E '\.(gz|bz2|xz)' | sort) ; do
    echo -n "      testing $mrt..."
    OUT=$mrt.bgp
    "$BGPDUMP" -vm "$DIR/test_data/$mrt" > "$DIR/test_out/$OUT"
    if [ -f "$DIR/test_expect/$OUT.gz" ] ; then
        EXT=gz
        CAT="$ZCAT"
    elif [ -f "$DIR/test_expect/$OUT.bz2" ] ; then
        EXT=bz2
        CAT='bzcat'
    elif [ -f "$DIR/test_expect/$OUT.xz" ] ; then
        EXT=xz
        CAT='xzcat'
    else
        echo "Have no expect data"
        exit 2
    fi

    "$CAT" "$DIR/test_expect/$OUT.$EXT" | diff -q "$DIR/test_out/$OUT" -
    if [ $? = 0 ]; then
        echo "success"
    else
        FAILURES=$(( $FAILURES + 1 ))
    fi
done

if [ ! -z "$BGPDUMP_TEST_UATTR" ] ; then
for mrt in $(find "$DIR/test_data/" -maxdepth 1 -type f -printf '%f\n' | grep -E '\.(gz|bz2|xz)' | sort) ; do
    printf "      testing -u %s..." "$mrt"
    OUT="$mrt.bgp.gz"
    # The pipe into sed removes the last field added by -u on table dump
    # and announcement (update files) lines, and allows us to chekc
    # everything else is the same without adding new test_expect files
    # to the repository.
    "$BGPDUMP" -u -vm test_data/$mrt | sed '/|A\|B|/ s/|[^|]*|$/|/' > test_out/$OUT
    gzip -cd test_expect/$OUT | diff -q test_out/$OUT -
    if [ $? = 0 ]; then
        echo "success"
    else
        FAILURES=$(( FAILURES + 1 ))
    fi
done
fi

if [ $FAILURES != 0 ]; then
    echo !!! $FAILURES failures !!!
    exit 1
else
    exit 0
fi