2014-05-13 07:20:03 -04:00
|
|
|
#! /bin/sh
|
|
|
|
|
2014-08-10 12:09:24 -04:00
|
|
|
# This is a script for the use of PCRE2 maintainers. It configures and rebuilds
|
2014-05-13 07:20:03 -04:00
|
|
|
# PCRE2 with a variety of configuration options, and in each case runs the
|
|
|
|
# tests to ensure that all goes well. Every possible combination would take far
|
|
|
|
# too long, so we use a representative sample. This script should be run in the
|
|
|
|
# PCRE2 source directory.
|
|
|
|
|
2014-08-10 12:09:24 -04:00
|
|
|
# While debugging, it is sometimes useful to be able to cut out some of the
|
|
|
|
# tests, in order to run those that are giving errors. The following options
|
|
|
|
# do this:
|
|
|
|
#
|
|
|
|
# -nojit skip JIT tests
|
|
|
|
# -nomain skip the main set of tests
|
|
|
|
# -notmp skip the test in a temporary directory
|
|
|
|
# -novalgrind skip the valgrind tests
|
|
|
|
|
|
|
|
# The -v option causes a call to 'pcre2test -C' to happen for each
|
|
|
|
# configuration.
|
|
|
|
|
|
|
|
# Some of the tests are automatically skipped when PCRE2 is built with non-Unix
|
|
|
|
# newline recognition because they don't work. I am hoping to reduce this as
|
|
|
|
# much as possible in due course.
|
|
|
|
|
|
|
|
usejit=1
|
|
|
|
usemain=1
|
|
|
|
usetmp=1
|
|
|
|
usevalgrind=1
|
|
|
|
verbose=0
|
2014-05-13 07:20:03 -04:00
|
|
|
|
2014-08-10 12:09:24 -04:00
|
|
|
while [ $# -gt 0 ] ; do
|
|
|
|
case $1 in
|
|
|
|
-nojit) usejit=0;;
|
|
|
|
-nomain) usemain=0;;
|
|
|
|
-notmp) usetmp=0;;
|
|
|
|
-novalgrind) usevalgrind=0;;
|
|
|
|
-v) verbose=1;;
|
|
|
|
*) echo "Unknown option '$1'"; exit 1;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2014-05-13 07:20:03 -04:00
|
|
|
|
|
|
|
# This is in case the caller has set aliases (as I do - PH)
|
|
|
|
|
|
|
|
unset cp ls mv rm
|
|
|
|
|
|
|
|
# This is a temporary directory for testing out-of-line builds
|
|
|
|
|
2014-08-10 12:09:24 -04:00
|
|
|
tmp=/tmp/pcre2testing
|
2014-05-13 07:20:03 -04:00
|
|
|
|
|
|
|
# Don't bother with compiler optimization for most tests; it just slows down
|
2014-08-10 12:09:24 -04:00
|
|
|
# compilation a lot (and running the tests themselves is quick). However, one
|
|
|
|
# special test turns optimization on, because it can provoke some compiler
|
2014-05-13 07:20:03 -04:00
|
|
|
# warnings.
|
|
|
|
|
|
|
|
CFLAGS="-g -O0"
|
2014-08-10 12:09:24 -04:00
|
|
|
ISGCC=0
|
2014-05-13 07:20:03 -04:00
|
|
|
|
|
|
|
# If the compiler is gcc, add a lot of warning switches.
|
|
|
|
|
|
|
|
cc --version >zzz 2>/dev/null
|
|
|
|
if [ $? -eq 0 ] && grep GCC zzz >/dev/null; then
|
2014-08-10 12:09:24 -04:00
|
|
|
ISGCC=1
|
2014-05-13 07:20:03 -04:00
|
|
|
CFLAGS="$CFLAGS -Wall"
|
|
|
|
CFLAGS="$CFLAGS -Wno-overlength-strings"
|
|
|
|
CFLAGS="$CFLAGS -Wpointer-arith"
|
|
|
|
CFLAGS="$CFLAGS -Wwrite-strings"
|
|
|
|
CFLAGS="$CFLAGS -Wundef -Wshadow"
|
|
|
|
CFLAGS="$CFLAGS -Wmissing-field-initializers"
|
2014-08-10 12:09:24 -04:00
|
|
|
CFLAGS="$CFLAGS -Wunused-parameter"
|
2014-05-13 07:20:03 -04:00
|
|
|
CFLAGS="$CFLAGS -Wextra -Wformat"
|
|
|
|
CFLAGS="$CFLAGS -Wbad-function-cast"
|
|
|
|
CFLAGS="$CFLAGS -Wmissing-declarations"
|
|
|
|
CFLAGS="$CFLAGS -Wnested-externs"
|
|
|
|
CFLAGS="$CFLAGS -pedantic"
|
|
|
|
CFLAGS="$CFLAGS -Wuninitialized"
|
|
|
|
CFLAGS="$CFLAGS -Wmissing-prototypes"
|
|
|
|
CFLAGS="$CFLAGS -Wstrict-prototypes"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# This function runs a single test with the set of configuration options that
|
|
|
|
# are in $opts. The source directory must be set in srcdir.
|
|
|
|
|
|
|
|
function runtest()
|
|
|
|
{
|
|
|
|
rm -f *_unittest
|
|
|
|
testcount=`expr $testcount + 1`
|
|
|
|
|
|
|
|
if [ "$opts" = "" ] ; then
|
|
|
|
echo "[$testcount/$testtotal] Configuring with: default settings"
|
|
|
|
else
|
|
|
|
echo "[$testcount/$testtotal] Configuring with:"
|
|
|
|
echo " $opts"
|
|
|
|
fi
|
|
|
|
|
2014-08-10 12:09:24 -04:00
|
|
|
CFLAGS="$CFLAGS" \
|
2014-05-13 07:20:03 -04:00
|
|
|
$srcdir/configure $opts >/dev/null 2>teststderr
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo " "
|
2014-08-10 12:09:24 -04:00
|
|
|
echo "******** Error while configuring ********"
|
2014-05-13 07:20:03 -04:00
|
|
|
cat teststderr
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Making"
|
|
|
|
make -j >/dev/null 2>teststderr
|
|
|
|
if [ $? -ne 0 -o -s teststderr ]; then
|
|
|
|
echo " "
|
2014-08-10 12:09:24 -04:00
|
|
|
echo "******** Errors or warnings while making ********"
|
2014-05-13 07:20:03 -04:00
|
|
|
echo " "
|
|
|
|
cat teststderr
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $verbose -eq 1 ]; then
|
|
|
|
./pcre2test -C
|
|
|
|
fi
|
|
|
|
|
|
|
|
nl=`./pcre2test -C newline`
|
2014-08-10 12:09:24 -04:00
|
|
|
./pcre2test -C jit >/dev/null
|
2014-05-13 07:20:03 -04:00
|
|
|
jit=$?
|
|
|
|
./pcre2test -C utf >/dev/null
|
|
|
|
utf=$?
|
|
|
|
|
|
|
|
if [ "$nl" = "LF" -o "$nl" = "ANY" ]; then
|
|
|
|
echo "Running C library tests $withvalgrind"
|
|
|
|
$srcdir/RunTest $valgrind >teststdout
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo " "
|
|
|
|
echo "**** Test failed ****"
|
|
|
|
cat teststdout
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Skipping C library tests: newline is $nl"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$nl" = "LF" ]; then
|
|
|
|
echo "Running pcre2grep tests $withvalgrind"
|
|
|
|
$srcdir/RunGrepTest $valgrind >teststdout 2>teststderr
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo " "
|
|
|
|
echo "**** Test failed ****"
|
|
|
|
cat teststderr
|
|
|
|
cat teststdout
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Skipping pcre2grep tests: newline is $nl"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$jit" -gt 0 -a $utf -gt 0 ]; then
|
|
|
|
echo "Running JIT regression tests $withvalgrind"
|
|
|
|
$cvalgrind $srcdir/pcre2_jit_test >teststdout 2>teststderr
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo " "
|
|
|
|
echo "**** Test failed ****"
|
|
|
|
cat teststderr
|
|
|
|
cat teststdout
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Skipping JIT regression tests: JIT or UTF not enabled"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Update the total count whenever a new test is added; it is used to show
|
|
|
|
# progess as each test is run.
|
|
|
|
|
2014-08-10 12:09:24 -04:00
|
|
|
testtotal=`expr 20 \* $usemain + \
|
|
|
|
1 \* $usetmp + \
|
|
|
|
1 \* $ISGCC \* $usemain + \
|
|
|
|
13 \* $usejit + \
|
|
|
|
\( 3 + 2 \* $usejit \) \* $usevalgrind`
|
2014-05-13 07:20:03 -04:00
|
|
|
testcount=0
|
|
|
|
|
2014-08-10 12:09:24 -04:00
|
|
|
# This set of tests builds PCRE2 and runs the tests with a variety of configure
|
2014-05-13 07:20:03 -04:00
|
|
|
# options, in the current (source) directory. The empty configuration builds
|
|
|
|
# with all the default settings. As well as testing that these options work, we
|
|
|
|
# use --disable-shared or --disable-static after the default test (which builds
|
|
|
|
# both) to save a bit of time by building only one version of the library for
|
|
|
|
# the subsequent tests.
|
|
|
|
|
|
|
|
valgrind=
|
|
|
|
cvalgrind=
|
|
|
|
withvalgrind=
|
|
|
|
srcdir=.
|
|
|
|
export srcdir
|
|
|
|
|
|
|
|
# If gcc is in use, run a maximally configured test with -O2, because that can
|
|
|
|
# throw up warnings that are not detected with -O0.
|
|
|
|
|
2014-08-10 12:09:24 -04:00
|
|
|
if [ $usejit -ne 0 ]; then
|
|
|
|
enable_jit=--enable-jit
|
|
|
|
else
|
|
|
|
enable_jit=
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $ISGCC -ne 0 -a $usemain -ne 0 ]; then
|
|
|
|
echo "---------- Maximally configured test with -O2 ----------"
|
2014-05-13 07:20:03 -04:00
|
|
|
SAVECLFAGS="$CFLAGS"
|
|
|
|
CFLAGS="$CFLAGS -O2"
|
2014-09-19 03:43:39 -04:00
|
|
|
opts="--disable-shared --enable-unicode $enable_jit --enable-pcre16 --enable-pcre32"
|
2014-05-13 07:20:03 -04:00
|
|
|
runtest
|
|
|
|
CFLAGS="$SAVECFLAGS"
|
|
|
|
fi
|
|
|
|
|
2014-08-10 12:09:24 -04:00
|
|
|
if [ $usemain -ne 0 ]; then
|
|
|
|
echo "---------- Non-JIT tests in the current directory ----------"
|
|
|
|
for opts in \
|
|
|
|
"" \
|
2014-09-19 03:43:39 -04:00
|
|
|
"--enable-unicode --disable-static" \
|
2014-08-10 12:09:24 -04:00
|
|
|
"--disable-stack-for-recursion --disable-shared" \
|
2014-09-19 03:43:39 -04:00
|
|
|
"--enable-unicode --disable-shared" \
|
|
|
|
"--enable-unicode --disable-stack-for-recursion --disable-shared" \
|
|
|
|
"--enable-unicode --with-link-size=3 --disable-shared" \
|
2014-08-10 12:09:24 -04:00
|
|
|
"--enable-rebuild-chartables --disable-shared" \
|
|
|
|
"--enable-newline-is-any --disable-shared" \
|
|
|
|
"--enable-newline-is-cr --disable-shared" \
|
|
|
|
"--enable-newline-is-crlf --disable-shared" \
|
|
|
|
"--enable-newline-is-anycrlf --enable-bsr-anycrlf --disable-shared" \
|
2014-09-19 03:43:39 -04:00
|
|
|
"--enable-unicode --enable-newline-is-any --disable-stack-for-recursion --disable-static" \
|
2014-08-10 12:09:24 -04:00
|
|
|
"--enable-pcre16" \
|
|
|
|
"--enable-pcre16 --disable-stack-for-recursion --disable-shared" \
|
2014-09-19 03:43:39 -04:00
|
|
|
"--enable-pcre16 --enable-unicode --disable-stack-for-recursion --disable-shared" \
|
2014-08-10 12:09:24 -04:00
|
|
|
"--enable-pcre32" \
|
|
|
|
"--enable-pcre32 --disable-stack-for-recursion --disable-shared" \
|
2014-09-19 03:43:39 -04:00
|
|
|
"--enable-pcre32 --enable-unicode --disable-stack-for-recursion --disable-shared" \
|
2014-08-10 12:09:24 -04:00
|
|
|
"--enable-pcre32 --enable-pcre16 --disable-shared" \
|
|
|
|
"--enable-pcre32 --enable-pcre16 --disable-pcre8 --disable-shared"
|
|
|
|
do
|
|
|
|
runtest
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Now run the JIT tests unless disabled
|
|
|
|
|
|
|
|
if [ $usejit -ne 0 ]; then
|
|
|
|
echo "---------- JIT tests in the current directory ----------"
|
|
|
|
for opts in \
|
|
|
|
"--enable-jit --disable-shared" \
|
2014-09-19 03:43:39 -04:00
|
|
|
"--enable-jit --enable-unicode --disable-shared" \
|
|
|
|
"--enable-jit --enable-unicode --with-link-size=3 --disable-shared" \
|
|
|
|
"--enable-jit --enable-pcre16 --enable-unicode --disable-shared" \
|
2014-08-10 12:09:24 -04:00
|
|
|
"--enable-jit --enable-pcre16 --disable-pcre8 --disable-shared" \
|
2014-09-19 03:43:39 -04:00
|
|
|
"--enable-jit --enable-pcre16 --disable-pcre8 --enable-unicode --disable-shared" \
|
|
|
|
"--enable-jit --enable-pcre16 --enable-unicode --with-link-size=3 --disable-shared" \
|
|
|
|
"--enable-jit --enable-pcre16 --enable-unicode --with-link-size=4 --disable-shared" \
|
|
|
|
"--enable-jit --enable-pcre32 --enable-unicode --disable-shared" \
|
2014-08-10 12:09:24 -04:00
|
|
|
"--enable-jit --enable-pcre32 --disable-pcre8 --disable-shared" \
|
2014-09-19 03:43:39 -04:00
|
|
|
"--enable-jit --enable-pcre32 --disable-pcre8 --enable-unicode --disable-shared" \
|
|
|
|
"--enable-jit --enable-pcre32 --enable-unicode --with-link-size=4 --disable-shared" \
|
|
|
|
"--enable-jit --enable-pcre32 --enable-pcre16 --disable-pcre8 --enable-unicode --enable-newline-is-anycrlf --enable-bsr-anycrlf --disable-shared"
|
2014-08-10 12:09:24 -04:00
|
|
|
do
|
|
|
|
runtest
|
|
|
|
done
|
|
|
|
fi
|
2014-05-13 07:20:03 -04:00
|
|
|
|
|
|
|
# Now re-run some of the tests under valgrind.
|
|
|
|
|
2014-08-10 12:09:24 -04:00
|
|
|
if [ $usevalgrind -ne 0 ]; then
|
|
|
|
echo "---------- Tests in the current directory using valgrind ----------"
|
|
|
|
valgrind=valgrind
|
|
|
|
cvalgrind="valgrind -q --smc-check=all"
|
|
|
|
withvalgrind="with valgrind"
|
|
|
|
|
|
|
|
for opts in \
|
2014-09-19 03:43:39 -04:00
|
|
|
"--enable-unicode --disable-stack-for-recursion --disable-shared" \
|
|
|
|
"--enable-unicode --with-link-size=3 --disable-shared" \
|
2014-08-10 12:09:24 -04:00
|
|
|
"--disable-shared"
|
|
|
|
do
|
|
|
|
opts="--enable-valgrind $opts"
|
|
|
|
runtest
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $usejit -ne 0 ]; then
|
|
|
|
for opts in \
|
2014-09-19 03:43:39 -04:00
|
|
|
"--enable-jit --enable-unicode --disable-shared" \
|
|
|
|
"--enable-jit --enable-pcre16 --enable-pcre32 --enable-unicode"
|
2014-08-10 12:09:24 -04:00
|
|
|
do
|
|
|
|
opts="--enable-valgrind $opts"
|
|
|
|
runtest
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
2014-05-13 07:20:03 -04:00
|
|
|
|
|
|
|
valgrind=
|
|
|
|
cvalgrind=
|
|
|
|
withvalgrind=
|
|
|
|
|
|
|
|
# Clean up the distribution and then do at least one build and test in a
|
|
|
|
# directory other than the source directory. It doesn't work unless the
|
|
|
|
# source directory is cleaned up first.
|
|
|
|
|
|
|
|
if [ -f Makefile ]; then
|
|
|
|
echo "Running 'make distclean'"
|
|
|
|
make distclean >/dev/null 2>&1
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "** 'make distclean' failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2014-08-10 12:09:24 -04:00
|
|
|
echo "---------- Tests in the $tmp directory ----------"
|
2014-05-13 07:20:03 -04:00
|
|
|
srcdir=`pwd`
|
|
|
|
export srcdir
|
|
|
|
|
|
|
|
if [ ! -e $tmp ]; then
|
|
|
|
mkdir $tmp
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d $tmp ]; then
|
|
|
|
echo "** Failed to create $tmp or it is not a directory"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $tmp
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "** Failed to cd to $tmp"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-08-10 12:09:24 -04:00
|
|
|
if [ $usetmp -ne 0 ]; then
|
|
|
|
for opts in \
|
2014-09-19 03:43:39 -04:00
|
|
|
"--enable-unicode --disable-shared"
|
2014-08-10 12:09:24 -04:00
|
|
|
do
|
|
|
|
runtest
|
|
|
|
done
|
|
|
|
fi
|
2014-05-13 07:20:03 -04:00
|
|
|
|
|
|
|
echo "Removing $tmp"
|
|
|
|
|
|
|
|
rm -rf $tmp
|
|
|
|
|
|
|
|
echo "All done"
|
|
|
|
|
|
|
|
# End
|