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 Workerscriptdir=$(dirname "$0") 31*5a6e8488SAndroid Build Coastguard Worker 32*5a6e8488SAndroid Build Coastguard Workergnu=/usr/bin/bc 33*5a6e8488SAndroid Build Coastguard Workergdh=/usr/local/bin/bc 34*5a6e8488SAndroid Build Coastguard Worker 35*5a6e8488SAndroid Build Coastguard Workerif [ "$#" -lt 1 ]; then 36*5a6e8488SAndroid Build Coastguard Worker printf 'err: must provide path to new bc\n' 37*5a6e8488SAndroid Build Coastguard Worker exit 1 38*5a6e8488SAndroid Build Coastguard Workerfi 39*5a6e8488SAndroid Build Coastguard Worker 40*5a6e8488SAndroid Build Coastguard Workernew="$1" 41*5a6e8488SAndroid Build Coastguard Workershift 42*5a6e8488SAndroid Build Coastguard Worker 43*5a6e8488SAndroid Build Coastguard Workerunset BC_LINE_LENGTH && unset BC_ENV_ARGS 44*5a6e8488SAndroid Build Coastguard Worker 45*5a6e8488SAndroid Build Coastguard Workergdh_fail_file="sqrt_fails.bc" 46*5a6e8488SAndroid Build Coastguard Workernew_fail_file="new_sqrt_fails.bc" 47*5a6e8488SAndroid Build Coastguard Worker 48*5a6e8488SAndroid Build Coastguard Workerrm -rf "$gdh_fail_file" 49*5a6e8488SAndroid Build Coastguard Workerrm -rf "$new_fail_file" 50*5a6e8488SAndroid Build Coastguard Worker 51*5a6e8488SAndroid Build Coastguard Workerwhile [ true ]; do 52*5a6e8488SAndroid Build Coastguard Worker 53*5a6e8488SAndroid Build Coastguard Worker tst=$("$gdh" -l "$scriptdir/sqrt_random.bc") 54*5a6e8488SAndroid Build Coastguard Worker err=$? 55*5a6e8488SAndroid Build Coastguard Worker 56*5a6e8488SAndroid Build Coastguard Worker if [ "$err" -ne 0 ]; then 57*5a6e8488SAndroid Build Coastguard Worker printf 'err: failed to create test\n' 58*5a6e8488SAndroid Build Coastguard Worker exit 2 59*5a6e8488SAndroid Build Coastguard Worker fi 60*5a6e8488SAndroid Build Coastguard Worker 61*5a6e8488SAndroid Build Coastguard Worker good=$(printf '%s\n' "$tst" | "$gnu" -l) 62*5a6e8488SAndroid Build Coastguard Worker 63*5a6e8488SAndroid Build Coastguard Worker gdh_out=$(printf '%s\n' "$tst" | "$gdh" -l) 64*5a6e8488SAndroid Build Coastguard Worker new_out=$(printf '%s\n' "$tst" | "$new" -l) 65*5a6e8488SAndroid Build Coastguard Worker 66*5a6e8488SAndroid Build Coastguard Worker gdh_good=$(printf '%s == %s\n' "$good" "$gdh_out" | "$gnu") 67*5a6e8488SAndroid Build Coastguard Worker new_good=$(printf '%s == %s\n' "$good" "$new_out" | "$gnu") 68*5a6e8488SAndroid Build Coastguard Worker 69*5a6e8488SAndroid Build Coastguard Worker if [ "$gdh_good" -eq 0 ]; then 70*5a6e8488SAndroid Build Coastguard Worker printf '%s\n' "$tst" >> "$gdh_fail_file" 71*5a6e8488SAndroid Build Coastguard Worker fi 72*5a6e8488SAndroid Build Coastguard Worker 73*5a6e8488SAndroid Build Coastguard Worker if [ "$new_good" -eq 0 ]; then 74*5a6e8488SAndroid Build Coastguard Worker printf '%s\n' "$tst" >> "$new_fail_file" 75*5a6e8488SAndroid Build Coastguard Worker fi 76*5a6e8488SAndroid Build Coastguard Worker 77*5a6e8488SAndroid Build Coastguard Workerdone 78