File: testall.sh

package info (click to toggle)
sanitizer 1.76-3
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, squeeze, wheezy
  • size: 940 kB
  • ctags: 184
  • sloc: perl: 5,276; sh: 2,107; makefile: 51
file content (158 lines) | stat: -rwxr-xr-x 4,342 bytes parent folder | download | duplicates (3)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/sh

# Debian
LC_ALL=C
export LC_ALL

# Set default variables.
#
FAILED=0
[ "$TEST_RESULTS" = "" ] && TEST_RESULTS=results.def
ANOMY=/usr
PERL5LIB=
export ANOMY PERL5LIB

# Charset related issues.
if (echo $LANG | grep -c -i utf >/dev/null); then
    echo
    echo "WARNING: Your default language setting is $LANG, which may enable"
    echo "UTF-8 (unicode) support in various programs, including Perl.  This"
    echo "may cause the Anomy Sanitizer to malfunction."
    echo "Please read the file UNICODE.TXT for further information."
    echo
    sleep 5
fi
LC_ALL=C
LANG=en_US
export LC_ALL LANG

# Do we have/need the TNEF stuff?
TNEF=0
[ -e ../bin/Anomy/TNEFStream.pm ] && TNEF=1

# Does "use bytes" work?
if ! perl -Mbytes -e 1 2>/dev/null >/dev/null; then
    echo "WARNING: Your perl is old, creating dummy 'bytes' module..."
    echo "package bytes; sub unimport { 1; } 1;" > $ANOMY/bin/bytes.pm
fi
# Does "use warnings" work?
if ! perl -Mwarnings -e 1 2>/dev/null >/dev/null; then
    echo "WARNING: Your perl is old, creating dummy 'warnings' module..."
    echo "package warnings; sub unimport { 1; } 1;" > $ANOMY/bin/warnings.pm
fi

# Check prerequisites.
#
echo -n "Checking prerequisites... "
REQ="-MDigest::MD5 -MMIME::Base64 -MMIME::QuotedPrint -MIO::File -MIO::Socket::INET"
[ $TNEF = 1 ] && REQ="$REQ -MMIME::Body"
perl $REQ -e1 2>/dev/null
if [ $? != 0 ] ; then
    echo failed.
    echo
    echo "One or more of the following Perl modules were missing from your"
    echo "system.  You need to install them before you can use the Anomy"
    echo "Mail Sanitizer:"
    echo
    echo "    IO::File"
    echo "    IO::Socket::INET"
[ $TNEF = 1 ] && \
    echo "    MIME::Body"
    echo "    MIME::Base64"
    echo "    MIME::QuotedPrint"
    echo "    Digest::MD5"
    echo
    echo "Try 'perldoc CPAN' for information on how to obtain them.  But"
    echo "beware - the CPAN module likes to upgrade your perl installation,"
    echo "which may not be what you want. :-)"
    echo
    exit 1
else
    echo ok.
fi

# Load local configuration, if it exists.
#
if [ -f tests.conf ]; then
    . tests.conf
    echo "Using configuration from tests.conf - results go in $TEST_RESULTS."
fi
export TEST_RESULTS SAN_CONF

# Minor sanity checks...
#
if [ ! -d "$TEST_RESULTS" ]; then
    echo "No such directory: $TEST_RESULTS"
    exit 1
fi
if [ "$SAN_CONF" != "" -a ! -r "$SAN_CONF" ]; then
    echo "No such file: $SAN_CONF"
    exit 1
fi

# Run tests!
#
WHICH=$1
echo "Running tests ..."
echo
for a in *.t; do
  if [ "$WHICH" = "" -o "$a" = "$WHICH" ]; then
        test=`echo $a |sed -e 's/\.t$//'`
	/bin/echo -n "$test:	"
	sh $a
	if [ -e "$TEST_RESULTS/$test.ok.rot13" ]; then
            perl -npe 'tr/a-zA-Z/n-za-mN-ZA-M/' \
              < "$TEST_RESULTS/$test.ok.rot13" > "$TEST_RESULTS/$test.ok"
        fi
	if [ ! -f "$TEST_RESULTS/$test.ok" ]; then
	    cp test.out "$TEST_RESULTS/$test.ok"
	    echo installed
            
        else
	    if diff -u -b "$TEST_RESULTS/$test.ok" test.out >test.diff; then
	        T="$TEST_RESULTS/$test"
	        rm -f test.* $T.out $T.log $T.diff
	        echo ok
            else
		for t in test.*; do
		    mv -f $t "$TEST_RESULTS"/`echo $t |sed -e "s/^test/$test/"`
		done
	        echo "failed  (moved result files to $TEST_RESULTS)"
	 	FAILED=$(($FAILED+1))
	    fi
        fi
	[ -e "$TEST_RESULTS/$test.ok.rot13" ] && rm -f "$TEST_RESULTS/$test.ok" 
  fi
done

rm -f test.*
echo
[ $FAILED = 0 ] && exit 0

# Beg for feedback...
#
cat <<tac
One or more tests failed!  There are two possible reasons for this:

 1) Something was fixed, and your test-case results need to be updated.
 2) I (the author) broke something.

Please check the change-log to see which it is.  If it's number 1), then
just replace the .ok file with the .out file generated by the failed test,
in your result directory.

Otherwise - if you think something is broken (case 2), please send the
following info to anomy-bugs@mailtools.anomy.net:

 - Architecture (e.g. Sparc, Intel, Alpha. ...)
 - Operating system (e.g. RedHat 6.2, Solaris 8, HP-UX, ...)
 - Perl version (the output of "perl -V")
 - Any relevant Anomy configuration files (e.g. for the sanitizer).
 - Copies of all result files for the failed tests (they should have the
   extensions .ok, .out, .diff and .log).

Thanks!

tac
exit 1