• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
30set -e
31
32script="$0"
33testdir=$(dirname "$script")
34
35. "$testdir/../functions.sh"
36
37if [ "$#" -ge 1 ]; then
38	d="$1"
39	shift
40else
41	err_exit "usage: $script dir [run_extra_tests] [run_stack_tests] [gen_tests] [time_tests] [exec args...]" 1
42fi
43
44if [ "$#" -lt 1 ]; then
45	extra=1
46else
47	extra="$1"
48	shift
49fi
50
51if [ "$#" -lt 1 ]; then
52	run_stack_tests=1
53else
54	run_stack_tests="$1"
55	shift
56fi
57
58if [ "$#" -lt 1 ]; then
59	generate_tests=1
60else
61	generate_tests="$1"
62	shift
63fi
64
65if [ "$#" -lt 1 ]; then
66	time_tests=0
67else
68	time_tests="$1"
69	shift
70fi
71
72if [ "$#" -lt 1 ]; then
73	exe="$testdir/../bin/$d"
74else
75	exe="$1"
76	shift
77fi
78
79stars="***********************************************************************"
80printf '%s\n' "$stars"
81
82if [ "$d" = "bc" ]; then
83	halt="quit"
84else
85	halt="q"
86fi
87
88unset BC_ENV_ARGS
89unset BC_LINE_LENGTH
90unset DC_ENV_ARGS
91unset DC_LINE_LENGTH
92
93printf '\nRunning %s tests...\n\n' "$d"
94
95while read t; do
96
97	if [ "$extra" -eq 0  ]; then
98		if [ "$t" = "trunc" ] || [ "$t" = "places" ] || [ "$t" = "shift" ] || \
99		   [ "$t" = "lib2" ] || [ "$t" = "scientific" ] || [ "$t" = "rand" ] || \
100		   [ "$t" = "engineering" ]
101		then
102			printf 'Skipping %s %s\n' "$d" "$t"
103			continue
104		fi
105	fi
106
107	sh "$testdir/test.sh" "$d" "$t" "$generate_tests" "$time_tests" "$exe" "$@"
108
109done < "$testdir/$d/all.txt"
110
111sh "$testdir/stdin.sh" "$d" "$exe" "$@"
112
113sh "$testdir/scripts.sh" "$d" "$extra" "$run_stack_tests" "$generate_tests" \
114	"$time_tests" "$exe" "$@"
115sh "$testdir/read.sh" "$d" "$exe" "$@"
116sh "$testdir/errors.sh" "$d" "$exe" "$@"
117
118sh "$testdir/other.sh" "$d" "$exe" "$@"
119
120printf '\nAll %s tests passed.\n' "$d"
121
122printf '\n%s\n' "$stars"
123