3 # SPDX-License-Identifier: BSD-2-Clause
5 # Copyright (c) 2018-2021 Gavin D. Howard and contributors.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are met:
10 # * Redistributions of source code must retain the above copyright notice, this
11 # list of conditions and the following disclaimer.
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.
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.
32 testdir=$(dirname "${script}")
36 # We need to figure out if we should run stuff in parallel.
39 while getopts "n" opt; do
42 n) pll=0 ; shift ; set -e ;;
43 ?) usage "Invalid option: $opt" ;;
48 # Command-line processing.
49 if [ "$#" -eq 0 ]; then
50 printf 'usage: %s [-n] dir [run_extra_tests] [run_stack_tests] [generate_tests] [time_tests] [exec args...]\n' "$script"
57 if [ "$#" -gt 0 ]; then
64 if [ "$#" -gt 0 ]; then
71 if [ "$#" -gt 0 ]; then
78 if [ "$#" -gt 0 ]; then
85 if [ "$#" -gt 0 ]; then
89 exe="$testdir/../bin/$d"
92 scriptdir="$testdir/$d/scripts"
94 scripts=$(cat "$scriptdir/all.txt")
96 # Run each script test individually.
101 if [ "$pll" -ne 0 ]; then
102 sh "$testdir/script.sh" "$d" "$f" "$run_extra_tests" "$run_stack_tests" \
103 "$generate" "$time_tests" "$exe" "$@" &
106 sh "$testdir/script.sh" "$d" "$f" "$run_extra_tests" "$run_stack_tests" \
107 "$generate" "$time_tests" "$exe" "$@"
112 if [ "$pll" -ne 0 ]; then
121 if [ "$err" -ne 0 ]; then
122 printf 'A script failed!\n'
128 if [ "$exit_err" -ne 0 ]; then