#!/bin/sh

. ${srcdir=.}/t.frame

CFG="$TMPDIR"/test.cf
OUT="$TMPDIR/test.out"
CORRECT="$SYSTEST/outputs/message_addr.ref"

cat <<EOF > "$CFG"
# include message's ip address
# suppress timestamps & version info in output
header_format=%h: %c, message_addr=%A
EOF

# build wordlists
$BOGOFILTER -n -v -D -c "$CFG" -M -B "$srcdir/inputs/good.mbx" > /dev/null
$BOGOFILTER -s -v -D -c "$CFG" -M -B "$srcdir/inputs/spam.mbx" > /dev/null

$BOGOFILTER -v -D -c "$CFG" -M -B "$srcdir/inputs/good.mbx" \
    "$srcdir/inputs/spam.mbx" \
| sed 's}.*/inputs/}inputs/}' > "$OUT"

# compare test output to reference output

if  [ $verbose -eq 0 ]; then
    diff "$CORRECT" "$OUT"
    cmp  "$CORRECT" "$OUT"
else
    diff $DIFF_BRIEF "$CORRECT" "$OUT"
fi
