11#! /bin/sh
22
3- # This is a script for the use of PCRE2 maintainers. It configures and rebuilds
3+ # This is a script for the use of PCRE2 maintainers. It configures and builds
44# PCRE2 with a variety of configuration options, and in each case runs the
55# tests to ensure that all goes well. Every possible combination would take far
66# too long, so we use a representative sample. This script should be run in the
1818# -nojitvalgrind skip JIT tests with valgrind
1919# -nomain skip all the main (non-JIT) set of tests
2020# -nomainvalgrind skip the main (non-JIT) valgrind tests
21- # -notmp skip the test in a temporary directory
21+ # -notmp skip the tests in a temporary directory
22+ # -notmpjit skip the JIT test in a temporary directory
2223# -novalgrind skip all the valgrind tests
2324
2425# Alternatively, if any of those names are given with '+' instead of '-no',
@@ -36,6 +37,7 @@ usejitvalgrind=1
3637usemain=1
3738usemainvalgrind=1
3839usetmp=1
40+ usetmpjit=1
3941usevalgrind=1
4042
4143dummy=0
@@ -53,6 +55,8 @@ while [ $# -gt 0 ] ; do
5355 usemain=0
5456 usemainvalgrind=0
5557 usetmp=0
58+ usetmpjit=0
59+ usevalgrind=0
5660 seenplus=1
5761 fi ;;
5862 esac
@@ -63,22 +67,24 @@ while [ $# -gt 0 ] ; do
6367 -noasan) useasan=0;;
6468 -nousan) useusan=0;;
6569 -nodebug) usedebug=0;;
66- -nojit) usejit=0; usejitvalgrind=0;;
70+ -nojit) usejit=0; usejitvalgrind=0; usetmpjit=0; ;
6771 -nojitmain) usejit=0;;
6872 -nojitvalgrind) usejitvalgrind=0;;
6973 -nomain) usemain=0; usemainvalgrind=0;;
7074 -nomainvalgrind) usemainvalgrind=0;;
71- -notmp) usetmp=0;;
75+ -notmp) usetmp=0; usetmpjit=0;;
76+ -notmpjit) usetmpjit=0;;
7277 -novalgrind) usevalgrind=0;;
7378 +asan) useasan=1;;
7479 +usan) useusan=1;;
7580 +debug) usedebug=1;;
76- +jit) usejit=1; usejitvalgrind=1;;
81+ +jit) usejit=1; usejitvalgrind=1; usetmpjit=1; ;
7782 +jitmain) usejit=1;;
7883 +jitvalgrind) usejitvalgrind=1;;
7984 +main) usemain=1; usemainvalgrind=1;;
8085 +mainvalgrind) usemainvalgrind=1;;
8186 +tmp) usetmp=1;;
87+ +tmpjit) usetmpjit=1;;
8288 +valgrind) usevalgrind=1; usejitvalgrind=1; usemainvalgrind=1;;
8389 * ) echo " Unknown option '$1 '" ; exit 1;;
8490 esac
@@ -124,9 +130,11 @@ if [ $? -eq 0 ] && grep GCC /tmp/pcre2ccversion >/dev/null; then
124130 CFLAGS=" $CFLAGS -Wnested-externs"
125131 CFLAGS=" $CFLAGS -pedantic"
126132 CFLAGS=" $CFLAGS -Wuninitialized"
127- CFLAGS=" $CFLAGS -Wmaybe-uninitialized"
133+ CFLAGS=" $CFLAGS -Wmaybe-uninitialized"
128134 CFLAGS=" $CFLAGS -Wmissing-prototypes"
129135 CFLAGS=" $CFLAGS -Wstrict-prototypes"
136+ CFKAGS=" $CFLAGS -Warray-bounds"
137+ CFLAGS=" $CFLAGS -Wformat-overflow=2"
130138fi
131139rm -f /tmp/pcre2ccversion
132140
@@ -137,7 +145,7 @@ rm -f /tmp/pcre2ccversion
137145
138146runtest ()
139147 {
140- rm -f $srcdir /pcre2test $srcdir /pcre2grep $srcdir /pcre2_jit_test
148+ rm -f $srcdir /pcre2test $srcdir /pcre2grep $srcdir /pcre2_jit_test $srcdir /pcre2posix_test
141149 testcount=` expr $testcount + 1`
142150
143151 if [ " $opts " = " " ] ; then
@@ -218,13 +226,21 @@ runtest()
218226 cat teststdoutM
219227 exit 1
220228 fi
229+ echo " Running pcre2posix test $withvalgrind "
230+ $valgrind ./pcre2posix_test > teststdoutM 2> teststderrM
231+
232+ if [ $? -ne 0 ]; then
233+ echo " "
234+ echo " **** Test failed ****"
235+ exit 1
236+ fi
221237 else
222- echo " Skipping pcre2grep tests: 8-bit library not compiled"
238+ echo " Skipping pcre2grep and pcre2posix tests: 8-bit library not compiled"
223239 fi
224240
225241 if [ " $jit " -gt 0 ]; then
226242 echo " Running JIT regression tests $withvalgrind "
227- $jrvalgrind $srcdir /pcre2_jit_test > teststdoutM 2> teststderrM
243+ $jrvalgrind . /pcre2_jit_test > teststdoutM 2> teststderrM
228244 if [ $? -ne 0 -o -s teststderrM ]; then
229245 echo " "
230246 echo " **** Test failed ****"
@@ -242,7 +258,7 @@ runtest()
242258
243259testtotal=` expr 17 \* $usemain + \
244260 1 \* $usemain \* $usedebug + \
245- 1 \* $usetmp + \
261+ 1 \* $usetmp + 1 \* $usetmpjit + \
246262 1 \* $ISGCC \* $usemain + \
247263 1 \* $ISGCC \* $usemain \* $useasan + \
248264 1 \* $ISGCC \* $usemain \* $useusan + \
@@ -293,15 +309,15 @@ if [ $ISGCC -ne 0 -a $usemain -ne 0 ]; then
293309 opts=" --disable-shared $enable_jit --enable-pcre2-16 --enable-pcre2-32"
294310 runtest
295311 fi
296- # This also seems to be the case for sanitize undefined.
312+ # This also seems to be the case for sanitize undefined.
297313 if [ $useusan -ne 0 ]; then
298314 echo " ------- Maximally configured test with -fsanitize=undefined -fno-sanitize=shift -fno-sanitize=alignment -std=gnu99 -------"
299315 CFLAGS=" $OFLAGS $SAVECFLAGS -no-pie -fno-PIE -fsanitize=undefined -fno-sanitize=shift -fno-sanitize=alignment -std=gnu99"
300316 echo " CFLAGS=$CFLAGS "
301317 opts=" --disable-shared $enable_jit --enable-pcre2-16 --enable-pcre2-32"
302318 runtest
303319 fi
304- CFLAGS=" $OFLAGS $ SAVECFLAGS"
320+ CFLAGS=" $SAVECFLAGS "
305321fi
306322
307323# This set of tests builds PCRE2 and runs the tests with a variety of configure
312328# library for the subsequent tests.
313329
314330echo " ---------- CFLAGS for the remaining tests ----------"
331+ CFLAGS=" $OFLAGS $CFLAGS "
315332echo " CFLAGS=$CFLAGS "
316333
317334if [ $usemain -ne 0 ]; then
@@ -386,7 +403,7 @@ if [ $usevalgrind -ne 0 ]; then
386403 fi
387404
388405 if [ $usejitvalgrind -ne 0 ]; then
389- jrvalgrind=" valgrind --tool=memcheck -q --smc-check=all-non-file --suppressions=$srcdir /testdata/valgrind-jit.supp"
406+ jrvalgrind=" valgrind --tool=memcheck -q --smc-check=all-non-file --suppressions=$srcdir /testdata/valgrind-jit.supp"
390407 for opts in \
391408 " --enable-jit --disable-shared" \
392409 " --enable-jit --enable-pcre2-16 --enable-pcre2-32"
@@ -418,8 +435,7 @@ echo "---------- End of tests in the source directory ----------"
418435echo " Removing teststdoutM and teststderrM"
419436rm -rf teststdoutM teststderrM
420437
421- if [ $usetmp -ne 0 ]; then
422- echo " ---------- Tests in the $tmp directory ----------"
438+ if [ $usetmp -ne 0 -o $usetmpjit -ne 0 ]; then
423439 srcdir=` pwd`
424440 export srcdir
425441
@@ -438,11 +454,23 @@ if [ $usetmp -ne 0 ]; then
438454 exit 1
439455 fi
440456
441- for opts in \
442- " --disable-shared"
443- do
444- runtest
445- done
457+ if [ $usetmp -ne 0 ]; then
458+ echo " ---------- Tests in the $tmp directory ----------"
459+ for opts in \
460+ " --disable-shared"
461+ do
462+ runtest
463+ done
464+ fi
465+
466+ if [ $usetmpjit -ne 0 ]; then
467+ echo " ---------- JIT tests in the $tmp directory ----------"
468+ for opts in \
469+ " --enable-jit --disable-shared"
470+ do
471+ runtest
472+ done
473+ fi
446474
447475 echo " Removing $tmp "
448476 rm -rf $tmp
0 commit comments