Debian Codegraph @

src/tests/t.bogodir

raw
1 #! /bin/sh
2
3 # Note: When run via "make check", test output files are automatically deleted.
4 # When run from the command line, output files are left in directory
5 # bogodir.YYYYMMDD. This is useful when something is different.
6
7 . ${srcdir=.}/t.frame
8
9 HOME="$TMPDIR/home"
10 mkdir "$HOME"
11 export HOME
12
13 LOG="$TMPDIR/bogodir.log"
14 cat /dev/null >"$LOG"
15
16 map_rc()
17 {
18 (
19 set +e
20 echo >> "$LOG" "$@"
21 echo >> "$LOG" "### expect: $expect"
22 result=`"$@" 2>&1 | tee -a "$LOG" | grep open | head -1`
23 ok=`echo "$result" | grep "$expect"`
24 if [ -n "$ok" ] ; then
25 echo >>"$LOG" "### ok: $ok"
26 echo >>"$LOG" "PASS"
27 else
28 echo >>"$LOG" "### got '$result'"
29 echo >>"$LOG" "FAIL"
30 fi
31 echo >> "$LOG" ""
32
33 [ -z "$ok" ] && rc=1
34 [ -n "$ok" ] && rc=0
35 exit $rc
36 )
37 }
38
39 #standard test (bogodir.log=3225)
40 OPTS=" -x d -vv -D"
41
42 #a bit more info (bogodir.log=5071)
43 #OPTS=" -x dcw -vvv -D"
44
45 #everything (bogodir.log=5416)
46 #OPTS=" -x cdfghlmrstw -vvvv -D"
47
48 # just $HOME should display /home/userid
49 unset BOGOFILTER_DIR
50 expect="$HOME/.bogofilter"
51 map_rc $BOGOFILTER $OPTS -C < /dev/null
52
53 cat <<EOF >"$TMPDIR/bogodir.cf"
54 bogofilter_dir=$TMPDIR/bogoconf.d
55 EOF
56
57 # config file should display "command"
58 expect="$TMPDIR/bogoconf.d"
59 map_rc $BOGOFILTER $OPTS -c "$TMPDIR/bogodir.cf" < /dev/null
60
61 # command line and config file should display "command.d"
62 expect="$TMPDIR/command.d"
63 map_rc $BOGOFILTER $OPTS -c "$TMPDIR/bogodir.cf" -d "$TMPDIR/command.d" < /dev/null
64
65 # $HOME and $BOGOFILTER_DIR should display $TMPDIR
66
67 expect="$BOGOFILTER_DIR"
68 map_rc $BOGOFILTER $OPTS -C < /dev/null
69 map_rc $BOGOFILTER $OPTS -c "$TMPDIR/bogodir.cf" < /dev/null
70
71 # command line should display "command.d"
72 expect="$TMPDIR/command.d"
73 map_rc $BOGOFILTER $OPTS -C -d "$TMPDIR/command.d" < /dev/null
74 map_rc $BOGOFILTER $OPTS -c "$TMPDIR/bogodir.cf" -d "$TMPDIR/command.d" < /dev/null
75
76 # test whether command line supercedes bogus config file entry
77 cat <<EOF >"$TMPDIR/bogodir.cf"
78 bogofilter_dir=$TMPDIR/bogus
79 wordlist r,word,wordlist.$DB_EXT,1
80 EOF
81
82 map_rc $BOGOFILTER $OPTS -c "$TMPDIR/bogodir.cf" -d "$TMPDIR/command.d" -v < /dev/null
83 test ! -d "$TMPDIR/bogus"