aboutsummaryrefslogtreecommitdiff
path: root/contrib/bc/tests/script.sh
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2020-12-27 20:53:09 +0000
committerStefan Eßer <se@FreeBSD.org>2021-03-21 15:53:30 +0000
commit92db69bf876227ae9bf97874404a156bb5926334 (patch)
treeededa9e4b77f303566e30435c7ad8985acae11f2 /contrib/bc/tests/script.sh
parent2b61bda2c75f30f6eadd18fb891fd885e4c8d19d (diff)
bc: Upgrade to version 3.2.4
This update changes the behavior of "-e" or "-f" in BC_ENV_ARGS: Use of these options on the command line makes bc exit after executing the given commands. These options will not cause bc to exit when passed via the environment (but EOF in STDIN or -e or -f on the command line will make bc exit as before). The same applies to DC_ENV_ARGS with regard to the dc program. Make length(0) and length(0.0) return 1 for compatibility with GNU bc and the traditional FreeBSD bc. Fix a potential division by zero error in a non-standard (extended) math library function. (cherry picked from commit e458944cf9deec51d03ec751050a58ddf43e796f) (cherry picked from commit 9a995fe186257315e7b3d01e24c55d86bb18fd32) (cherry picked from commit 4aa71da8dc004aa5027836259433e5bff3cd9104) (cherry picked from commit 028616d0dd69a3da7a30cb94d35f040bf2ced6b9) (cherry picked from commit f165641df4da1752f8bb1f55c1e602cdb657fba4) (cherry picked from commit 893ecb52db5ed47d6c1e8698334d34e0df651612)
Diffstat (limited to 'contrib/bc/tests/script.sh')
-rwxr-xr-xcontrib/bc/tests/script.sh28
1 files changed, 22 insertions, 6 deletions
diff --git a/contrib/bc/tests/script.sh b/contrib/bc/tests/script.sh
index 279295829f75..b7c707ac88bf 100755
--- a/contrib/bc/tests/script.sh
+++ b/contrib/bc/tests/script.sh
@@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: BSD-2-Clause
#
-# Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+# Copyright (c) 2018-2021 Gavin D. Howard and contributors.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -33,6 +33,8 @@ script="$0"
testdir=$(dirname "${script}")
+. "$testdir/../functions.sh"
+
if [ "$#" -lt 2 ]; then
printf 'usage: %s dir script [run_extra_tests] [run_stack_tests] [generate_tests] [time_tests] [exec args...]\n' "$script"
exit 1
@@ -79,8 +81,6 @@ else
exe="$testdir/../bin/$d"
fi
-out="$testdir/../.log_${d}_test.txt"
-
if [ "$d" = "bc" ]; then
if [ "$run_stack_tests" -ne 0 ]; then
@@ -120,6 +120,18 @@ if [ "$run_stack_tests" -eq 0 ]; then
fi
+out="$testdir/${d}_outputs/${name}_script_results.txt"
+outdir=$(dirname "$out")
+
+if [ ! -d "$outdir" ]; then
+ mkdir -p "$outdir"
+fi
+
+unset BC_ENV_ARGS
+unset BC_LINE_LENGTH
+unset DC_ENV_ARGS
+unset DC_LINE_LENGTH
+
s="$scriptdir/$f"
orig="$testdir/$name.txt"
results="$scriptdir/$name.txt"
@@ -129,7 +141,7 @@ if [ -f "$orig" ]; then
elif [ -f "$results" ]; then
res="$results"
elif [ "$generate" -eq 0 ]; then
- printf 'Skipping %s script %s\n' "$d" "$s"
+ printf 'Skipping %s script %s\n' "$d" "$f"
exit 0
else
printf 'Generating %s results...' "$f"
@@ -138,18 +150,22 @@ else
res="$results"
fi
+set +e
+
printf 'Running %s script %s...' "$d" "$f"
if [ "$time_tests" -ne 0 ]; then
printf '\n'
printf '%s\n' "$halt" | /usr/bin/time -p "$exe" "$@" $options "$s" > "$out"
+ err="$?"
printf '\n'
else
printf '%s\n' "$halt" | "$exe" "$@" $options "$s" > "$out"
+ err="$?"
fi
-diff "$res" "$out"
+checktest "$d" "$err" "script $f" "$res" "$out"
rm -f "$out"
-printf 'pass\n'
+exec printf 'pass\n'