1*5a6e8488SAndroid Build Coastguard Worker#! /bin/sh 2*5a6e8488SAndroid Build Coastguard Worker# 3*5a6e8488SAndroid Build Coastguard Worker# SPDX-License-Identifier: BSD-2-Clause 4*5a6e8488SAndroid Build Coastguard Worker# 5*5a6e8488SAndroid Build Coastguard Worker# Copyright (c) 2018-2024 Gavin D. Howard and contributors. 6*5a6e8488SAndroid Build Coastguard Worker# 7*5a6e8488SAndroid Build Coastguard Worker# Redistribution and use in source and binary forms, with or without 8*5a6e8488SAndroid Build Coastguard Worker# modification, are permitted provided that the following conditions are met: 9*5a6e8488SAndroid Build Coastguard Worker# 10*5a6e8488SAndroid Build Coastguard Worker# * Redistributions of source code must retain the above copyright notice, this 11*5a6e8488SAndroid Build Coastguard Worker# list of conditions and the following disclaimer. 12*5a6e8488SAndroid Build Coastguard Worker# 13*5a6e8488SAndroid Build Coastguard Worker# * Redistributions in binary form must reproduce the above copyright notice, 14*5a6e8488SAndroid Build Coastguard Worker# this list of conditions and the following disclaimer in the documentation 15*5a6e8488SAndroid Build Coastguard Worker# and/or other materials provided with the distribution. 16*5a6e8488SAndroid Build Coastguard Worker# 17*5a6e8488SAndroid Build Coastguard Worker# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18*5a6e8488SAndroid Build Coastguard Worker# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19*5a6e8488SAndroid Build Coastguard Worker# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20*5a6e8488SAndroid Build Coastguard Worker# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21*5a6e8488SAndroid Build Coastguard Worker# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22*5a6e8488SAndroid Build Coastguard Worker# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23*5a6e8488SAndroid Build Coastguard Worker# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24*5a6e8488SAndroid Build Coastguard Worker# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25*5a6e8488SAndroid Build Coastguard Worker# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26*5a6e8488SAndroid Build Coastguard Worker# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27*5a6e8488SAndroid Build Coastguard Worker# POSSIBILITY OF SUCH DAMAGE. 28*5a6e8488SAndroid Build Coastguard Worker# 29*5a6e8488SAndroid Build Coastguard Worker 30*5a6e8488SAndroid Build Coastguard Worker# For macOS from Ventura on, run using the following: 31*5a6e8488SAndroid Build Coastguard Worker# 32*5a6e8488SAndroid Build Coastguard Worker# scripts/release.sh 1 1 0 1 0 0 0 0 1 0 1 1 1 0 0 0 0 33*5a6e8488SAndroid Build Coastguard Worker# 34*5a6e8488SAndroid Build Coastguard Worker# For OpenBSD, run using the following: 35*5a6e8488SAndroid Build Coastguard Worker# 36*5a6e8488SAndroid Build Coastguard Worker# scripts/release.sh 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 37*5a6e8488SAndroid Build Coastguard Worker# 38*5a6e8488SAndroid Build Coastguard Worker# For FreeBSD, run using the following: 39*5a6e8488SAndroid Build Coastguard Worker# 40*5a6e8488SAndroid Build Coastguard Worker# scripts/release.sh 1 1 0 1 1 0 0 0 1 0 1 0 1 0 0 1 1 41*5a6e8488SAndroid Build Coastguard Worker# 42*5a6e8488SAndroid Build Coastguard Worker# For Linux, run two separate ones (in different checkouts), like so: 43*5a6e8488SAndroid Build Coastguard Worker# 44*5a6e8488SAndroid Build Coastguard Worker# scripts/release.sh 1 1 1 1 0 1 0 0 1 0 1 0 1 0 0 1 1 45*5a6e8488SAndroid Build Coastguard Worker# cd build; ../scripts/release.sh 1 1 1 0 1 0 1 0 1 0 1 0 0 1 1 1 1 46*5a6e8488SAndroid Build Coastguard Worker# 47*5a6e8488SAndroid Build Coastguard Worker# Yes, I usually do sanitizers with Clang and Valgrind with GCC, and I also do 48*5a6e8488SAndroid Build Coastguard Worker# out-of-source builds with GCC. 49*5a6e8488SAndroid Build Coastguard Worker# 50*5a6e8488SAndroid Build Coastguard Worker# The reason I run history tests with GCC and not with Clang is because Clang 51*5a6e8488SAndroid Build Coastguard Worker# already runs slower as a result of running with sanitizers, and the history 52*5a6e8488SAndroid Build Coastguard Worker# tests are a little sensitive to load on a system. 53*5a6e8488SAndroid Build Coastguard Worker# 54*5a6e8488SAndroid Build Coastguard Worker# If this script fails on any platform when starting the Karatsuba test, check 55*5a6e8488SAndroid Build Coastguard Worker# that Python is installed, especially if the error says something like: 56*5a6e8488SAndroid Build Coastguard Worker# "karatsuba.py: not found". 57*5a6e8488SAndroid Build Coastguard Worker 58*5a6e8488SAndroid Build Coastguard Worker# Print the usage and exit with an error. Each parameter should be an integer. 59*5a6e8488SAndroid Build Coastguard Worker# Non-zero activates, and zero deactivates. 60*5a6e8488SAndroid Build Coastguard Worker# @param 1 A message to print. 61*5a6e8488SAndroid Build Coastguard Workerusage() { 62*5a6e8488SAndroid Build Coastguard Worker if [ $# -eq 1 ]; then 63*5a6e8488SAndroid Build Coastguard Worker printf '%s\n\n' "$1" 64*5a6e8488SAndroid Build Coastguard Worker fi 65*5a6e8488SAndroid Build Coastguard Worker printf 'usage: %s [run_tests] [generate_tests] [run_problematic_tests] \n' "$script" 66*5a6e8488SAndroid Build Coastguard Worker printf ' [test_with_clang] [test_with_gcc] [run_sanitizers] [run_valgrind] \n' 67*5a6e8488SAndroid Build Coastguard Worker printf ' [test_settings] [run_64_bit] [run_gen_script] [test_c11] \n' 68*5a6e8488SAndroid Build Coastguard Worker printf ' [test_128_bit] [test_computed_goto] [test_karatsuba] [test_history] \n' 69*5a6e8488SAndroid Build Coastguard Worker printf ' [test_editline] [test_readline]\n' 70*5a6e8488SAndroid Build Coastguard Worker exit 1 71*5a6e8488SAndroid Build Coastguard Worker} 72*5a6e8488SAndroid Build Coastguard Worker 73*5a6e8488SAndroid Build Coastguard Worker# Print a header with a message. This is just to make it easy to track progress. 74*5a6e8488SAndroid Build Coastguard Worker# @param msg The message to print in the header. 75*5a6e8488SAndroid Build Coastguard Workerheader() { 76*5a6e8488SAndroid Build Coastguard Worker 77*5a6e8488SAndroid Build Coastguard Worker _header_msg="$1" 78*5a6e8488SAndroid Build Coastguard Worker shift 79*5a6e8488SAndroid Build Coastguard Worker 80*5a6e8488SAndroid Build Coastguard Worker printf '\n' 81*5a6e8488SAndroid Build Coastguard Worker printf '*******************\n' 82*5a6e8488SAndroid Build Coastguard Worker printf "$_header_msg" 83*5a6e8488SAndroid Build Coastguard Worker printf '\n' 84*5a6e8488SAndroid Build Coastguard Worker printf '*******************\n' 85*5a6e8488SAndroid Build Coastguard Worker printf '\n' 86*5a6e8488SAndroid Build Coastguard Worker} 87*5a6e8488SAndroid Build Coastguard Worker 88*5a6e8488SAndroid Build Coastguard Worker# Easy way to call make. 89*5a6e8488SAndroid Build Coastguard Workerdo_make() { 90*5a6e8488SAndroid Build Coastguard Worker # No reason to do 64 except to see if I actually can overload my system. :) 91*5a6e8488SAndroid Build Coastguard Worker # Well, also that it might actually improve throughput as other jobs can run 92*5a6e8488SAndroid Build Coastguard Worker # while some are waiting. 93*5a6e8488SAndroid Build Coastguard Worker make -j64 "$@" 94*5a6e8488SAndroid Build Coastguard Worker} 95*5a6e8488SAndroid Build Coastguard Worker 96*5a6e8488SAndroid Build Coastguard Worker# Run configure.sh. 97*5a6e8488SAndroid Build Coastguard Worker# @param CFLAGS The CFLAGS. 98*5a6e8488SAndroid Build Coastguard Worker# @param CC The C compiler. 99*5a6e8488SAndroid Build Coastguard Worker# @param configure_flags The flags for configure.sh itself. 100*5a6e8488SAndroid Build Coastguard Worker# @param GEN_HOST The setting for GEN_HOST. 101*5a6e8488SAndroid Build Coastguard Worker# @param LONG_BIT The setting for LONG_BIT. 102*5a6e8488SAndroid Build Coastguard Workerconfigure() { 103*5a6e8488SAndroid Build Coastguard Worker 104*5a6e8488SAndroid Build Coastguard Worker _configure_CFLAGS="$1" 105*5a6e8488SAndroid Build Coastguard Worker shift 106*5a6e8488SAndroid Build Coastguard Worker 107*5a6e8488SAndroid Build Coastguard Worker _configure_CC="$1" 108*5a6e8488SAndroid Build Coastguard Worker shift 109*5a6e8488SAndroid Build Coastguard Worker 110*5a6e8488SAndroid Build Coastguard Worker _configure_configure_flags="$1" 111*5a6e8488SAndroid Build Coastguard Worker shift 112*5a6e8488SAndroid Build Coastguard Worker 113*5a6e8488SAndroid Build Coastguard Worker _configure_GEN_HOST="$1" 114*5a6e8488SAndroid Build Coastguard Worker shift 115*5a6e8488SAndroid Build Coastguard Worker 116*5a6e8488SAndroid Build Coastguard Worker _configure_LONG_BIT="$1" 117*5a6e8488SAndroid Build Coastguard Worker shift 118*5a6e8488SAndroid Build Coastguard Worker 119*5a6e8488SAndroid Build Coastguard Worker # Make sure to not generate tests if necessary. 120*5a6e8488SAndroid Build Coastguard Worker if [ "$gen_tests" -eq 0 ]; then 121*5a6e8488SAndroid Build Coastguard Worker _configure_configure_flags="-G $_configure_configure_flags" 122*5a6e8488SAndroid Build Coastguard Worker fi 123*5a6e8488SAndroid Build Coastguard Worker 124*5a6e8488SAndroid Build Coastguard Worker # Make sure to skip problematic tests if necessary. 125*5a6e8488SAndroid Build Coastguard Worker if [ "$problematic_tests" -eq 0 ]; then 126*5a6e8488SAndroid Build Coastguard Worker _configure_configure_flags="-P $_configure_configure_flags" 127*5a6e8488SAndroid Build Coastguard Worker fi 128*5a6e8488SAndroid Build Coastguard Worker 129*5a6e8488SAndroid Build Coastguard Worker # Choose the right extra flags. 130*5a6e8488SAndroid Build Coastguard Worker if [ "$_configure_CC" = "clang" ]; then 131*5a6e8488SAndroid Build Coastguard Worker 132*5a6e8488SAndroid Build Coastguard Worker _configure_CFLAGS="$clang_flags $_configure_CFLAGS" 133*5a6e8488SAndroid Build Coastguard Worker 134*5a6e8488SAndroid Build Coastguard Worker # We need to quiet this warning from Clang because the configure.sh docs 135*5a6e8488SAndroid Build Coastguard Worker # have this warning, so people should know. Also, I want this script to 136*5a6e8488SAndroid Build Coastguard Worker # work. 137*5a6e8488SAndroid Build Coastguard Worker if [ "$_configure_GEN_HOST" -eq 0 ]; then 138*5a6e8488SAndroid Build Coastguard Worker _configure_CFLAGS="$_configure_CFLAGS -Wno-overlength-strings" 139*5a6e8488SAndroid Build Coastguard Worker fi 140*5a6e8488SAndroid Build Coastguard Worker 141*5a6e8488SAndroid Build Coastguard Worker elif [ "$_configure_CC" = "gcc" ]; then 142*5a6e8488SAndroid Build Coastguard Worker 143*5a6e8488SAndroid Build Coastguard Worker _configure_CFLAGS="$gcc_flags $_configure_CFLAGS" 144*5a6e8488SAndroid Build Coastguard Worker 145*5a6e8488SAndroid Build Coastguard Worker # We need to quiet this warning from GCC because the configure.sh docs 146*5a6e8488SAndroid Build Coastguard Worker # have this warning, so people should know. Also, I want this script to 147*5a6e8488SAndroid Build Coastguard Worker # work. 148*5a6e8488SAndroid Build Coastguard Worker if [ "$_configure_GEN_HOST" -eq 0 ]; then 149*5a6e8488SAndroid Build Coastguard Worker _configure_CFLAGS="$_configure_CFLAGS -Wno-overlength-strings" 150*5a6e8488SAndroid Build Coastguard Worker fi 151*5a6e8488SAndroid Build Coastguard Worker 152*5a6e8488SAndroid Build Coastguard Worker fi 153*5a6e8488SAndroid Build Coastguard Worker 154*5a6e8488SAndroid Build Coastguard Worker # Print the header and do the job. 155*5a6e8488SAndroid Build Coastguard Worker _configure_header=$(printf 'Running configure.sh %s ...' "$_configure_configure_flags") 156*5a6e8488SAndroid Build Coastguard Worker _configure_header=$(printf "$_configure_header\n CC=\"%s\"\n" "$_configure_CC") 157*5a6e8488SAndroid Build Coastguard Worker _configure_header=$(printf "$_configure_header\n CFLAGS=\"%s\"\n" "$_configure_CFLAGS") 158*5a6e8488SAndroid Build Coastguard Worker _configure_header=$(printf "$_configure_header\n LONG_BIT=%s" "$_configure_LONG_BIT") 159*5a6e8488SAndroid Build Coastguard Worker _configure_header=$(printf "$_configure_header\n GEN_HOST=%s" "$_configure_GEN_HOST") 160*5a6e8488SAndroid Build Coastguard Worker 161*5a6e8488SAndroid Build Coastguard Worker header "$_configure_header" 162*5a6e8488SAndroid Build Coastguard Worker CFLAGS="$_configure_CFLAGS" CC="$_configure_CC" GEN_HOST="$_configure_GEN_HOST" \ 163*5a6e8488SAndroid Build Coastguard Worker LONG_BIT="$_configure_LONG_BIT" "$real/configure.sh" $_configure_configure_flags > /dev/null 2> /dev/null 164*5a6e8488SAndroid Build Coastguard Worker} 165*5a6e8488SAndroid Build Coastguard Worker 166*5a6e8488SAndroid Build Coastguard Worker# Build with make. This function also captures and outputs any warnings if they 167*5a6e8488SAndroid Build Coastguard Worker# exists because as far as I am concerned, warnings are not acceptable for 168*5a6e8488SAndroid Build Coastguard Worker# release. 169*5a6e8488SAndroid Build Coastguard Worker# @param CFLAGS The CFLAGS. 170*5a6e8488SAndroid Build Coastguard Worker# @param CC The C compiler. 171*5a6e8488SAndroid Build Coastguard Worker# @param configure_flags The flags for configure.sh itself. 172*5a6e8488SAndroid Build Coastguard Worker# @param GEN_HOST The setting for GEN_HOST. 173*5a6e8488SAndroid Build Coastguard Worker# @param LONG_BIT The setting for LONG_BIT. 174*5a6e8488SAndroid Build Coastguard Workerbuild() { 175*5a6e8488SAndroid Build Coastguard Worker 176*5a6e8488SAndroid Build Coastguard Worker _build_CFLAGS="$1" 177*5a6e8488SAndroid Build Coastguard Worker shift 178*5a6e8488SAndroid Build Coastguard Worker 179*5a6e8488SAndroid Build Coastguard Worker _build_CC="$1" 180*5a6e8488SAndroid Build Coastguard Worker shift 181*5a6e8488SAndroid Build Coastguard Worker 182*5a6e8488SAndroid Build Coastguard Worker _build_configure_flags="$1" 183*5a6e8488SAndroid Build Coastguard Worker shift 184*5a6e8488SAndroid Build Coastguard Worker 185*5a6e8488SAndroid Build Coastguard Worker _build_GEN_HOST="$1" 186*5a6e8488SAndroid Build Coastguard Worker shift 187*5a6e8488SAndroid Build Coastguard Worker 188*5a6e8488SAndroid Build Coastguard Worker _build_LONG_BIT="$1" 189*5a6e8488SAndroid Build Coastguard Worker shift 190*5a6e8488SAndroid Build Coastguard Worker 191*5a6e8488SAndroid Build Coastguard Worker configure "$_build_CFLAGS" "$_build_CC" "$_build_configure_flags" "$_build_GEN_HOST" "$_build_LONG_BIT" 192*5a6e8488SAndroid Build Coastguard Worker 193*5a6e8488SAndroid Build Coastguard Worker _build_header=$(printf 'Building...\n CC=%s' "$_build_CC") 194*5a6e8488SAndroid Build Coastguard Worker _build_header=$(printf "$_build_header\n CFLAGS=\"%s\"" "$_build_CFLAGS") 195*5a6e8488SAndroid Build Coastguard Worker _build_header=$(printf "$_build_header\n LONG_BIT=%s" "$_build_LONG_BIT") 196*5a6e8488SAndroid Build Coastguard Worker _build_header=$(printf "$_build_header\n GEN_HOST=%s" "$_build_GEN_HOST") 197*5a6e8488SAndroid Build Coastguard Worker 198*5a6e8488SAndroid Build Coastguard Worker header "$_build_header" 199*5a6e8488SAndroid Build Coastguard Worker 200*5a6e8488SAndroid Build Coastguard Worker set +e 201*5a6e8488SAndroid Build Coastguard Worker 202*5a6e8488SAndroid Build Coastguard Worker # Capture and print warnings. 203*5a6e8488SAndroid Build Coastguard Worker do_make > /dev/null 2> "./.test.txt" 204*5a6e8488SAndroid Build Coastguard Worker err=$? 205*5a6e8488SAndroid Build Coastguard Worker 206*5a6e8488SAndroid Build Coastguard Worker set -e 207*5a6e8488SAndroid Build Coastguard Worker 208*5a6e8488SAndroid Build Coastguard Worker if [ -s "./.test.txt" ]; then 209*5a6e8488SAndroid Build Coastguard Worker printf '%s generated warning(s):\n' "$_build_CC" 210*5a6e8488SAndroid Build Coastguard Worker printf '\n' 211*5a6e8488SAndroid Build Coastguard Worker cat "./.test.txt" 212*5a6e8488SAndroid Build Coastguard Worker exit 1 213*5a6e8488SAndroid Build Coastguard Worker fi 214*5a6e8488SAndroid Build Coastguard Worker 215*5a6e8488SAndroid Build Coastguard Worker if [ "$err" -ne 0 ]; then 216*5a6e8488SAndroid Build Coastguard Worker exit "$err" 217*5a6e8488SAndroid Build Coastguard Worker fi 218*5a6e8488SAndroid Build Coastguard Worker} 219*5a6e8488SAndroid Build Coastguard Worker 220*5a6e8488SAndroid Build Coastguard Worker# Run tests with make. 221*5a6e8488SAndroid Build Coastguard Workerruntest() { 222*5a6e8488SAndroid Build Coastguard Worker 223*5a6e8488SAndroid Build Coastguard Worker header "Running tests" 224*5a6e8488SAndroid Build Coastguard Worker 225*5a6e8488SAndroid Build Coastguard Worker if [ "$#" -gt 0 ]; then 226*5a6e8488SAndroid Build Coastguard Worker do_make "$@" 227*5a6e8488SAndroid Build Coastguard Worker else 228*5a6e8488SAndroid Build Coastguard Worker 229*5a6e8488SAndroid Build Coastguard Worker do_make test 230*5a6e8488SAndroid Build Coastguard Worker 231*5a6e8488SAndroid Build Coastguard Worker if [ "$test_history" -ne 0 ]; then 232*5a6e8488SAndroid Build Coastguard Worker do_make test_history 233*5a6e8488SAndroid Build Coastguard Worker fi 234*5a6e8488SAndroid Build Coastguard Worker fi 235*5a6e8488SAndroid Build Coastguard Worker} 236*5a6e8488SAndroid Build Coastguard Worker 237*5a6e8488SAndroid Build Coastguard Worker# Builds and runs tests with both calculators, then bc only, then dc only. If 238*5a6e8488SAndroid Build Coastguard Worker# run_tests is false, then it just does the builds. 239*5a6e8488SAndroid Build Coastguard Worker# @param CFLAGS The CFLAGS. 240*5a6e8488SAndroid Build Coastguard Worker# @param CC The C compiler. 241*5a6e8488SAndroid Build Coastguard Worker# @param configure_flags The flags for configure.sh itself. 242*5a6e8488SAndroid Build Coastguard Worker# @param GEN_HOST The setting for GEN_HOST. 243*5a6e8488SAndroid Build Coastguard Worker# @param LONG_BIT The setting for LONG_BIT. 244*5a6e8488SAndroid Build Coastguard Worker# @param run_tests Whether to run tests or not. 245*5a6e8488SAndroid Build Coastguard Workerrunconfigtests() { 246*5a6e8488SAndroid Build Coastguard Worker 247*5a6e8488SAndroid Build Coastguard Worker _runconfigtests_CFLAGS="$1" 248*5a6e8488SAndroid Build Coastguard Worker shift 249*5a6e8488SAndroid Build Coastguard Worker 250*5a6e8488SAndroid Build Coastguard Worker _runconfigtests_CC="$1" 251*5a6e8488SAndroid Build Coastguard Worker shift 252*5a6e8488SAndroid Build Coastguard Worker 253*5a6e8488SAndroid Build Coastguard Worker _runconfigtests_configure_flags="$1" 254*5a6e8488SAndroid Build Coastguard Worker shift 255*5a6e8488SAndroid Build Coastguard Worker 256*5a6e8488SAndroid Build Coastguard Worker _runconfigtests_GEN_HOST="$1" 257*5a6e8488SAndroid Build Coastguard Worker shift 258*5a6e8488SAndroid Build Coastguard Worker 259*5a6e8488SAndroid Build Coastguard Worker _runconfigtests_LONG_BIT="$1" 260*5a6e8488SAndroid Build Coastguard Worker shift 261*5a6e8488SAndroid Build Coastguard Worker 262*5a6e8488SAndroid Build Coastguard Worker _runconfigtests_run_tests="$1" 263*5a6e8488SAndroid Build Coastguard Worker shift 264*5a6e8488SAndroid Build Coastguard Worker 265*5a6e8488SAndroid Build Coastguard Worker if [ "$_runconfigtests_run_tests" -ne 0 ]; then 266*5a6e8488SAndroid Build Coastguard Worker _runconfigtests_header=$(printf 'Running tests with configure flags') 267*5a6e8488SAndroid Build Coastguard Worker else 268*5a6e8488SAndroid Build Coastguard Worker _runconfigtests_header=$(printf 'Building with configure flags') 269*5a6e8488SAndroid Build Coastguard Worker fi 270*5a6e8488SAndroid Build Coastguard Worker 271*5a6e8488SAndroid Build Coastguard Worker _runconfigtests_header=$(printf "$_runconfigtests_header \"%s\" ...\n" "$_runconfigtests_configure_flags") 272*5a6e8488SAndroid Build Coastguard Worker _runconfigtests_header=$(printf "$_runconfigtests_header\n CC=%s\n" "$_runconfigseries_CC") 273*5a6e8488SAndroid Build Coastguard Worker _runconfigtests_header=$(printf "$_runconfigtests_header\n CFLAGS=\"%s\"" "$_runconfigseries_CFLAGS") 274*5a6e8488SAndroid Build Coastguard Worker _runconfigtests_header=$(printf "$_runconfigtests_header\n LONG_BIT=%s" "$_runconfigtests_LONG_BIT") 275*5a6e8488SAndroid Build Coastguard Worker _runconfigtests_header=$(printf "$_runconfigtests_header\n GEN_HOST=%s" "$_runconfigtests_GEN_HOST") 276*5a6e8488SAndroid Build Coastguard Worker 277*5a6e8488SAndroid Build Coastguard Worker header "$_runconfigtests_header" 278*5a6e8488SAndroid Build Coastguard Worker 279*5a6e8488SAndroid Build Coastguard Worker build "$_runconfigtests_CFLAGS" "$_runconfigtests_CC" \ 280*5a6e8488SAndroid Build Coastguard Worker "$_runconfigtests_configure_flags" "$_runconfigtests_GEN_HOST" \ 281*5a6e8488SAndroid Build Coastguard Worker "$_runconfigtests_LONG_BIT" 282*5a6e8488SAndroid Build Coastguard Worker 283*5a6e8488SAndroid Build Coastguard Worker if [ "$_runconfigtests_run_tests" -ne 0 ]; then 284*5a6e8488SAndroid Build Coastguard Worker runtest 285*5a6e8488SAndroid Build Coastguard Worker fi 286*5a6e8488SAndroid Build Coastguard Worker 287*5a6e8488SAndroid Build Coastguard Worker do_make clean 288*5a6e8488SAndroid Build Coastguard Worker 289*5a6e8488SAndroid Build Coastguard Worker build "$_runconfigtests_CFLAGS" "$_runconfigtests_CC" \ 290*5a6e8488SAndroid Build Coastguard Worker "$_runconfigtests_configure_flags -b" "$_runconfigtests_GEN_HOST" \ 291*5a6e8488SAndroid Build Coastguard Worker "$_runconfigtests_LONG_BIT" 292*5a6e8488SAndroid Build Coastguard Worker 293*5a6e8488SAndroid Build Coastguard Worker if [ "$_runconfigtests_run_tests" -ne 0 ]; then 294*5a6e8488SAndroid Build Coastguard Worker runtest 295*5a6e8488SAndroid Build Coastguard Worker fi 296*5a6e8488SAndroid Build Coastguard Worker 297*5a6e8488SAndroid Build Coastguard Worker do_make clean 298*5a6e8488SAndroid Build Coastguard Worker 299*5a6e8488SAndroid Build Coastguard Worker build "$_runconfigtests_CFLAGS" "$_runconfigtests_CC" \ 300*5a6e8488SAndroid Build Coastguard Worker "$_runconfigtests_configure_flags -d" "$_runconfigtests_GEN_HOST" \ 301*5a6e8488SAndroid Build Coastguard Worker "$_runconfigtests_LONG_BIT" 302*5a6e8488SAndroid Build Coastguard Worker 303*5a6e8488SAndroid Build Coastguard Worker if [ "$_runconfigtests_run_tests" -ne 0 ]; then 304*5a6e8488SAndroid Build Coastguard Worker runtest 305*5a6e8488SAndroid Build Coastguard Worker fi 306*5a6e8488SAndroid Build Coastguard Worker 307*5a6e8488SAndroid Build Coastguard Worker do_make clean 308*5a6e8488SAndroid Build Coastguard Worker} 309*5a6e8488SAndroid Build Coastguard Worker 310*5a6e8488SAndroid Build Coastguard Worker# Builds and runs tests with runconfigtests(), but also does 64-bit, 32-bit, and 311*5a6e8488SAndroid Build Coastguard Worker# 128-bit rand, if requested. It also does it with the gen script (strgen.sh) if 312*5a6e8488SAndroid Build Coastguard Worker# requested. If run_tests is false, it just does the builds. 313*5a6e8488SAndroid Build Coastguard Worker# @param CFLAGS The CFLAGS. 314*5a6e8488SAndroid Build Coastguard Worker# @param CC The C compiler. 315*5a6e8488SAndroid Build Coastguard Worker# @param configure_flags The flags for configure.sh itself. 316*5a6e8488SAndroid Build Coastguard Worker# @param run_tests Whether to run tests or not. 317*5a6e8488SAndroid Build Coastguard Workerrunconfigseries() { 318*5a6e8488SAndroid Build Coastguard Worker 319*5a6e8488SAndroid Build Coastguard Worker _runconfigseries_CFLAGS="$1" 320*5a6e8488SAndroid Build Coastguard Worker shift 321*5a6e8488SAndroid Build Coastguard Worker 322*5a6e8488SAndroid Build Coastguard Worker _runconfigseries_CC="$1" 323*5a6e8488SAndroid Build Coastguard Worker shift 324*5a6e8488SAndroid Build Coastguard Worker 325*5a6e8488SAndroid Build Coastguard Worker _runconfigseries_configure_flags="$1" 326*5a6e8488SAndroid Build Coastguard Worker shift 327*5a6e8488SAndroid Build Coastguard Worker 328*5a6e8488SAndroid Build Coastguard Worker _runconfigseries_run_tests="$1" 329*5a6e8488SAndroid Build Coastguard Worker shift 330*5a6e8488SAndroid Build Coastguard Worker 331*5a6e8488SAndroid Build Coastguard Worker if [ "$run_64_bit" -ne 0 ]; then 332*5a6e8488SAndroid Build Coastguard Worker 333*5a6e8488SAndroid Build Coastguard Worker if [ "$test_128_bit" -ne 0 ]; then 334*5a6e8488SAndroid Build Coastguard Worker runconfigtests "$_runconfigseries_CFLAGS" "$_runconfigseries_CC" \ 335*5a6e8488SAndroid Build Coastguard Worker "$_runconfigseries_configure_flags" 1 64 "$_runconfigseries_run_tests" 336*5a6e8488SAndroid Build Coastguard Worker fi 337*5a6e8488SAndroid Build Coastguard Worker 338*5a6e8488SAndroid Build Coastguard Worker if [ "$run_gen_script" -ne 0 ]; then 339*5a6e8488SAndroid Build Coastguard Worker runconfigtests "$_runconfigseries_CFLAGS" "$_runconfigseries_CC" \ 340*5a6e8488SAndroid Build Coastguard Worker "$_runconfigseries_configure_flags" 0 64 "$_runconfigseries_run_tests" 341*5a6e8488SAndroid Build Coastguard Worker fi 342*5a6e8488SAndroid Build Coastguard Worker 343*5a6e8488SAndroid Build Coastguard Worker runconfigtests "$_runconfigseries_CFLAGS -DBC_RAND_BUILTIN=0" "$_runconfigseries_CC" \ 344*5a6e8488SAndroid Build Coastguard Worker "$_runconfigseries_configure_flags" 1 64 "$_runconfigseries_run_tests" 345*5a6e8488SAndroid Build Coastguard Worker 346*5a6e8488SAndroid Build Coastguard Worker # Test Editline and Readline if history is not turned off. 347*5a6e8488SAndroid Build Coastguard Worker if [ "${_runconfigseries_configure_flags#*H}" = "${_runconfigseries_configure_flags}" ]; then 348*5a6e8488SAndroid Build Coastguard Worker 349*5a6e8488SAndroid Build Coastguard Worker if [ "$test_editline" -ne 0 ]; then 350*5a6e8488SAndroid Build Coastguard Worker runconfigtests "$_runconfigseries_CFLAGS -DBC_RAND_BUILTIN=0" "$_runconfigseries_CC" \ 351*5a6e8488SAndroid Build Coastguard Worker "$_runconfigseries_configure_flags -e" 1 64 "$_runconfigseries_run_tests" 352*5a6e8488SAndroid Build Coastguard Worker fi 353*5a6e8488SAndroid Build Coastguard Worker 354*5a6e8488SAndroid Build Coastguard Worker if [ "$test_readline" -ne 0 ]; then 355*5a6e8488SAndroid Build Coastguard Worker runconfigtests "$_runconfigseries_CFLAGS -DBC_RAND_BUILTIN=0" "$_runconfigseries_CC" \ 356*5a6e8488SAndroid Build Coastguard Worker "$_runconfigseries_configure_flags -r" 1 64 "$_runconfigseries_run_tests" 357*5a6e8488SAndroid Build Coastguard Worker fi 358*5a6e8488SAndroid Build Coastguard Worker 359*5a6e8488SAndroid Build Coastguard Worker fi 360*5a6e8488SAndroid Build Coastguard Worker 361*5a6e8488SAndroid Build Coastguard Worker fi 362*5a6e8488SAndroid Build Coastguard Worker 363*5a6e8488SAndroid Build Coastguard Worker runconfigtests "$_runconfigseries_CFLAGS" "$_runconfigseries_CC" \ 364*5a6e8488SAndroid Build Coastguard Worker "$_runconfigseries_configure_flags" 1 32 "$_runconfigseries_run_tests" 365*5a6e8488SAndroid Build Coastguard Worker 366*5a6e8488SAndroid Build Coastguard Worker if [ "$run_gen_script" -ne 0 ]; then 367*5a6e8488SAndroid Build Coastguard Worker runconfigtests "$_runconfigseries_CFLAGS" "$_runconfigseries_CC" \ 368*5a6e8488SAndroid Build Coastguard Worker "$_runconfigseries_configure_flags" 0 32 "$_runconfigseries_run_tests" 369*5a6e8488SAndroid Build Coastguard Worker fi 370*5a6e8488SAndroid Build Coastguard Worker} 371*5a6e8488SAndroid Build Coastguard Worker 372*5a6e8488SAndroid Build Coastguard Worker# Builds and runs tests with each setting combo running runconfigseries(). If 373*5a6e8488SAndroid Build Coastguard Worker# run_tests is false, it just does the builds. 374*5a6e8488SAndroid Build Coastguard Worker# @param CFLAGS The CFLAGS. 375*5a6e8488SAndroid Build Coastguard Worker# @param CC The C compiler. 376*5a6e8488SAndroid Build Coastguard Worker# @param configure_flags The flags for configure.sh itself. 377*5a6e8488SAndroid Build Coastguard Worker# @param run_tests Whether to run tests or not. 378*5a6e8488SAndroid Build Coastguard Workerrunsettingsseries() { 379*5a6e8488SAndroid Build Coastguard Worker 380*5a6e8488SAndroid Build Coastguard Worker _runsettingsseries_CFLAGS="$1" 381*5a6e8488SAndroid Build Coastguard Worker shift 382*5a6e8488SAndroid Build Coastguard Worker 383*5a6e8488SAndroid Build Coastguard Worker _runsettingsseries_CC="$1" 384*5a6e8488SAndroid Build Coastguard Worker shift 385*5a6e8488SAndroid Build Coastguard Worker 386*5a6e8488SAndroid Build Coastguard Worker _runsettingsseries_configure_flags="$1" 387*5a6e8488SAndroid Build Coastguard Worker shift 388*5a6e8488SAndroid Build Coastguard Worker 389*5a6e8488SAndroid Build Coastguard Worker _runsettingsseries_run_tests="$1" 390*5a6e8488SAndroid Build Coastguard Worker shift 391*5a6e8488SAndroid Build Coastguard Worker 392*5a6e8488SAndroid Build Coastguard Worker if [ "$test_settings" -ne 0 ]; then 393*5a6e8488SAndroid Build Coastguard Worker 394*5a6e8488SAndroid Build Coastguard Worker while read _runsettingsseries_s; do 395*5a6e8488SAndroid Build Coastguard Worker runconfigseries "$_runsettingsseries_CFLAGS" "$_runsettingsseries_CC" \ 396*5a6e8488SAndroid Build Coastguard Worker "$_runsettingsseries_configure_flags $_runsettingsseries_s" \ 397*5a6e8488SAndroid Build Coastguard Worker "$_runsettingsseries_run_tests" 398*5a6e8488SAndroid Build Coastguard Worker done < "$scriptdir/release_settings.txt" 399*5a6e8488SAndroid Build Coastguard Worker 400*5a6e8488SAndroid Build Coastguard Worker else 401*5a6e8488SAndroid Build Coastguard Worker runconfigseries "$_runsettingsseries_CFLAGS" "$_runsettingsseries_CC" \ 402*5a6e8488SAndroid Build Coastguard Worker "$_runsettingsseries_configure_flags" "$_runsettingsseries_run_tests" 403*5a6e8488SAndroid Build Coastguard Worker fi 404*5a6e8488SAndroid Build Coastguard Worker} 405*5a6e8488SAndroid Build Coastguard Worker 406*5a6e8488SAndroid Build Coastguard Worker# Builds and runs tests with each build type running runsettingsseries(). If 407*5a6e8488SAndroid Build Coastguard Worker# run_tests is false, it just does the builds. 408*5a6e8488SAndroid Build Coastguard Worker# @param CFLAGS The CFLAGS. 409*5a6e8488SAndroid Build Coastguard Worker# @param CC The C compiler. 410*5a6e8488SAndroid Build Coastguard Worker# @param configure_flags The flags for configure.sh itself. 411*5a6e8488SAndroid Build Coastguard Worker# @param run_tests Whether to run tests or not. 412*5a6e8488SAndroid Build Coastguard Workerruntestseries() { 413*5a6e8488SAndroid Build Coastguard Worker 414*5a6e8488SAndroid Build Coastguard Worker _runtestseries_CFLAGS="$1" 415*5a6e8488SAndroid Build Coastguard Worker shift 416*5a6e8488SAndroid Build Coastguard Worker 417*5a6e8488SAndroid Build Coastguard Worker _runtestseries_CC="$1" 418*5a6e8488SAndroid Build Coastguard Worker shift 419*5a6e8488SAndroid Build Coastguard Worker 420*5a6e8488SAndroid Build Coastguard Worker _runtestseries_configure_flags="$1" 421*5a6e8488SAndroid Build Coastguard Worker shift 422*5a6e8488SAndroid Build Coastguard Worker 423*5a6e8488SAndroid Build Coastguard Worker _runtestseries_run_tests="$1" 424*5a6e8488SAndroid Build Coastguard Worker shift 425*5a6e8488SAndroid Build Coastguard Worker 426*5a6e8488SAndroid Build Coastguard Worker _runtestseries_flags="E H N EH EN HN EHN" 427*5a6e8488SAndroid Build Coastguard Worker 428*5a6e8488SAndroid Build Coastguard Worker runsettingsseries "$_runtestseries_CFLAGS" "$_runtestseries_CC" \ 429*5a6e8488SAndroid Build Coastguard Worker "$_runtestseries_configure_flags" "$_runtestseries_run_tests" 430*5a6e8488SAndroid Build Coastguard Worker 431*5a6e8488SAndroid Build Coastguard Worker for _runtestseries_f in $_runtestseries_flags; do 432*5a6e8488SAndroid Build Coastguard Worker runsettingsseries "$_runtestseries_CFLAGS" "$_runtestseries_CC" \ 433*5a6e8488SAndroid Build Coastguard Worker "$_runtestseries_configure_flags -$_runtestseries_f" "$_runtestseries_run_tests" 434*5a6e8488SAndroid Build Coastguard Worker done 435*5a6e8488SAndroid Build Coastguard Worker} 436*5a6e8488SAndroid Build Coastguard Worker 437*5a6e8488SAndroid Build Coastguard Worker# Builds and runs the tests for bcl. If run_tests is false, it just does the 438*5a6e8488SAndroid Build Coastguard Worker# builds. 439*5a6e8488SAndroid Build Coastguard Worker# @param CFLAGS The CFLAGS. 440*5a6e8488SAndroid Build Coastguard Worker# @param CC The C compiler. 441*5a6e8488SAndroid Build Coastguard Worker# @param configure_flags The flags for configure.sh itself. 442*5a6e8488SAndroid Build Coastguard Worker# @param run_tests Whether to run tests or not. 443*5a6e8488SAndroid Build Coastguard Workerrunlibtests() { 444*5a6e8488SAndroid Build Coastguard Worker 445*5a6e8488SAndroid Build Coastguard Worker _runlibtests_CFLAGS="$1" 446*5a6e8488SAndroid Build Coastguard Worker shift 447*5a6e8488SAndroid Build Coastguard Worker 448*5a6e8488SAndroid Build Coastguard Worker _runlibtests_CC="$1" 449*5a6e8488SAndroid Build Coastguard Worker shift 450*5a6e8488SAndroid Build Coastguard Worker 451*5a6e8488SAndroid Build Coastguard Worker _runlibtests_configure_flags="$1" 452*5a6e8488SAndroid Build Coastguard Worker shift 453*5a6e8488SAndroid Build Coastguard Worker 454*5a6e8488SAndroid Build Coastguard Worker _runlibtests_run_tests="$1" 455*5a6e8488SAndroid Build Coastguard Worker shift 456*5a6e8488SAndroid Build Coastguard Worker 457*5a6e8488SAndroid Build Coastguard Worker _runlibtests_configure_flags="$_runlibtests_configure_flags -a" 458*5a6e8488SAndroid Build Coastguard Worker 459*5a6e8488SAndroid Build Coastguard Worker build "$_runlibtests_CFLAGS" "$_runlibtests_CC" "$_runlibtests_configure_flags" 1 64 460*5a6e8488SAndroid Build Coastguard Worker 461*5a6e8488SAndroid Build Coastguard Worker if [ "$_runlibtests_run_tests" -ne 0 ]; then 462*5a6e8488SAndroid Build Coastguard Worker runtest test 463*5a6e8488SAndroid Build Coastguard Worker fi 464*5a6e8488SAndroid Build Coastguard Worker 465*5a6e8488SAndroid Build Coastguard Worker build "$_runlibtests_CFLAGS" "$_runlibtests_CC" "$_runlibtests_configure_flags" 1 32 466*5a6e8488SAndroid Build Coastguard Worker 467*5a6e8488SAndroid Build Coastguard Worker if [ "$_runlibtests_run_tests" -ne 0 ]; then 468*5a6e8488SAndroid Build Coastguard Worker runtest test 469*5a6e8488SAndroid Build Coastguard Worker fi 470*5a6e8488SAndroid Build Coastguard Worker} 471*5a6e8488SAndroid Build Coastguard Worker 472*5a6e8488SAndroid Build Coastguard Worker# Builds and runs tests under C99, then C11, if requested, using 473*5a6e8488SAndroid Build Coastguard Worker# runtestseries(). If run_tests is false, it just does the builds. 474*5a6e8488SAndroid Build Coastguard Worker# @param CFLAGS The CFLAGS. 475*5a6e8488SAndroid Build Coastguard Worker# @param CC The C compiler. 476*5a6e8488SAndroid Build Coastguard Worker# @param configure_flags The flags for configure.sh itself. 477*5a6e8488SAndroid Build Coastguard Worker# @param run_tests Whether to run tests or not. 478*5a6e8488SAndroid Build Coastguard Workerruntests() { 479*5a6e8488SAndroid Build Coastguard Worker 480*5a6e8488SAndroid Build Coastguard Worker _runtests_CFLAGS="$1" 481*5a6e8488SAndroid Build Coastguard Worker shift 482*5a6e8488SAndroid Build Coastguard Worker 483*5a6e8488SAndroid Build Coastguard Worker _runtests_CC="$1" 484*5a6e8488SAndroid Build Coastguard Worker shift 485*5a6e8488SAndroid Build Coastguard Worker 486*5a6e8488SAndroid Build Coastguard Worker _runtests_configure_flags="$1" 487*5a6e8488SAndroid Build Coastguard Worker shift 488*5a6e8488SAndroid Build Coastguard Worker 489*5a6e8488SAndroid Build Coastguard Worker _runtests_run_tests="$1" 490*5a6e8488SAndroid Build Coastguard Worker shift 491*5a6e8488SAndroid Build Coastguard Worker 492*5a6e8488SAndroid Build Coastguard Worker runtestseries "-std=c99 $_runtests_CFLAGS" "$_runtests_CC" "$_runtests_configure_flags" "$_runtests_run_tests" 493*5a6e8488SAndroid Build Coastguard Worker 494*5a6e8488SAndroid Build Coastguard Worker if [ "$test_c11" -ne 0 ]; then 495*5a6e8488SAndroid Build Coastguard Worker runtestseries "-std=c11 $_runtests_CFLAGS" "$_runtests_CC" "$_runtests_configure_flags" "$_runtests_run_tests" 496*5a6e8488SAndroid Build Coastguard Worker fi 497*5a6e8488SAndroid Build Coastguard Worker} 498*5a6e8488SAndroid Build Coastguard Worker 499*5a6e8488SAndroid Build Coastguard Worker# Runs the karatsuba tests. 500*5a6e8488SAndroid Build Coastguard Workerkaratsuba() { 501*5a6e8488SAndroid Build Coastguard Worker 502*5a6e8488SAndroid Build Coastguard Worker header "Running Karatsuba tests" 503*5a6e8488SAndroid Build Coastguard Worker do_make karatsuba_test 504*5a6e8488SAndroid Build Coastguard Worker} 505*5a6e8488SAndroid Build Coastguard Worker 506*5a6e8488SAndroid Build Coastguard Worker# Builds and runs under valgrind. It runs both, bc only, then dc only. 507*5a6e8488SAndroid Build Coastguard Workervg() { 508*5a6e8488SAndroid Build Coastguard Worker 509*5a6e8488SAndroid Build Coastguard Worker header "Running valgrind" 510*5a6e8488SAndroid Build Coastguard Worker 511*5a6e8488SAndroid Build Coastguard Worker if [ "$run_64_bit" -ne 0 ]; then 512*5a6e8488SAndroid Build Coastguard Worker _vg_bits=64 513*5a6e8488SAndroid Build Coastguard Worker else 514*5a6e8488SAndroid Build Coastguard Worker _vg_bits=32 515*5a6e8488SAndroid Build Coastguard Worker fi 516*5a6e8488SAndroid Build Coastguard Worker 517*5a6e8488SAndroid Build Coastguard Worker build "$debug -std=c99" "gcc" "-O3 -gv" "1" "$_vg_bits" 518*5a6e8488SAndroid Build Coastguard Worker runtest test 519*5a6e8488SAndroid Build Coastguard Worker 520*5a6e8488SAndroid Build Coastguard Worker do_make clean_config 521*5a6e8488SAndroid Build Coastguard Worker 522*5a6e8488SAndroid Build Coastguard Worker build "$debug -std=c99" "gcc" "-O3 -gvb" "1" "$_vg_bits" 523*5a6e8488SAndroid Build Coastguard Worker runtest test 524*5a6e8488SAndroid Build Coastguard Worker 525*5a6e8488SAndroid Build Coastguard Worker do_make clean_config 526*5a6e8488SAndroid Build Coastguard Worker 527*5a6e8488SAndroid Build Coastguard Worker build "$debug -std=c99" "gcc" "-O3 -gvd" "1" "$_vg_bits" 528*5a6e8488SAndroid Build Coastguard Worker runtest test 529*5a6e8488SAndroid Build Coastguard Worker 530*5a6e8488SAndroid Build Coastguard Worker do_make clean_config 531*5a6e8488SAndroid Build Coastguard Worker 532*5a6e8488SAndroid Build Coastguard Worker build "$debug -std=c99" "gcc" "-O3 -gva" "1" "$_vg_bits" 533*5a6e8488SAndroid Build Coastguard Worker runtest test 534*5a6e8488SAndroid Build Coastguard Worker 535*5a6e8488SAndroid Build Coastguard Worker do_make clean_config 536*5a6e8488SAndroid Build Coastguard Worker} 537*5a6e8488SAndroid Build Coastguard Worker 538*5a6e8488SAndroid Build Coastguard Worker# Builds the debug series and runs the tests if run_tests allows. If sanitizers 539*5a6e8488SAndroid Build Coastguard Worker# are enabled, it also does UBSan. 540*5a6e8488SAndroid Build Coastguard Worker# @param CC The C compiler. 541*5a6e8488SAndroid Build Coastguard Worker# @param run_tests Whether to run tests or not. 542*5a6e8488SAndroid Build Coastguard Workerdebug() { 543*5a6e8488SAndroid Build Coastguard Worker 544*5a6e8488SAndroid Build Coastguard Worker _debug_CC="$1" 545*5a6e8488SAndroid Build Coastguard Worker shift 546*5a6e8488SAndroid Build Coastguard Worker 547*5a6e8488SAndroid Build Coastguard Worker _debug_run_tests="$1" 548*5a6e8488SAndroid Build Coastguard Worker shift 549*5a6e8488SAndroid Build Coastguard Worker 550*5a6e8488SAndroid Build Coastguard Worker 551*5a6e8488SAndroid Build Coastguard Worker if [ "$_debug_CC" = "clang" -a "$run_sanitizers" -ne 0 ]; then 552*5a6e8488SAndroid Build Coastguard Worker runtests "$debug -fsanitize=undefined" "$_debug_CC" "-gm" "$_debug_run_tests" 553*5a6e8488SAndroid Build Coastguard Worker else 554*5a6e8488SAndroid Build Coastguard Worker runtests "$debug" "$_debug_CC" "-g" "$_debug_run_tests" 555*5a6e8488SAndroid Build Coastguard Worker fi 556*5a6e8488SAndroid Build Coastguard Worker 557*5a6e8488SAndroid Build Coastguard Worker if [ "$_debug_CC" = "clang" -a "$run_sanitizers" -ne 0 ]; then 558*5a6e8488SAndroid Build Coastguard Worker runlibtests "$debug -fsanitize=undefined" "$_debug_CC" "-gm" "$_debug_run_tests" 559*5a6e8488SAndroid Build Coastguard Worker else 560*5a6e8488SAndroid Build Coastguard Worker runlibtests "$debug" "$_debug_CC" "-g" "$_debug_run_tests" 561*5a6e8488SAndroid Build Coastguard Worker fi 562*5a6e8488SAndroid Build Coastguard Worker} 563*5a6e8488SAndroid Build Coastguard Worker 564*5a6e8488SAndroid Build Coastguard Worker# Builds the release series and runs the test if run_tests allows. 565*5a6e8488SAndroid Build Coastguard Worker# @param CC The C compiler. 566*5a6e8488SAndroid Build Coastguard Worker# @param run_tests Whether to run tests or not. 567*5a6e8488SAndroid Build Coastguard Workerrelease() { 568*5a6e8488SAndroid Build Coastguard Worker 569*5a6e8488SAndroid Build Coastguard Worker _release_CC="$1" 570*5a6e8488SAndroid Build Coastguard Worker shift 571*5a6e8488SAndroid Build Coastguard Worker 572*5a6e8488SAndroid Build Coastguard Worker _release_run_tests="$1" 573*5a6e8488SAndroid Build Coastguard Worker shift 574*5a6e8488SAndroid Build Coastguard Worker 575*5a6e8488SAndroid Build Coastguard Worker runtests "$release" "$_release_CC" "-O3" "$_release_run_tests" 576*5a6e8488SAndroid Build Coastguard Worker 577*5a6e8488SAndroid Build Coastguard Worker runlibtests "$release" "$_release_CC" "-O3" "$_release_run_tests" 578*5a6e8488SAndroid Build Coastguard Worker} 579*5a6e8488SAndroid Build Coastguard Worker 580*5a6e8488SAndroid Build Coastguard Worker# Builds the release debug series and runs the test if run_tests allows. If 581*5a6e8488SAndroid Build Coastguard Worker# sanitizers are enabled, it also does ASan and MSan. 582*5a6e8488SAndroid Build Coastguard Worker# @param CC The C compiler. 583*5a6e8488SAndroid Build Coastguard Worker# @param run_tests Whether to run tests or not. 584*5a6e8488SAndroid Build Coastguard Workerreldebug() { 585*5a6e8488SAndroid Build Coastguard Worker 586*5a6e8488SAndroid Build Coastguard Worker _reldebug_CC="$1" 587*5a6e8488SAndroid Build Coastguard Worker shift 588*5a6e8488SAndroid Build Coastguard Worker 589*5a6e8488SAndroid Build Coastguard Worker _reldebug_run_tests="$1" 590*5a6e8488SAndroid Build Coastguard Worker shift 591*5a6e8488SAndroid Build Coastguard Worker 592*5a6e8488SAndroid Build Coastguard Worker 593*5a6e8488SAndroid Build Coastguard Worker if [ "$_reldebug_CC" = "clang" -a "$run_sanitizers" -ne 0 ]; then 594*5a6e8488SAndroid Build Coastguard Worker runtests "$debug -fsanitize=address" "$_reldebug_CC" "-mgO3" "$_reldebug_run_tests" 595*5a6e8488SAndroid Build Coastguard Worker runtests "$debug -fsanitize=memory" "$_reldebug_CC" "-mgO3" "$_reldebug_run_tests" 596*5a6e8488SAndroid Build Coastguard Worker else 597*5a6e8488SAndroid Build Coastguard Worker runtests "$debug" "$_reldebug_CC" "-gO3" "$_reldebug_run_tests" 598*5a6e8488SAndroid Build Coastguard Worker fi 599*5a6e8488SAndroid Build Coastguard Worker 600*5a6e8488SAndroid Build Coastguard Worker 601*5a6e8488SAndroid Build Coastguard Worker if [ "$_reldebug_CC" = "clang" -a "$run_sanitizers" -ne 0 ]; then 602*5a6e8488SAndroid Build Coastguard Worker runlibtests "$debug -fsanitize=address" "$_reldebug_CC" "-mgO3" "$_reldebug_run_tests" 603*5a6e8488SAndroid Build Coastguard Worker runlibtests "$debug -fsanitize=memory" "$_reldebug_CC" "-mgO3" "$_reldebug_run_tests" 604*5a6e8488SAndroid Build Coastguard Worker else 605*5a6e8488SAndroid Build Coastguard Worker runlibtests "$debug" "$_reldebug_CC" "-gO3" "$_reldebug_run_tests" 606*5a6e8488SAndroid Build Coastguard Worker fi 607*5a6e8488SAndroid Build Coastguard Worker} 608*5a6e8488SAndroid Build Coastguard Worker 609*5a6e8488SAndroid Build Coastguard Worker# Builds the min size release series and runs the test if run_tests allows. 610*5a6e8488SAndroid Build Coastguard Worker# @param CC The C compiler. 611*5a6e8488SAndroid Build Coastguard Worker# @param run_tests Whether to run tests or not. 612*5a6e8488SAndroid Build Coastguard Workerminsize() { 613*5a6e8488SAndroid Build Coastguard Worker 614*5a6e8488SAndroid Build Coastguard Worker _minsize_CC="$1" 615*5a6e8488SAndroid Build Coastguard Worker shift 616*5a6e8488SAndroid Build Coastguard Worker 617*5a6e8488SAndroid Build Coastguard Worker _minsize_run_tests="$1" 618*5a6e8488SAndroid Build Coastguard Worker shift 619*5a6e8488SAndroid Build Coastguard Worker 620*5a6e8488SAndroid Build Coastguard Worker runtests "$release" "$_minsize_CC" "-Os" "$_minsize_run_tests" 621*5a6e8488SAndroid Build Coastguard Worker 622*5a6e8488SAndroid Build Coastguard Worker runlibtests "$release" "$_minsize_CC" "-Os" "$_minsize_run_tests" 623*5a6e8488SAndroid Build Coastguard Worker} 624*5a6e8488SAndroid Build Coastguard Worker 625*5a6e8488SAndroid Build Coastguard Worker# Builds all sets: debug, release, release debug, and min size, and runs the 626*5a6e8488SAndroid Build Coastguard Worker# tests if run_tests allows. 627*5a6e8488SAndroid Build Coastguard Worker# @param CC The C compiler. 628*5a6e8488SAndroid Build Coastguard Worker# @param run_tests Whether to run tests or not. 629*5a6e8488SAndroid Build Coastguard Workerbuild_set() { 630*5a6e8488SAndroid Build Coastguard Worker 631*5a6e8488SAndroid Build Coastguard Worker _build_set_CC="$1" 632*5a6e8488SAndroid Build Coastguard Worker shift 633*5a6e8488SAndroid Build Coastguard Worker 634*5a6e8488SAndroid Build Coastguard Worker _build_set_run_tests="$1" 635*5a6e8488SAndroid Build Coastguard Worker shift 636*5a6e8488SAndroid Build Coastguard Worker 637*5a6e8488SAndroid Build Coastguard Worker debug "$_build_set_CC" "$_build_set_run_tests" 638*5a6e8488SAndroid Build Coastguard Worker release "$_build_set_CC" "$_build_set_run_tests" 639*5a6e8488SAndroid Build Coastguard Worker reldebug "$_build_set_CC" "$_build_set_run_tests" 640*5a6e8488SAndroid Build Coastguard Worker minsize "$_build_set_CC" "$_build_set_run_tests" 641*5a6e8488SAndroid Build Coastguard Worker} 642*5a6e8488SAndroid Build Coastguard Worker 643*5a6e8488SAndroid Build Coastguard Workerset -e 644*5a6e8488SAndroid Build Coastguard Worker 645*5a6e8488SAndroid Build Coastguard Workerscript="$0" 646*5a6e8488SAndroid Build Coastguard Workerscriptdir=$(dirname "$script") 647*5a6e8488SAndroid Build Coastguard Worker 648*5a6e8488SAndroid Build Coastguard Worker. "$scriptdir/functions.sh" 649*5a6e8488SAndroid Build Coastguard Worker 650*5a6e8488SAndroid Build Coastguard Worker# Unset all bc and dc environment variables. This is intended to allow this 651*5a6e8488SAndroid Build Coastguard Worker# script to run in a clean environment. 652*5a6e8488SAndroid Build Coastguard Workerunset POSIXLY_CORRECT 653*5a6e8488SAndroid Build Coastguard Workerunset BC_BANNER 654*5a6e8488SAndroid Build Coastguard Workerunset BC_ENV_ARGS 655*5a6e8488SAndroid Build Coastguard Workerunset DC_ENV_ARGS 656*5a6e8488SAndroid Build Coastguard Workerunset BC_LINE_LENGTH 657*5a6e8488SAndroid Build Coastguard Workerunset DC_LINE_LENGTH 658*5a6e8488SAndroid Build Coastguard Workerunset BC_SIGINT_RESET 659*5a6e8488SAndroid Build Coastguard Workerunset DC_SIGINT_RESET 660*5a6e8488SAndroid Build Coastguard Workerunset BC_TTY_MODE 661*5a6e8488SAndroid Build Coastguard Workerunset DC_TTY_MODE 662*5a6e8488SAndroid Build Coastguard Workerunset BC_PROMPT 663*5a6e8488SAndroid Build Coastguard Workerunset DC_PROMPT 664*5a6e8488SAndroid Build Coastguard Workerunset BC_EXPR_EXIT 665*5a6e8488SAndroid Build Coastguard Workerunset DC_EXPR_EXIT 666*5a6e8488SAndroid Build Coastguard Workerunset BC_DIGIT_CLAMP 667*5a6e8488SAndroid Build Coastguard Workerunset DC_DIGIT_CLAMP 668*5a6e8488SAndroid Build Coastguard Worker 669*5a6e8488SAndroid Build Coastguard Workeros=$(uname) 670*5a6e8488SAndroid Build Coastguard Worker# Set some strict warning flags. Clang's -Weverything can be way too strict, so 671*5a6e8488SAndroid Build Coastguard Worker# we actually have to turn off some things. 672*5a6e8488SAndroid Build Coastguard Workerclang_flags="-Weverything -Wno-padded -Wno-unsafe-buffer-usage -Wno-poison-system-directories -Wno-switch-default" 673*5a6e8488SAndroid Build Coastguard Workergcc_flags="-Wno-clobbered" 674*5a6e8488SAndroid Build Coastguard Worker 675*5a6e8488SAndroid Build Coastguard Worker# Common CFLAGS. 676*5a6e8488SAndroid Build Coastguard Workercflags="-Wall -Wextra -Werror -pedantic" 677*5a6e8488SAndroid Build Coastguard Worker 678*5a6e8488SAndroid Build Coastguard Worker# Common debug and release flags. 679*5a6e8488SAndroid Build Coastguard Workerdebug="$cflags -fno-omit-frame-pointer" 680*5a6e8488SAndroid Build Coastguard Workerrelease="$cflags -DNDEBUG" 681*5a6e8488SAndroid Build Coastguard Worker 682*5a6e8488SAndroid Build Coastguard Workerreal=$(realpath "$scriptdir/../") 683*5a6e8488SAndroid Build Coastguard Worker 684*5a6e8488SAndroid Build Coastguard Worker# Whether to run tests. 685*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -gt 0 ]; then 686*5a6e8488SAndroid Build Coastguard Worker run_tests="$1" 687*5a6e8488SAndroid Build Coastguard Worker shift 688*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$run_tests" 689*5a6e8488SAndroid Build Coastguard Workerelse 690*5a6e8488SAndroid Build Coastguard Worker run_tests=1 691*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$run_tests" 692*5a6e8488SAndroid Build Coastguard Workerfi 693*5a6e8488SAndroid Build Coastguard Worker 694*5a6e8488SAndroid Build Coastguard Worker# Whether to generate tests. On platforms like OpenBSD, there is no GNU bc to 695*5a6e8488SAndroid Build Coastguard Worker# generate tests, so this must be off. 696*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -gt 0 ]; then 697*5a6e8488SAndroid Build Coastguard Worker gen_tests="$1" 698*5a6e8488SAndroid Build Coastguard Worker shift 699*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$gen_tests" 700*5a6e8488SAndroid Build Coastguard Workerelse 701*5a6e8488SAndroid Build Coastguard Worker gen_tests=1 702*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$gen_tests" 703*5a6e8488SAndroid Build Coastguard Workerfi 704*5a6e8488SAndroid Build Coastguard Worker 705*5a6e8488SAndroid Build Coastguard Worker# Whether to run problematic tests. This needs to be off on FreeBSD. 706*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -gt 0 ]; then 707*5a6e8488SAndroid Build Coastguard Worker problematic_tests="$1" 708*5a6e8488SAndroid Build Coastguard Worker shift 709*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$problematic_tests" 710*5a6e8488SAndroid Build Coastguard Workerelse 711*5a6e8488SAndroid Build Coastguard Worker problematic_tests=1 712*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$problematic_tests" 713*5a6e8488SAndroid Build Coastguard Workerfi 714*5a6e8488SAndroid Build Coastguard Worker 715*5a6e8488SAndroid Build Coastguard Worker# Whether to test with clang. 716*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -gt 0 ]; then 717*5a6e8488SAndroid Build Coastguard Worker test_with_clang="$1" 718*5a6e8488SAndroid Build Coastguard Worker shift 719*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_with_clang" 720*5a6e8488SAndroid Build Coastguard Workerelse 721*5a6e8488SAndroid Build Coastguard Worker test_with_clang=1 722*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_with_clang" 723*5a6e8488SAndroid Build Coastguard Workerfi 724*5a6e8488SAndroid Build Coastguard Worker 725*5a6e8488SAndroid Build Coastguard Worker# Whether to test with gcc. 726*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -gt 0 ]; then 727*5a6e8488SAndroid Build Coastguard Worker test_with_gcc="$1" 728*5a6e8488SAndroid Build Coastguard Worker shift 729*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_with_gcc" 730*5a6e8488SAndroid Build Coastguard Workerelse 731*5a6e8488SAndroid Build Coastguard Worker test_with_gcc=1 732*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_with_clang" 733*5a6e8488SAndroid Build Coastguard Workerfi 734*5a6e8488SAndroid Build Coastguard Worker 735*5a6e8488SAndroid Build Coastguard Worker# Whether to test with sanitizers. 736*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -gt 0 ]; then 737*5a6e8488SAndroid Build Coastguard Worker run_sanitizers="$1" 738*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$run_sanitizers" 739*5a6e8488SAndroid Build Coastguard Worker shift 740*5a6e8488SAndroid Build Coastguard Workerelse 741*5a6e8488SAndroid Build Coastguard Worker run_sanitizers=1 742*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$run_sanitizers" 743*5a6e8488SAndroid Build Coastguard Workerfi 744*5a6e8488SAndroid Build Coastguard Worker 745*5a6e8488SAndroid Build Coastguard Worker# Whether to test with valgrind. 746*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -gt 0 ]; then 747*5a6e8488SAndroid Build Coastguard Worker run_valgrind="$1" 748*5a6e8488SAndroid Build Coastguard Worker shift 749*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$run_valgrind" 750*5a6e8488SAndroid Build Coastguard Workerelse 751*5a6e8488SAndroid Build Coastguard Worker run_valgrind=1 752*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$run_valgrind" 753*5a6e8488SAndroid Build Coastguard Workerfi 754*5a6e8488SAndroid Build Coastguard Worker 755*5a6e8488SAndroid Build Coastguard Worker# Whether to test all settings combos. 756*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -gt 0 ]; then 757*5a6e8488SAndroid Build Coastguard Worker test_settings="$1" 758*5a6e8488SAndroid Build Coastguard Worker shift 759*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_settings" 760*5a6e8488SAndroid Build Coastguard Workerelse 761*5a6e8488SAndroid Build Coastguard Worker test_settings=1 762*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_settings" 763*5a6e8488SAndroid Build Coastguard Workerfi 764*5a6e8488SAndroid Build Coastguard Worker 765*5a6e8488SAndroid Build Coastguard Worker# Whether to test 64-bit in addition to 32-bit. 766*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -gt 0 ]; then 767*5a6e8488SAndroid Build Coastguard Worker run_64_bit="$1" 768*5a6e8488SAndroid Build Coastguard Worker shift 769*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$run_64_bit" 770*5a6e8488SAndroid Build Coastguard Workerelse 771*5a6e8488SAndroid Build Coastguard Worker run_64_bit=1 772*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$run_64_bit" 773*5a6e8488SAndroid Build Coastguard Workerfi 774*5a6e8488SAndroid Build Coastguard Worker 775*5a6e8488SAndroid Build Coastguard Worker# Whether to test with strgen.sh in addition to strgen.c. 776*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -gt 0 ]; then 777*5a6e8488SAndroid Build Coastguard Worker run_gen_script="$1" 778*5a6e8488SAndroid Build Coastguard Worker shift 779*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$run_gen_script" 780*5a6e8488SAndroid Build Coastguard Workerelse 781*5a6e8488SAndroid Build Coastguard Worker run_gen_script=0 782*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$run_gen_script" 783*5a6e8488SAndroid Build Coastguard Workerfi 784*5a6e8488SAndroid Build Coastguard Worker 785*5a6e8488SAndroid Build Coastguard Worker# Whether to test on C11 in addition to C99. 786*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -gt 0 ]; then 787*5a6e8488SAndroid Build Coastguard Worker test_c11="$1" 788*5a6e8488SAndroid Build Coastguard Worker shift 789*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_c11" 790*5a6e8488SAndroid Build Coastguard Workerelse 791*5a6e8488SAndroid Build Coastguard Worker test_c11=0 792*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_c11" 793*5a6e8488SAndroid Build Coastguard Workerfi 794*5a6e8488SAndroid Build Coastguard Worker 795*5a6e8488SAndroid Build Coastguard Worker# Whether to test 128-bit integers in addition to no 128-bit integers. 796*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -gt 0 ]; then 797*5a6e8488SAndroid Build Coastguard Worker test_128_bit="$1" 798*5a6e8488SAndroid Build Coastguard Worker shift 799*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_128_bit" 800*5a6e8488SAndroid Build Coastguard Workerelse 801*5a6e8488SAndroid Build Coastguard Worker test_128_bit=0 802*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_128_bit" 803*5a6e8488SAndroid Build Coastguard Workerfi 804*5a6e8488SAndroid Build Coastguard Worker 805*5a6e8488SAndroid Build Coastguard Worker# Whether to test with computed goto or not. 806*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -gt 0 ]; then 807*5a6e8488SAndroid Build Coastguard Worker test_computed_goto="$1" 808*5a6e8488SAndroid Build Coastguard Worker shift 809*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_computed_goto" 810*5a6e8488SAndroid Build Coastguard Workerelse 811*5a6e8488SAndroid Build Coastguard Worker test_computed_goto=0 812*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_computed_goto" 813*5a6e8488SAndroid Build Coastguard Workerfi 814*5a6e8488SAndroid Build Coastguard Worker 815*5a6e8488SAndroid Build Coastguard Worker# Whether to test history or not. 816*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -gt 0 ]; then 817*5a6e8488SAndroid Build Coastguard Worker test_karatsuba="$1" 818*5a6e8488SAndroid Build Coastguard Worker shift 819*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_karatsuba" 820*5a6e8488SAndroid Build Coastguard Workerelse 821*5a6e8488SAndroid Build Coastguard Worker test_karatsuba=1 822*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_karatsuba" 823*5a6e8488SAndroid Build Coastguard Workerfi 824*5a6e8488SAndroid Build Coastguard Worker 825*5a6e8488SAndroid Build Coastguard Worker# Whether to test history or not. 826*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -gt 0 ]; then 827*5a6e8488SAndroid Build Coastguard Worker test_history="$1" 828*5a6e8488SAndroid Build Coastguard Worker shift 829*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_history" 830*5a6e8488SAndroid Build Coastguard Workerelse 831*5a6e8488SAndroid Build Coastguard Worker test_history=0 832*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_history" 833*5a6e8488SAndroid Build Coastguard Workerfi 834*5a6e8488SAndroid Build Coastguard Worker 835*5a6e8488SAndroid Build Coastguard Worker# Whether to test editline or not. 836*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -gt 0 ]; then 837*5a6e8488SAndroid Build Coastguard Worker test_editline="$1" 838*5a6e8488SAndroid Build Coastguard Worker shift 839*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_editline" 840*5a6e8488SAndroid Build Coastguard Workerelse 841*5a6e8488SAndroid Build Coastguard Worker test_editline=0 842*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_editline" 843*5a6e8488SAndroid Build Coastguard Workerfi 844*5a6e8488SAndroid Build Coastguard Worker 845*5a6e8488SAndroid Build Coastguard Worker# Whether to test editline or not. 846*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -gt 0 ]; then 847*5a6e8488SAndroid Build Coastguard Worker test_readline="$1" 848*5a6e8488SAndroid Build Coastguard Worker shift 849*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_readline" 850*5a6e8488SAndroid Build Coastguard Workerelse 851*5a6e8488SAndroid Build Coastguard Worker test_readline=0 852*5a6e8488SAndroid Build Coastguard Worker check_bool_arg "$test_readline" 853*5a6e8488SAndroid Build Coastguard Workerfi 854*5a6e8488SAndroid Build Coastguard Worker 855*5a6e8488SAndroid Build Coastguard Workerif [ "$run_64_bit" -ne 0 ]; then 856*5a6e8488SAndroid Build Coastguard Worker bits=64 857*5a6e8488SAndroid Build Coastguard Workerelse 858*5a6e8488SAndroid Build Coastguard Worker bits=32 859*5a6e8488SAndroid Build Coastguard Workerfi 860*5a6e8488SAndroid Build Coastguard Worker 861*5a6e8488SAndroid Build Coastguard Workerif [ "$test_computed_goto" -eq 0 ]; then 862*5a6e8488SAndroid Build Coastguard Worker clang_flags="-DBC_NO_COMPUTED_GOTO $clang_flags" 863*5a6e8488SAndroid Build Coastguard Worker gcc_flags="-DBC_NO_COMPUTED_GOTO $gcc_flags" 864*5a6e8488SAndroid Build Coastguard Workerfi 865*5a6e8488SAndroid Build Coastguard Worker 866*5a6e8488SAndroid Build Coastguard Worker# Setup a default compiler. 867*5a6e8488SAndroid Build Coastguard Workerif [ "$test_with_clang" -ne 0 ]; then 868*5a6e8488SAndroid Build Coastguard Worker defcc="clang" 869*5a6e8488SAndroid Build Coastguard Workerelif [ "$test_with_gcc" -ne 0 ]; then 870*5a6e8488SAndroid Build Coastguard Worker defcc="gcc" 871*5a6e8488SAndroid Build Coastguard Workerelse 872*5a6e8488SAndroid Build Coastguard Worker defcc="c99" 873*5a6e8488SAndroid Build Coastguard Workerfi 874*5a6e8488SAndroid Build Coastguard Worker 875*5a6e8488SAndroid Build Coastguard Workerexport ASAN_OPTIONS="abort_on_error=1,allocator_may_return_null=1:strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1:detect_invalid_pointer_pairs=2" 876*5a6e8488SAndroid Build Coastguard Workerexport UBSAN_OPTIONS="print_stack_trace=1,silence_unsigned_overflow=1" 877*5a6e8488SAndroid Build Coastguard Worker 878*5a6e8488SAndroid Build Coastguard Workerbuild "$debug -std=c99" "$defcc" "-g" "1" "$bits" 879*5a6e8488SAndroid Build Coastguard Worker 880*5a6e8488SAndroid Build Coastguard Workerheader "Running math library under --standard" 881*5a6e8488SAndroid Build Coastguard Worker 882*5a6e8488SAndroid Build Coastguard Worker# Make sure the math library is POSIX compliant. 883*5a6e8488SAndroid Build Coastguard Workerprintf 'quit\n' | bin/bc -ls 884*5a6e8488SAndroid Build Coastguard Worker 885*5a6e8488SAndroid Build Coastguard Workerdo_make clean_tests 886*5a6e8488SAndroid Build Coastguard Worker 887*5a6e8488SAndroid Build Coastguard Worker# Run the clang build sets. 888*5a6e8488SAndroid Build Coastguard Workerif [ "$test_with_clang" -ne 0 ]; then 889*5a6e8488SAndroid Build Coastguard Worker build_set "clang" "$run_tests" 890*5a6e8488SAndroid Build Coastguard Workerfi 891*5a6e8488SAndroid Build Coastguard Worker 892*5a6e8488SAndroid Build Coastguard Worker# Run the gcc build sets. 893*5a6e8488SAndroid Build Coastguard Workerif [ "$test_with_gcc" -ne 0 ]; then 894*5a6e8488SAndroid Build Coastguard Worker build_set "gcc" "$run_tests" 895*5a6e8488SAndroid Build Coastguard Workerfi 896*5a6e8488SAndroid Build Coastguard Worker 897*5a6e8488SAndroid Build Coastguard Workerif [ "$run_tests" -ne 0 ]; then 898*5a6e8488SAndroid Build Coastguard Worker 899*5a6e8488SAndroid Build Coastguard Worker build "$release" "$defcc" "-O3" "1" "$bits" 900*5a6e8488SAndroid Build Coastguard Worker 901*5a6e8488SAndroid Build Coastguard Worker # Run karatsuba. 902*5a6e8488SAndroid Build Coastguard Worker if [ "$test_karatsuba" -ne 0 ]; then 903*5a6e8488SAndroid Build Coastguard Worker karatsuba 904*5a6e8488SAndroid Build Coastguard Worker fi 905*5a6e8488SAndroid Build Coastguard Worker 906*5a6e8488SAndroid Build Coastguard Worker # Valgrind. 907*5a6e8488SAndroid Build Coastguard Worker if [ "$run_valgrind" -ne 0 -a "$test_with_gcc" -ne 0 ]; then 908*5a6e8488SAndroid Build Coastguard Worker vg 909*5a6e8488SAndroid Build Coastguard Worker fi 910*5a6e8488SAndroid Build Coastguard Worker 911*5a6e8488SAndroid Build Coastguard Worker printf '\n' 912*5a6e8488SAndroid Build Coastguard Worker printf 'Tests successful.\n' 913*5a6e8488SAndroid Build Coastguard Worker 914*5a6e8488SAndroid Build Coastguard Workerfi 915