Debian Codegraph @

src/tests/t.passthrough-hb

raw
1 #! /bin/sh
2
3 . ${srcdir:=.}/t.frame
4
5 # t.passthrough-hb
6 #
7 # test for correct detection of line separating header and body
8
9 $BOGOFILTER -e -p -C < "$srcdir/inputs/headerbody.txt" > "$TMPDIR/output"
10 $AWK '/^X-Bogosity:/ { bl=NR } \
11 /^Summary:/ { sl=NR } \
12 END { if (sl > bl) { exit 1; } }' \
13 < "$TMPDIR"/output
14
15 CFG="$TMPDIR/test.cf"
16
17 cat >> "$CFG" <<EOF
18 header_format = %h: %c, tests=bogofilter, spamicity=%p
19 EOF
20
21 # test two additional scenarios
22 # - one with a body
23 # - one with no body
24
25 cat > "$TMPDIR"/reference.2 <<EOF
26 Header: body and empty line
27 head2
28 Another-Header: head3
29
30 after non-empty blank -- X-Bogosity should be next
31 X-Bogosity: Unsure, tests=bogofilter, spamicity=0.520000
32
33 after empty line
34 EOF
35
36 cat > "$TMPDIR/reference.3" <<EOF
37 Header: no body
38 head2
39 Another-Header: head3 -- X-Bogosity should be next
40 X-Bogosity: Unsure, tests=bogofilter, spamicity=0.520000
41
42 after non-empty blank
43
44 no body
45 EOF
46
47 cat <<EOF |tr "^" "\r" > "$TMPDIR"/reference.4
48 Header: no body^
49 head2^
50 Another-Header: head4 -- X-Bogosity should be next^
51 X-Bogosity: Unsure, tests=bogofilter, spamicity=0.520000^
52 ^
53 after non-empty blank^
54 ^
55 no body^
56 EOF
57
58 printf "Header: body and empty line\n head2\nAnother-Header: head3\n \nafter non-empty blank -- X-Bogosity should be next\n\nafter empty line" > "$TMPDIR/input.2"
59 $BOGOFILTER -e -p -c "$CFG" < "$TMPDIR"/input.2 > "$TMPDIR/results.2"
60
61 printf "Header: no body\n head2\nAnother-Header: head3 -- X-Bogosity should be next\n \nafter non-empty blank\n \nno body" > "$TMPDIR/input.3"
62 $BOGOFILTER -e -p -c "$CFG" < "$TMPDIR"/input.3 > "$TMPDIR/results.3"
63
64 printf "Header: no body\r\n head2\r\nAnother-Header: head4 -- X-Bogosity should be next\r\n \r\nafter non-empty blank\r\n \r\nno body" > "$TMPDIR/input.4"
65 $BOGOFILTER -e -p -c "$CFG" < "$TMPDIR"/input.4 > "$TMPDIR/results.4"
66
67 for f in 2 3 4 ; do
68 if [ $verbose -eq 0 ]; then
69 cmp "$TMPDIR/reference.$f" "$TMPDIR/results.$f"
70 else
71 set +e
72 diff $DIFF_BRIEF "$TMPDIR"/reference.$f "$TMPDIR/results.$f"
73 fi
74 done