File: run

package info (click to toggle)
nginx 1.18.0-6.1%2Bdeb11u3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 19,344 kB
  • sloc: ansic: 250,653; perl: 7,548; sh: 1,408; ruby: 879; python: 358; makefile: 338; awk: 36; cpp: 18
file content (86 lines) | stat: -rwxr-xr-x 1,849 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#! /bin/bash
set -e

if [[ $# -lt 1 || $# -gt 2 ]] ; then
	echo "Usage: $0 <prefix-path> [1]" 1>&2
	exit 1
fi

# Obtain the absolute path to the tests directory
pushd "$(dirname "$0")" &> /dev/null
readonly T=$(pwd)
popd &> /dev/null
export T

# Same for the nginx prefix directory
pushd "$1" &> /dev/null
readonly prefix=$(pwd)
popd &> /dev/null

dynamic=false
if [[ $# -gt 1 && $2 -eq 1 ]] ; then
	dynamic=true
fi
readonly dynamic

declare -a t_pass=( )
declare -a t_fail=( )
declare -a t_skip=( )

for t in `ls "$T"/*.test | sort -R` ; do
	name="t/${t##*/}"
	name=${name%.test}
	printf "${name} ... "
	errfile="${name}.err"
	outfile="${name}.out"
	shfile="${name}.sh"
	cat > "${shfile}" <<-EOF
	readonly DYNAMIC=${dynamic}
	readonly TESTDIR='$T'
	readonly PREFIX='${prefix}'
	$(< "$T/preamble")
	$(< "$t")
	EOF
	if bash -e "${shfile}" > "${outfile}" 2> "${errfile}" ; then
		t_pass+=( "${name}" )
		printf 'passed\n'
	elif [[ $? -eq 111 ]] ; then
		t_skip+=( "${name}" )
		printf 'skipped\n'
	else
		t_fail+=( "${name}" )
		printf 'failed\n'
	fi
done

for name in "${t_fail[@]}" ; do
	echo
	printf '=== %s.out\n' "${name}"
	cat "${name}.out"
	echo
	printf '=== %s.err\n' "${name}"
	cat "${name}.err"
	echo
done

if [[ ${#t_skip[@]} -gt 0 ]] ; then
	echo
	printf 'Skipped tests:\n'
	for name in "${t_skip[@]}" ; do
		reason=$(grep '^(\-\-) ' "${name}.err" | head -1)
		if [[ -z ${reason} ]] ; then
			reason='No reason given'
		else
			reason=${reason:5}
		fi
		printf ' - %s: %s\n' "${name}" "${reason:-No reason given}"
	done
	echo
fi

printf '=== passed/skipped/failed/total: %d/%d/%d/%d\n' \
	${#t_pass[@]} ${#t_skip[@]} ${#t_fail[@]} $(( ${#t_pass[@]} + ${#t_fail[@]} ))

if [[ ${#t_fail[@]} -gt 0 ]] ; then
	exit 1
fi