]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/all.sh
vendor/bc: update to upstream version 5.0.2
[FreeBSD/FreeBSD.git] / tests / all.sh
1 #! /bin/sh
2 #
3 # SPDX-License-Identifier: BSD-2-Clause
4 #
5 # Copyright (c) 2018-2021 Gavin D. Howard and contributors.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are met:
9 #
10 # * Redistributions of source code must retain the above copyright notice, this
11 #   list of conditions and the following disclaimer.
12 #
13 # * Redistributions in binary form must reproduce the above copyright notice,
14 #   this list of conditions and the following disclaimer in the documentation
15 #   and/or other materials provided with the distribution.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 # POSSIBILITY OF SUCH DAMAGE.
28 #
29
30 set -e
31
32 script="$0"
33 testdir=$(dirname "$script")
34
35 . "$testdir/../scripts/functions.sh"
36
37 # Command-line processing.
38 if [ "$#" -ge 1 ]; then
39         d="$1"
40         shift
41 else
42         err_exit "usage: $script dir [run_extra_tests] [run_stack_tests] [gen_tests] [time_tests] [exec args...]" 1
43 fi
44
45 if [ "$#" -lt 1 ]; then
46         extra=1
47 else
48         extra="$1"
49         shift
50 fi
51
52 if [ "$#" -lt 1 ]; then
53         run_stack_tests=1
54 else
55         run_stack_tests="$1"
56         shift
57 fi
58
59 if [ "$#" -lt 1 ]; then
60         generate_tests=1
61 else
62         generate_tests="$1"
63         shift
64 fi
65
66 if [ "$#" -lt 1 ]; then
67         time_tests=0
68 else
69         time_tests="$1"
70         shift
71 fi
72
73 if [ "$#" -lt 1 ]; then
74         exe="$testdir/../bin/$d"
75 else
76         exe="$1"
77         shift
78 fi
79
80 stars="***********************************************************************"
81 printf '%s\n' "$stars"
82
83 # Set stuff for the correct calculator.
84 if [ "$d" = "bc" ]; then
85         halt="quit"
86 else
87         halt="q"
88 fi
89
90 # I use these, so unset them to make the tests work.
91 unset BC_ENV_ARGS
92 unset BC_LINE_LENGTH
93 unset DC_ENV_ARGS
94 unset DC_LINE_LENGTH
95
96 # Get the list of tests that require extra math.
97 extra_required=$(cat "$testdir/extra_required.txt")
98
99 printf '\nRunning %s tests...\n\n' "$d"
100
101 # Run the tests one at a time.
102 while read t; do
103
104         # If it requires extra, then skip if we don't have it.
105         if [ "$extra" -eq 0 ]; then
106                 if [ -z "${extra_required##*$t*}" ]; then
107                         printf 'Skipping %s %s\n' "$d" "$t"
108                         continue
109                 fi
110         fi
111
112         sh "$testdir/test.sh" "$d" "$t" "$generate_tests" "$time_tests" "$exe" "$@"
113
114 done < "$testdir/$d/all.txt"
115
116 # stdin tests.
117 sh "$testdir/stdin.sh" "$d" "$exe" "$@"
118
119 # Script tests.
120 sh "$testdir/scripts.sh" "$d" "$extra" "$run_stack_tests" "$generate_tests" \
121         "$time_tests" "$exe" "$@"
122
123 # Read tests.
124 sh "$testdir/read.sh" "$d" "$exe" "$@"
125
126 # Error tests.
127 sh "$testdir/errors.sh" "$d" "$exe" "$@"
128
129 # Other tests.
130 sh "$testdir/other.sh" "$d" "$extra" "$exe" "$@"
131
132 # History tests.
133 sh "$testdir/history.sh" "$d" -a
134
135 printf '\nAll %s tests passed.\n' "$d"
136
137 printf '\n%s\n' "$stars"