| 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 |
|
| 27 |
# This function runs a single test with the set of configuration options that
|
| 28 |
# are in $opts. The source directory must be set in srcdir.
|
| 29 |
|
| 30 |
function runtest()
|
| 31 |
{
|
| 32 |
rm -f *_unittest
|
| 33 |
|
| 34 |
if [ "$opts" = "" ] ; then
|
| 35 |
echo "Configuring with: default settings"
|
| 36 |
else
|
| 37 |
olen=`expr length "$opts"`
|
| 38 |
if [ $olen -gt 53 ] ; then
|
| 39 |
echo "Configuring with:"
|
| 40 |
echo " $opts"
|
| 41 |
else
|
| 42 |
echo "Configuring with: $opts"
|
| 43 |
fi
|
| 44 |
fi
|
| 45 |
|
| 46 |
$srcdir/configure $opts >/dev/null 2>teststderr
|
| 47 |
if [ $? -ne 0 ]; then
|
| 48 |
echo " "
|
| 49 |
echo "**** Error while configuring ****"
|
| 50 |
cat teststderr
|
| 51 |
exit 1
|
| 52 |
fi
|
| 53 |
|
| 54 |
echo "Making"
|
| 55 |
make >/dev/null 2>teststderr
|
| 56 |
if [ $? -ne 0 ]; then
|
| 57 |
echo " "
|
| 58 |
echo "**** Error while making ****"
|
| 59 |
cat teststderr
|
| 60 |
exit 1
|
| 61 |
fi
|
| 62 |
|
| 63 |
if [ $verbose -eq 1 ]; then
|
| 64 |
./pcretest -C
|
| 65 |
fi
|
| 66 |
|
| 67 |
conf=`./pcretest -C`
|
| 68 |
nl=`expr match "$conf" ".*Newline sequence is \([A-Z]*\)"`
|
| 69 |
|
| 70 |
if [ "$nl" = "LF" -o "$nl" = "ANY" ]; then
|
| 71 |
echo "Running C library tests"
|
| 72 |
$srcdir/RunTest >teststdout
|
| 73 |
if [ $? -ne 0 ]; then
|
| 74 |
echo " "
|
| 75 |
echo "**** Test failed ****"
|
| 76 |
cat teststdout
|
| 77 |
exit 1
|
| 78 |
fi
|
| 79 |
else
|
| 80 |
echo "Skipping C library tests: newline is $nl"
|
| 81 |
fi
|
| 82 |
|
| 83 |
if [ "$nl" = "LF" ]; then
|
| 84 |
echo "Running pcregrep tests"
|
| 85 |
$srcdir/RunGrepTest >teststdout 2>teststderr
|
| 86 |
if [ $? -ne 0 ]; then
|
| 87 |
echo " "
|
| 88 |
echo "**** Test failed ****"
|
| 89 |
cat teststderr
|
| 90 |
cat teststdout
|
| 91 |
exit 1
|
| 92 |
fi
|
| 93 |
else
|
| 94 |
echo "Skipping pcregrep tests: newline is $nl"
|
| 95 |
fi
|
| 96 |
|
| 97 |
if [ "$nl" = "LF" -o "$nl" = "ANY" ]; then
|
| 98 |
if [ -f pcrecpp_unittest ] ; then
|
| 99 |
for utest in pcrecpp_unittest \
|
| 100 |
pcre_scanner_unittest \
|
| 101 |
pcre_stringpiece_unittest
|
| 102 |
do
|
| 103 |
echo "Running $utest"
|
| 104 |
$utest >teststdout
|
| 105 |
if [ $? -ne 0 ]; then
|
| 106 |
echo " "
|
| 107 |
echo "**** Test failed ****"
|
| 108 |
cat teststdout
|
| 109 |
exit 1
|
| 110 |
fi
|
| 111 |
done
|
| 112 |
else
|
| 113 |
echo "Skipping C++ tests: pcrecpp_unittest does not exist"
|
| 114 |
fi
|
| 115 |
else
|
| 116 |
echo "Skipping C++ tests: newline is $nl"
|
| 117 |
fi
|
| 118 |
}
|
| 119 |
|
| 120 |
|
| 121 |
# This set of tests builds PCRE and runs the tests with a variety of configure
|
| 122 |
# options, in the current (source) directory. The first (empty) configuration
|
| 123 |
# builds with all the default settings. As well as testing that these options
|
| 124 |
# work, we use --disable-shared or --disable-static after the first test (which
|
| 125 |
# builds both) to save a bit of time by building only one version of the
|
| 126 |
# library for the subsequent tests.
|
| 127 |
|
| 128 |
echo "Tests in the current directory"
|
| 129 |
srcdir=.
|
| 130 |
for opts in \
|
| 131 |
"" \
|
| 132 |
"--enable-utf8 --disable-static" \
|
| 133 |
"--enable-unicode-properties --disable-shared" \
|
| 134 |
"--enable-unicode-properties --disable-stack-for-recursion --disable-shared" \
|
| 135 |
"--enable-unicode-properties --disable-cpp --with-link-size=3 --disable-shared" \
|
| 136 |
"--enable-rebuild-chartables --disable-shared" \
|
| 137 |
"--enable-newline-is-any --disable-shared" \
|
| 138 |
"--enable-newline-is-cr --disable-shared" \
|
| 139 |
"--enable-newline-is-crlf --disable-shared" \
|
| 140 |
"--enable-newline-is-anycrlf --disable-shared" \
|
| 141 |
"--enable-utf8 --enable-newline-is-any --enable-unicode-properties --disable-stack-for-recursion --disable-static --disable-cpp"
|
| 142 |
do
|
| 143 |
runtest
|
| 144 |
done
|
| 145 |
|
| 146 |
|
| 147 |
# Clean up the distribution and then do at least one build and test in a
|
| 148 |
# directory other than the source directory. It doesn't work unless the
|
| 149 |
# source directory is cleaned up first - and anyway, it's best to leave it
|
| 150 |
# in a clean state after all this reconfiguring.
|
| 151 |
|
| 152 |
if [ -f Makefile ]; then
|
| 153 |
echo "Running 'make distclean'"
|
| 154 |
make distclean >/dev/null 2>&1
|
| 155 |
if [ $? -ne 0 ]; then
|
| 156 |
echo "** 'make distclean' failed"
|
| 157 |
exit 1
|
| 158 |
fi
|
| 159 |
fi
|
| 160 |
|
| 161 |
echo "Tests in the $tmp directory"
|
| 162 |
srcdir=`pwd`
|
| 163 |
export srcdir
|
| 164 |
|
| 165 |
if [ ! -e $tmp ]; then
|
| 166 |
mkdir $tmp
|
| 167 |
fi
|
| 168 |
|
| 169 |
if [ ! -d $tmp ]; then
|
| 170 |
echo "** Failed to create $tmp or it is not a directory"
|
| 171 |
exit 1
|
| 172 |
fi
|
| 173 |
|
| 174 |
cd $tmp
|
| 175 |
if [ $? -ne 0 ]; then
|
| 176 |
echo "** Failed to cd to $tmp"
|
| 177 |
exit 1
|
| 178 |
fi
|
| 179 |
|
| 180 |
for opts in \
|
| 181 |
"--enable-unicode-properties --disable-shared"
|
| 182 |
do
|
| 183 |
runtest
|
| 184 |
done
|
| 185 |
|
| 186 |
echo "Removing $tmp"
|
| 187 |
|
| 188 |
rm -rf $tmp
|
| 189 |
|
| 190 |
echo "All done"
|
| 191 |
|
| 192 |
# End
|