1#!/bin/sh 2# 3# Do some checking before 'git push'. 4 5# Set a stricter bash mode 6set -e 7set -u 8 9# We define _GNU_SOURCE to avoid warnings with missing prototypes. 10# C89 does not know snprintf, strdup, strndup, popen, pclose 11export CFLAGS="-std=gnu89 -pedantic -g -Wall -Wextra -Wstrict-prototypes -Wold-style-definition -Wwrite-strings -Wshadow -Wformat -Wformat-security -Wunreachable-code -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition" 12 13ASAN_FLAGS="-fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope" 14 15# measure time consumed and print it at the end of the script 16START=$(date +%s.%N) 17 18for CC in clang gcc; do 19 export CC 20 echo 21 echo "*** Testing with CC=$CC" 22 23 for options in \ 24 "-Dbuiltin=libicu -Druntime=libicu" \ 25 "-Dbuiltin=libidn2 -Druntime=libidn2" \ 26 "-Dbuiltin=libidn -Druntime=libidn" \ 27 "-Dbuiltin=no -Druntime=no"; do 28 29 # normal build+check+valgrind-check 30 echo 31 echo " *** $options" 32 rm -rf builddir 33 meson builddir $options 34 cd builddir 35 ninja 36 for xLCALL in C tr_TR.utf8; do 37 LC_ALL=$xLCALL meson test 38 LC_ALL=$xLCALL meson test --wrap='valgrind --tool=memcheck' 39 done 40 cd .. 41 42 # UBSAN build+check 43 flags="-Db_sanitize=undefined -Db_lundef=false" 44 echo 45 echo " *** $options $flags" 46 rm -rf builddir 47 LDFLAGS="-lubsan" meson builddir $options $flags 48 LDFLAGS="-lubsan" ninja -C builddir 49 for xLCALL in C tr_TR.utf8; do 50 LC_ALL=$xLCALL ninja test -C builddir 51 done 52 53 # ASAN build+check 54 flags="-Db_sanitize=address -Db_lundef=false" 55 echo 56 echo " *** $options $flags" 57 rm -rf builddir 58 CFLAGS="$CFLAGS $ASAN_FLAGS" meson builddir $options $flags 59 CFLAGS="$CFLAGS $ASAN_FLAGS" ninja -C builddir 60 for xLCALL in C tr_TR.utf8; do 61 LC_ALL=$xLCALL CFLAGS="$CFLAGS $ASAN_FLAGS" ninja test -C builddir 62 done 63 64 done 65done 66 67END=$(date +%s.%N) 68echo 69echo "Duration: "$(echo "$END - $START" | bc) 70