| 1 |
#! /bin/sh
|
| 2 |
|
| 3 |
# This is a script for the use of PCRE maintainers. It configures and rebuilds
|
| 4 |
# PCRE with a variety of configuration options, and in each case runs the tests
|
| 5 |
# to ensure that all goes well. Every possible combination would take far too
|
| 6 |
# long, so we use a representative sample. This script should be run in the
|
| 7 |
# PCRE source directory.
|
| 8 |
|
| 9 |
# Some of the tests have to be skipped when PCRE is built with non-Unix newline
|
| 10 |
# recognition. I am planning to reduce this as much as possible in due course.
|
| 11 |
|
| 12 |
|
| 13 |
# This is in case the caller has set aliases (as I do - PH)
|
| 14 |
|
| 15 |
unset cp ls mv rm
|
| 16 |
|
| 17 |
# Use -v to make the output more verbose
|
| 18 |
|
| 19 |
verbose=0
|
| 20 |
if [ "$1" = "-v" ] ; then verbose=1; fi
|
| 21 |
|
| 22 |
# This is a temporary directory for testing out-of-line builds
|
| 23 |
|
| 24 |
tmp=/tmp/pcretesting
|
| 25 |
|
| 26 |
# Don't bother with compiler optimization; it just slows down compilation a lot
|
| 27 |
# (and these tests themselves are quick).
|
| 28 |
|
| 29 |
CFLAGS="-g -O0"
|
| 30 |
|
| 31 |
|
| 32 |
# This function runs a single test with the set of configuration options that
|
| 33 |
# are in $opts. The source directory must be set in srcdir.
|
| 34 |
|
| 35 |
function runtest()
|
| 36 |
{
|
| 37 |
rm -f *_unittest
|
| 38 |
testcount=`expr $testcount + 1`
|
| 39 |
|
| 40 |
if [ "$opts" = "" ] ; then
|
| 41 |
echo "[$testcount/$testtotal] Configuring with: default settings"
|
| 42 |
else
|
| 43 |
echo "[$testcount/$testtotal] Configuring with:"
|
| 44 |
echo " $opts"
|
| 45 |
fi
|
| 46 |
|
| 47 |
CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" \
|
| 48 |
$srcdir/configure $opts >/dev/null 2>teststderr
|
| 49 |
|
| 50 |
if [ $? -ne 0 ]; then
|
| 51 |
echo " "
|
| 52 |
echo "**** Error while configuring ****"
|
| 53 |
cat teststderr
|
| 54 |
exit 1
|
| 55 |
fi
|
| 56 |
|
| 57 |
echo "Making"
|
| 58 |
make >/dev/null 2>teststderr
|
| 59 |
if [ $? -ne 0 ]; then
|
| 60 |
echo " "
|
| 61 |
echo "**** Error while making ****"
|
| 62 |
cat teststderr
|
| 63 |
exit 1
|
| 64 |
fi
|
| 65 |
|
| 66 |
if [ $verbose -eq 1 ]; then
|
| 67 |
./pcretest -C
|
| 68 |
fi
|
| 69 |
|
| 70 |
nl=`./pcretest -C newline`
|
| 71 |
./pcretest -C jit >/dev/null
|
| 72 |
jit=$?
|
| 73 |
./pcretest -C utf >/dev/null
|
| 74 |
utf=$?
|
| 75 |
|
| 76 |
if [ "$nl" = "LF" -o "$nl" = "ANY" ]; then
|
| 77 |
echo "Running C library tests $withvalgrind"
|
| 78 |
$srcdir/RunTest $valgrind >teststdout
|
| 79 |
if [ $? -ne 0 ]; then
|
| 80 |
echo " "
|
| 81 |
echo "**** Test failed ****"
|
| 82 |
cat teststdout
|
| 83 |
exit 1
|
| 84 |
fi
|
| 85 |
else
|
| 86 |
echo "Skipping C library tests: newline is $nl"
|
| 87 |
fi
|
| 88 |
|
| 89 |
if [ "$nl" = "LF" ]; then
|
| 90 |
echo "Running pcregrep tests $withvalgrind"
|
| 91 |
$srcdir/RunGrepTest $valgrind >teststdout 2>teststderr
|
| 92 |
if [ $? -ne 0 ]; then
|
| 93 |
echo " "
|
| 94 |
echo "**** Test failed ****"
|
| 95 |
cat teststderr
|
| 96 |
cat teststdout
|
| 97 |
exit 1
|
| 98 |
fi
|
| 99 |
else
|
| 100 |
echo "Skipping pcregrep tests: newline is $nl"
|
| 101 |
fi
|
| 102 |
|
| 103 |
if [ "$jit" -gt 0 -a $utf -gt 0 ]; then
|
| 104 |
echo "Running JIT regression tests $withvalgrind"
|
| 105 |
$cvalgrind $srcdir/pcre_jit_test >teststdout 2>teststderr
|
| 106 |
if [ $? -ne 0 ]; then
|
| 107 |
echo " "
|
| 108 |
echo "**** Test failed ****"
|
| 109 |
cat teststderr
|
| 110 |
cat teststdout
|
| 111 |
exit 1
|
| 112 |
fi
|
| 113 |
else
|
| 114 |
echo "Skipping JIT regression tests: JIT or UTF not enabled"
|
| 115 |
fi
|
| 116 |
|
| 117 |
if [ "$nl" = "LF" -o "$nl" = "ANY" ]; then
|
| 118 |
if [ -f pcrecpp_unittest ] ; then
|
| 119 |
for utest in pcrecpp_unittest \
|
| 120 |
pcre_scanner_unittest \
|
| 121 |
pcre_stringpiece_unittest
|
| 122 |
do
|
| 123 |
echo "Running $utest $withvalgrind"
|
| 124 |
$cvalgrind $utest >teststdout
|
| 125 |
if [ $? -ne 0 ]; then
|
| 126 |
echo " "
|
| 127 |
echo "**** Test failed ****"
|
| 128 |
cat teststdout
|
| 129 |
exit 1
|
| 130 |
fi
|
| 131 |
done
|
| 132 |
else
|
| 133 |
echo "Skipping C++ tests: pcrecpp_unittest does not exist"
|
| 134 |
fi
|
| 135 |
else
|
| 136 |
echo "Skipping C++ tests: newline is $nl"
|
| 137 |
fi
|
| 138 |
}
|
| 139 |
|
| 140 |
|
| 141 |
# This set of tests builds PCRE and runs the tests with a variety of configure
|
| 142 |
# options, in the current (source) directory. The first (empty) configuration
|
| 143 |
# builds with all the default settings. As well as testing that these options
|
| 144 |
# work, we use --disable-shared or --disable-static after the first test (which
|
| 145 |
# builds both) to save a bit of time by building only one version of the
|
| 146 |
# library for the subsequent tests.
|
| 147 |
|
| 148 |
valgrind=
|
| 149 |
cvalgrind=
|
| 150 |
withvalgrind=
|
| 151 |
|
| 152 |
# Update the total count whenever a new test is added; it is used to show
|
| 153 |
# progess as each test is run.
|
| 154 |
|
| 155 |
testtotal=41
|
| 156 |
testcount=0
|
| 157 |
|
| 158 |
echo "Tests in the current directory"
|
| 159 |
srcdir=.
|
| 160 |
for opts in \
|
| 161 |
"" \
|
| 162 |
"--enable-utf8 --disable-static" \
|
| 163 |
"--disable-stack-for-recursion --disable-shared" \
|
| 164 |
"--enable-utf8 --disable-stack-for-recursion --disable-shared" \
|
| 165 |
"--enable-unicode-properties --disable-shared" \
|
| 166 |
"--enable-unicode-properties --disable-stack-for-recursion --disable-shared" \
|
| 167 |
"--enable-unicode-properties --disable-cpp --with-link-size=3 --disable-shared" \
|
| 168 |
"--enable-rebuild-chartables --disable-shared" \
|
| 169 |
"--enable-newline-is-any --disable-shared" \
|
| 170 |
"--enable-newline-is-cr --disable-shared" \
|
| 171 |
"--enable-newline-is-crlf --disable-shared" \
|
| 172 |
"--enable-newline-is-anycrlf --enable-bsr-anycrlf --disable-shared" \
|
| 173 |
"--enable-utf8 --enable-newline-is-any --enable-unicode-properties --disable-stack-for-recursion --disable-static --disable-cpp" \
|
| 174 |
"--enable-jit --disable-shared" \
|
| 175 |
"--enable-jit --enable-unicode-properties --disable-shared" \
|
| 176 |
"--enable-jit --enable-unicode-properties --with-link-size=3 --disable-shared" \
|
| 177 |
"--enable-pcre16" \
|
| 178 |
"--enable-pcre16 --enable-jit --enable-utf --disable-shared" \
|
| 179 |
"--enable-pcre16 --enable-jit --enable-unicode-properties --disable-shared" \
|
| 180 |
"--enable-pcre16 --enable-jit --disable-pcre8 --disable-shared" \
|
| 181 |
"--enable-pcre16 --enable-jit --disable-pcre8 --enable-utf --disable-shared" \
|
| 182 |
"--enable-pcre16 --disable-stack-for-recursion --disable-shared" \
|
| 183 |
"--enable-pcre16 --enable-unicode-properties --disable-stack-for-recursion --disable-shared" \
|
| 184 |
"--enable-pcre16 --enable-jit --enable-unicode-properties --with-link-size=3 --disable-shared" \
|
| 185 |
"--enable-pcre16 --enable-jit --enable-unicode-properties --with-link-size=4 --disable-shared" \
|
| 186 |
"--enable-pcre32" \
|
| 187 |
"--enable-pcre32 --enable-jit --enable-utf --disable-shared" \
|
| 188 |
"--enable-pcre32 --enable-jit --enable-unicode-properties --disable-shared" \
|
| 189 |
"--enable-pcre32 --enable-jit --disable-pcre8 --disable-shared" \
|
| 190 |
"--enable-pcre32 --enable-jit --disable-pcre8 --enable-utf --disable-shared" \
|
| 191 |
"--enable-pcre32 --disable-stack-for-recursion --disable-shared" \
|
| 192 |
"--enable-pcre32 --enable-unicode-properties --disable-stack-for-recursion --disable-shared" \
|
| 193 |
"--enable-pcre32 --enable-jit --enable-unicode-properties --with-link-size=4 --disable-shared" \
|
| 194 |
"--enable-pcre32 --enable-pcre16 --disable-shared" \
|
| 195 |
"--enable-pcre32 --enable-pcre16 --disable-pcre8 --disable-shared"
|
| 196 |
do
|
| 197 |
runtest
|
| 198 |
done
|
| 199 |
|
| 200 |
# Now re-run some of the tests under valgrind.
|
| 201 |
|
| 202 |
echo "Tests in the current directory using valgrind"
|
| 203 |
valgrind=valgrind
|
| 204 |
cvalgrind="valgrind -q --smc-check=all"
|
| 205 |
withvalgrind="with valgrind"
|
| 206 |
|
| 207 |
for opts in \
|
| 208 |
"--enable-unicode-properties --disable-stack-for-recursion --disable-shared" \
|
| 209 |
"--enable-unicode-properties --with-link-size=3 --disable-shared" \
|
| 210 |
"--enable-jit --enable-unicode-properties --disable-shared" \
|
| 211 |
"--enable-pcre16 --enable-pcre32 --enable-jit --enable-unicode-properties " \
|
| 212 |
"--disable-shared"
|
| 213 |
do
|
| 214 |
opts="--enable-valgrind $opts"
|
| 215 |
runtest
|
| 216 |
done
|
| 217 |
|
| 218 |
valgrind=
|
| 219 |
cvalgrind=
|
| 220 |
withvalgrind=
|
| 221 |
|
| 222 |
# Clean up the distribution and then do at least one build and test in a
|
| 223 |
# directory other than the source directory. It doesn't work unless the
|
| 224 |
# source directory is cleaned up first.
|
| 225 |
|
| 226 |
if [ -f Makefile ]; then
|
| 227 |
echo "Running 'make distclean'"
|
| 228 |
make distclean >/dev/null 2>&1
|
| 229 |
if [ $? -ne 0 ]; then
|
| 230 |
echo "** 'make distclean' failed"
|
| 231 |
exit 1
|
| 232 |
fi
|
| 233 |
fi
|
| 234 |
|
| 235 |
echo "Tests in the $tmp directory"
|
| 236 |
srcdir=`pwd`
|
| 237 |
export srcdir
|
| 238 |
|
| 239 |
if [ ! -e $tmp ]; then
|
| 240 |
mkdir $tmp
|
| 241 |
fi
|
| 242 |
|
| 243 |
if [ ! -d $tmp ]; then
|
| 244 |
echo "** Failed to create $tmp or it is not a directory"
|
| 245 |
exit 1
|
| 246 |
fi
|
| 247 |
|
| 248 |
cd $tmp
|
| 249 |
if [ $? -ne 0 ]; then
|
| 250 |
echo "** Failed to cd to $tmp"
|
| 251 |
exit 1
|
| 252 |
fi
|
| 253 |
|
| 254 |
for opts in \
|
| 255 |
"--enable-unicode-properties --disable-shared"
|
| 256 |
do
|
| 257 |
runtest
|
| 258 |
done
|
| 259 |
|
| 260 |
echo "Removing $tmp"
|
| 261 |
|
| 262 |
rm -rf $tmp
|
| 263 |
|
| 264 |
echo "All done"
|
| 265 |
|
| 266 |
# End
|