File: user-params

package info (click to toggle)
debian-installer-utils 1.156
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 944 kB
  • sloc: sh: 1,001; ansic: 160; makefile: 62
file content (46 lines) | stat: -rwxr-xr-x 905 bytes parent folder | download | duplicates (12)
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
#! /bin/sh
set -e

export TESTSUITE=1
TESTFILE=user-params.in
trap 'rm -f "$TESTFILE"' 0 HUP INT QUIT TERM

[ "$TEST_VERBOSE" ] || TEST_VERBOSE=0

TESTS=0
SUCCESSES=0
TESTING=""

while read line; do
	if [ "$TESTING" ]; then
		if [ "$RESULT" = "$line" ]; then
			SUCCESSES=$(($SUCCESSES + 1))
		elif [ $TEST_VERBOSE -ge 3 ]; then
			echo "Test $TESTS: $INPUT"
			echo "Expected: $line"
			echo "Got     : $RESULT"
		fi
		TESTING=""
	elif echo "$line" | egrep -q "^[[:space:]]*(#.*)?$"; then
		continue
	else
		TESTS=$(($TESTS + 1))
		TESTING=1
		INPUT="$line"
		echo "$INPUT" >$TESTFILE
		RESULT="$(../../user-params | tr "\n" " " | sed "s/ $//")"
	fi
done <user-params.tests

if [ "$TESTING" ]; then
	echo "error: missing results line"
	exit 1
fi

if [ $TEST_VERBOSE -ge 2 ]; then
	echo "Result: $SUCCESSES out of $TESTS test cases were successful"
fi
if [ $SUCCESSES -ne $TESTS ]; then
	exit 1
fi
exit 0