| |
|
|
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| |
|
|
| |
| |
|
|
| useasan=1 |
| useusan=1 |
| usedebug=1 |
| usejit=1 |
| usejitvalgrind=1 |
| usemain=1 |
| usemainvalgrind=1 |
| usetmp=1 |
| usetmpjit=1 |
| useebcdic=1 |
| useebcdicjit=1 |
| usevalgrind=1 |
|
|
| dummy=0 |
| seenplus=0 |
| verbose=0 |
|
|
| while [ $# -gt 0 ] ; do |
| case $1 in |
| +*) if [ $seenplus -eq 0 ]; then |
| useasan=0 |
| useusan=0 |
| usedebug=0 |
| usejit=0 |
| usejitvalgrind=0 |
| usemain=0 |
| usemainvalgrind=0 |
| usetmp=0 |
| usetmpjit=0 |
| useebcdic=0 |
| useebcdicjit=0 |
| usevalgrind=0 |
| seenplus=1 |
| fi;; |
| esac |
|
|
| case $1 in |
| -dummy) dummy=1;; |
| -v) verbose=1;; |
| -noasan) useasan=0;; |
| -nousan) useusan=0;; |
| -nodebug) usedebug=0;; |
| -nojit) usejit=0; usejitvalgrind=0; usetmpjit=0; useebcdicjit=0;; |
| -nojitmain) usejit=0;; |
| -nojitvalgrind) usejitvalgrind=0;; |
| -nomain) usemain=0; usemainvalgrind=0;; |
| -nomainvalgrind) usemainvalgrind=0;; |
| -notmp) usetmp=0; usetmpjit=0;; |
| -notmpjit) usetmpjit=0;; |
| -noebcdic) useebcdic=0; useebcdicjit=0;; |
| -noebcdicjit) useebcdicjit=0;; |
| -novalgrind) usevalgrind=0;; |
| +asan) useasan=1;; |
| +usan) useusan=1;; |
| +debug) usedebug=1;; |
| +jit) usejit=1; usejitvalgrind=1; usetmpjit=1; useebcdicjit=1;; |
| +jitmain) usejit=1;; |
| +jitvalgrind) usejitvalgrind=1;; |
| +main) usemain=1; usemainvalgrind=1;; |
| +mainvalgrind) usemainvalgrind=1;; |
| +tmp) usetmp=1;; |
| +tmpjit) usetmpjit=1;; |
| +ebcdic) useebcdic=1;; |
| +ebcdicjit) useebcdicjit=1;; |
| +valgrind) usevalgrind=1; usejitvalgrind=1; usemainvalgrind=1;; |
| *) echo "Unknown option '$1'"; exit 1;; |
| esac |
| shift |
| done |
|
|
| if [ $usejitvalgrind -eq 0 -a $usemainvalgrind -eq 0 ] ; then |
| usevalgrind=0 |
| fi |
|
|
| |
|
|
| unset cp ls mv rm |
|
|
| |
|
|
| tmp=/tmp/pcre2testing |
|
|
| |
| |
| |
| |
|
|
| CFLAGS="-g" |
| OFLAGS="-O0" |
| CC="${CC:=cc}" |
| ISGCC=0 |
|
|
| |
|
|
| CC_VER_OUTPUT=`printf '#if defined(__GNUC__) && !defined(__clang__)\nGCC=yes\n#endif\n' | $CC -E -` |
| if [ $? -eq 0 ] && (echo "$CC_VER_OUTPUT" | grep GCC=yes) >/dev/null; then |
| echo "Treating $CC as GCC" |
| ISGCC=1 |
| CFLAGS="$CFLAGS -Wall" |
| CFLAGS="$CFLAGS -Wextra" |
| CFLAGS="$CFLAGS -Wno-overlength-strings" |
| CFLAGS="$CFLAGS -Wpointer-arith" |
| CFLAGS="$CFLAGS -Wwrite-strings" |
| CFLAGS="$CFLAGS -Wundef" |
| CFLAGS="$CFLAGS -Wshadow" |
| CFLAGS="$CFLAGS -Wmissing-field-initializers" |
| CFLAGS="$CFLAGS -Wunused-parameter" |
| CFLAGS="$CFLAGS -Wformat" |
| CFLAGS="$CFLAGS -Wbad-function-cast" |
| CFLAGS="$CFLAGS -Wmissing-declarations" |
| CFLAGS="$CFLAGS -Wnested-externs" |
| CFLAGS="$CFLAGS -pedantic" |
| CFLAGS="$CFLAGS -Wuninitialized" |
| CFLAGS="$CFLAGS -Wmaybe-uninitialized" |
| CFLAGS="$CFLAGS -Wmissing-prototypes" |
| CFLAGS="$CFLAGS -Wstrict-prototypes" |
| CFLAGS="$CFLAGS -Warray-bounds" |
| CFLAGS="$CFLAGS -Wformat-overflow=2" |
| CFLAGS="$CFLAGS -Wformat-truncation=1" |
| CFLAGS="$CFLAGS -Wdeclaration-after-statement" |
| fi |
|
|
| |
| |
| |
| |
|
|
| runtest() |
| { |
| rm -f $srcdir/pcre2test $srcdir/pcre2grep $srcdir/pcre2_jit_test $srcdir/pcre2posix_test |
| testcount=`expr $testcount + 1` |
|
|
| if [ "$opts" = "" ] ; then |
| echo "[$testcount/$testtotal] Configuring with: default settings" |
| else |
| echo "[$testcount/$testtotal] Configuring with:" |
| echo " $opts" |
| fi |
|
|
| if [ $dummy -eq 1 ]; then return; fi |
|
|
| CC="$CC" CFLAGS="$CFLAGS" \ |
| $srcdir/configure $opts >/dev/null 2>teststderrM |
| if [ $? -ne 0 ]; then |
| echo " " |
| echo "******** Error while configuring ********" |
| cat teststderrM |
| exit 1 |
| fi |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| echo "Making" |
| make -j >/dev/null 2>teststderrM |
| makeRC=$? |
| if command -v sed >/dev/null 2>&1 ; then |
| sed "/\`u' modifier ignored since \`D' is the default/ d" \ |
| teststderrM > teststderrMM |
| mv -f teststderrMM teststderrM |
| fi |
| if [ $makeRC -ne 0 -o -s teststderrM ]; then |
| echo " " |
| echo "******** Errors or warnings while making ********" |
| echo " " |
| cat teststderrM |
| exit 1 |
| fi |
|
|
| if [ $verbose -eq 1 ]; then |
| ./pcre2test -C |
| fi |
|
|
| ./pcre2test -C jit >/dev/null |
| jit=$? |
| ./pcre2test -C pcre2-8 >/dev/null |
| pcre2_8=$? |
|
|
| echo "Running PCRE2 library tests $withvalgrind $withmalloc" |
| $srcdir/RunTest $valgrind $malloc >teststdoutM 2>teststderrM |
|
|
| if [ $? -ne 0 -o -s teststderrM ]; then |
| echo " " |
| echo "**** Test failed ****" |
| if [ -s teststderrM ] ; then |
| cat teststderrM |
| else |
| cat teststdoutM |
| fi |
| exit 1 |
| fi |
|
|
| if [ $pcre2_8 -eq 0 ]; then |
| echo "Skipping pcre2grep and pcre2posix tests: 8-bit library not compiled" |
| elif [ "x$withebcdic" != x ]; then |
| echo "Skipping pcre2grep and pcre2posix tests: tests not supported on EBCDIC" |
| else |
| echo "Running pcre2grep tests $withvalgrind" |
| $srcdir/RunGrepTest $valgrind >teststdoutM 2>teststderrM |
| if [ $? -ne 0 -o -s teststderrM ]; then |
| echo " " |
| echo "**** Test failed ****" |
| cat teststderrM |
| cat teststdoutM |
| exit 1 |
| fi |
| echo "Running pcre2posix test $withvalgrind" |
| $valgrind ./pcre2posix_test >teststdoutM 2>teststderrM |
|
|
| if [ $? -ne 0 ]; then |
| echo " " |
| echo "**** Test failed ****" |
| exit 1 |
| fi |
| fi |
|
|
| if [ "$jit" -eq 0 ]; then |
| echo "Skipping JIT regression tests: JIT is not enabled" |
| elif [ "x$withebcdic" != x ]; then |
| echo "Skipping JIT regression tests: tests not supported on EBCDIC" |
| else |
| echo "Running JIT regression tests $withvalgrind" |
| $jrvalgrind ./pcre2_jit_test >teststdoutM 2>teststderrM |
| if [ $? -ne 0 -o -s teststderrM ]; then |
| echo " " |
| echo "**** Test failed ****" |
| cat teststderrM |
| cat teststdoutM |
| exit 1 |
| fi |
| fi |
| } |
|
|
| |
| |
|
|
| testtotal=`expr 17 \* $usemain + \ |
| 1 \* $usemain \* $usedebug + \ |
| 1 \* $usetmp + 1 \* $usetmpjit + \ |
| 1 \* $ISGCC \* $usemain + \ |
| 1 \* $ISGCC \* $usemain \* $useasan + \ |
| 1 \* $ISGCC \* $usemain \* $useusan + \ |
| 13 \* $usejit + \ |
| 2 \* $useebcdic + \ |
| 1 \* $useebcdicjit + \ |
| 2 \* $usemainvalgrind + \ |
| 2 \* $usejitvalgrind` |
|
|
| testcount=0 |
|
|
| if [ $testtotal -eq 0 ] ; then |
| echo "** No tests selected" |
| exit 1 |
| fi |
|
|
| valgrind= |
| jrvalgrind= |
| withvalgrind= |
| malloc= |
| withmalloc= |
| srcdir=. |
| export srcdir |
|
|
| 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 ----------" |
| SAVECFLAGS="$CFLAGS" |
| CFLAGS="-O2 $CFLAGS" |
| echo "CFLAGS=$CFLAGS" |
| opts="--disable-shared $enable_jit --enable-pcre2-16 --enable-pcre2-32" |
| runtest |
| if [ $useasan -ne 0 ]; then |
| echo "---------- Maximally configured test with -fsanitize=address ----------" |
| |
| |
| CFLAGS="$OFLAGS $SAVECFLAGS -no-pie -fno-PIE -fsanitize=address" |
| echo "CFLAGS=$CFLAGS" |
| opts="--disable-shared $enable_jit --enable-pcre2-16 --enable-pcre2-32" |
| runtest |
| fi |
| |
| if [ $useusan -ne 0 ]; then |
| echo "------- Maximally configured test with -fsanitize=undefined -fno-sanitize=alignment -std=gnu99 -------" |
| CFLAGS="$OFLAGS $SAVECFLAGS -no-pie -fno-PIE -fsanitize=undefined -fno-sanitize=alignment -std=gnu99" |
| echo "CFLAGS=$CFLAGS" |
| opts="--disable-shared $enable_jit --enable-pcre2-16 --enable-pcre2-32" |
| runtest |
| fi |
| CFLAGS="$SAVECFLAGS" |
| fi |
|
|
| |
| |
| |
| |
| |
| |
|
|
| echo "---------- CFLAGS for the remaining tests ----------" |
| CFLAGS="$OFLAGS $CFLAGS" |
| echo "CFLAGS=$CFLAGS" |
|
|
| if [ $usemain -ne 0 ]; then |
| if [ $usedebug -ne 0 ]; then |
| echo "---------- Maximally configured test with --enable-debug ----------" |
| opts="--disable-shared $enable_jit --enable-pcre2-16 --enable-pcre2-32 --enable-debug" |
| runtest |
| fi |
|
|
| echo "---------- Non-JIT tests in the current directory ----------" |
| for opts in \ |
| "" \ |
| "--disable-static" \ |
| "--disable-shared" \ |
| "--disable-unicode --disable-shared --enable-never-backslash-C" \ |
| "--with-link-size=3 --disable-shared --disable-pcre2grep-callout" \ |
| "--disable-unicode --enable-rebuild-chartables --disable-shared" \ |
| "--disable-unicode --enable-newline-is-any --disable-shared" \ |
| "--disable-unicode --enable-newline-is-cr --disable-shared" \ |
| "--disable-unicode --enable-newline-is-crlf --disable-shared" \ |
| "--disable-unicode --enable-newline-is-anycrlf --enable-bsr-anycrlf --disable-shared" \ |
| "--enable-newline-is-any --disable-static" \ |
| "--disable-unicode --enable-pcre2-16 --enable-debug" \ |
| "--enable-pcre2-16 --disable-shared" \ |
| "--disable-unicode --enable-pcre2-32" \ |
| "--enable-pcre2-32 --disable-shared" \ |
| "--disable-unicode --enable-pcre2-32 --enable-pcre2-16 --disable-shared" \ |
| "--disable-unicode --enable-pcre2-32 --enable-pcre2-16 --disable-pcre2-8 --disable-shared" |
| do |
| runtest |
| done |
| fi |
|
|
| |
|
|
| if [ $usejit -ne 0 ]; then |
| echo "---------- JIT tests in the current directory ----------" |
| for opts in \ |
| "--disable-unicode --enable-jit --disable-shared" \ |
| "--enable-jit --disable-shared" \ |
| "--enable-jit --with-link-size=3 --disable-shared" \ |
| "--enable-jit --enable-pcre2-16 --disable-shared" \ |
| "--disable-unicode --enable-jit --enable-pcre2-16 --disable-pcre2-8 --disable-shared" \ |
| "--enable-jit --enable-pcre2-16 --disable-pcre2-8 --disable-shared" \ |
| "--enable-jit --enable-pcre2-16 --with-link-size=3 --disable-shared" \ |
| "--enable-jit --enable-pcre2-16 --with-link-size=4 --disable-shared" \ |
| "--enable-jit --enable-pcre2-32 --disable-shared" \ |
| "--disable-unicode --enable-jit --enable-pcre2-32 --disable-pcre2-8 --disable-shared" \ |
| "--enable-jit --enable-pcre2-32 --disable-pcre2-8 --disable-shared" \ |
| "--enable-jit --enable-pcre2-32 --with-link-size=4 --disable-shared" \ |
| "--enable-jit --enable-pcre2-32 --enable-pcre2-16 --disable-pcre2-8 --enable-newline-is-anycrlf --enable-bsr-anycrlf --disable-shared" |
| do |
| runtest |
| done |
| fi |
|
|
| |
|
|
| if [ $useebcdic -ne 0 -o $useebcdicjit -ne 0 ]; then |
| echo "---------- EBCDIC tests in the current directory ----------" |
| withebcdic="with EBCDIC" |
|
|
| if [ $useebcdic -ne 0 ]; then |
| for opts in \ |
| "--disable-unicode --enable-ebcdic --enable-ebcdic-ignoring-compiler" \ |
| "--disable-unicode --enable-ebcdic --enable-ebcdic-ignoring-compiler --enable-ebcdic-nl25" |
| do |
| runtest |
| done |
| fi |
|
|
| if [ $useebcdicjit -ne 0 ]; then |
| for opts in \ |
| "--disable-unicode --enable-jit --enable-ebcdic --enable-ebcdic-ignoring-compiler" |
| do |
| runtest |
| done |
| fi |
| fi |
|
|
| withebcdic= |
|
|
| |
|
|
| if [ $usevalgrind -ne 0 ]; then |
| echo "---------- Tests in the current directory using valgrind ----------" |
| valgrind=valgrind |
| withvalgrind="with valgrind" |
|
|
| malloc=-malloc |
| withmalloc="with -malloc" |
|
|
| if [ $usemainvalgrind -ne 0 ]; then |
| for opts in \ |
| "--disable-shared" \ |
| "--with-link-size=3 --enable-pcre2-16 --enable-pcre2-32 --disable-shared" |
| do |
| opts="--enable-valgrind $opts" |
| runtest |
|
|
| # Only need to run the first test with -malloc. |
| malloc= |
| withmalloc= |
| done |
| fi |
|
|
| malloc=-malloc |
| withmalloc="with -malloc" |
|
|
| if [ $usejitvalgrind -ne 0 ]; then |
| jrvalgrind="valgrind --tool=memcheck -q --smc-check=all-non-file --suppressions=$srcdir/testdata/valgrind-jit.supp" |
| for opts in \ |
| "--enable-jit --disable-shared" \ |
| "--enable-jit --enable-pcre2-16 --enable-pcre2-32" |
| do |
| opts="--enable-valgrind $opts" |
| runtest |
|
|
| # Only need to run the first test with -malloc. |
| malloc= |
| withmalloc= |
| done |
| fi |
| fi |
|
|
| valgrind= |
| jrvalgrind= |
| withvalgrind= |
| malloc= |
| withmalloc= |
|
|
| |
| |
| |
|
|
| 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 |
|
|
| echo "---------- End of tests in the source directory ----------" |
| echo "Removing teststdoutM and teststderrM" |
| rm -rf teststdoutM teststderrM |
|
|
| if [ $usetmp -ne 0 -o $usetmpjit -ne 0 ]; then |
| 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 |
|
|
| if [ $usetmp -ne 0 ]; then |
| echo "---------- Tests in the $tmp directory ----------" |
| for opts in \ |
| "--disable-shared" |
| do |
| runtest |
| done |
| fi |
|
|
| if [ $usetmpjit -ne 0 ]; then |
| echo "---------- JIT tests in the $tmp directory ----------" |
| for opts in \ |
| "--enable-jit --disable-shared" |
| do |
| runtest |
| done |
| fi |
|
|
| echo "Removing $tmp" |
| rm -rf $tmp |
| fi |
|
|
| echo "---------- All done ----------" |
|
|
| |
|
|