File: pluto-testlist-scan.sh

package info (click to toggle)
libreswan 5.2-2.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 81,632 kB
  • sloc: ansic: 129,988; sh: 32,018; xml: 20,646; python: 10,303; makefile: 3,022; javascript: 1,506; sed: 574; yacc: 511; perl: 264; awk: 52
file content (171 lines) | stat: -rwxr-xr-x 3,962 bytes parent folder | download | duplicates (3)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171

# pluto-testlist-scan.sh: a hack to analyze the results of Pluto tests
#
# Synopsis:
#	cd testing/pluto
#	../utils/pluto-testlist-scan.sh
# The result is, for each test, a one-line report on the latest result.
# The set of tests is specified by testing/pluto/TESTLIST.
#
# Bonus:
#
# --re-sanitize will run ../../utils/re-sanitize.sh
#   for each test (but the output will clutter the report).
#
# --meld will cause meld to be invoked where a diff is found
#
# --meld-show will report meld commands worth running
#
# Copyright 2014,2015 D. Hugh Redelmeier

set -ue

# capture path to my script as anchor for $me.dumb-cert-fragment
me=`readlink -f $0`

# be flexible about current directory
if [ -f TESTLIST ] ; then
	if [ ! TESTLIST -ef ../../testing/pluto/TESTLIST ] ; then
		echo "$me: may not be in correct directory" >&2
	fi
elif [ -f pluto/TESTLIST -a pluto/TESTLIST -ef ../testing/pluto/TESTLIST ] ; then
	cd pluto
elif [ -f testing/pluto/TESTLIST ] ; then
	cd testing/pluto
else
	echo "$me: not in correct directory" >&2
	exit 1
fi

export preprocess=""

# : is a command that does nothing
export meldop=":"

previous=""

commontest() {
	testtype="$1"
	testname="$2"
	teststatus="$3"
	notes=""

	if [ ! -d "$testname/OUTPUT" ] ; then
		notes="$notes,NO-OUTPUT"
	else
		if ! ( cd $testname ; $preprocess ) ; then
		    notes="$notes,SANITIZE-FAILED"
		fi
	fi

	if [ -f "$testname/OUTPUT/RESULT" ] ; then
		if [ -n "previous" -a "$testname/OUTPUT/RESULT" -ot "$previous" ] ; then
			ls -ld "$testname/OUTPUT/RESULT"
		fi
		previous="$testname/OUTPUT/RESULT"
	fi

	for i in "$testname"/OUTPUT/core* ; do
		if [ -f "$i" ] ; then
			notes="$notes,`basename $i`"
		fi
	done

	for i in "$testname"/OUTPUT/*.pluto.log ; do
		if [ -f "$i" ] ; then
			if grep -F 'ASSERTION FAILED' "$i" >/dev/null ; then
				notes="$notes,ASSERT:`basename $i`"
			fi
			if grep -F 'EXPECTATION FAILED' "$i" >/dev/null ; then
				notes="$notes,EXPECT:`basename $i`"
			fi
			if grep -F 'SEGFAULT' "$i" >/dev/null ; then
				notes="$notes,SEGFAULT:`basename $i`"
			fi
		fi
	done

	if [ ! -f "$testname/OUTPUT/RESULT" ] ; then
		result=none
	elif grep '"result": *"passed"' "$testname/OUTPUT/RESULT" >/dev/null ; then
		result=good
	elif grep '"result": *"failed"' "$testname/OUTPUT/RESULT" >/dev/null ; then
		result=bad
		for i in west east north road ; do
			if [ ! -f "$testname/OUTPUT/$i.console.diff" ] ; then
				# not even there
				:
			elif [ ! -s "$testname/OUTPUT/$i.console.diff" ] ; then
				notes="$notes,$i:ok"
			elif [ ! -s "$testname/$i.console.txt" ] ; then
				notes="$notes,$i:missing-baseline"
			else
				# something is in $testname/OUTPUT/$i.console.diff
				if grep -E '^[+-]' "$testname/OUTPUT/$i.console.diff" | grep -E -v '^(\+\+\+|---)' | LC_ALL=C sort -u | cmp -s - "$me.dumb-cert-fragment" ; then
					notes="$notes,$i:mainca-noise"
				elif ! grep -v 'No test for authenc(' "$testname/OUTPUT/$i.console.diff" | grep -E -v '^(\+\+\+|---)' | grep -E '^[-+]' >/dev/null ; then
					notes="$notes,$i:authenc-noise"
				else
					notes="$notes,$i:bad"
					$meldop "$testname/$i.console.txt" "$testname/OUTPUT/$i.console.diff"
				fi
			fi
		done
	else
		result=dunno
	fi
	if [ "$teststatus" = "$result" ] ; then
		show=""
	else
		show="!=$result"
	fi
	echo "$testtype	$testname	$teststatus$show$notes"
}

ctltest() {
	testname="$1"
	teststatus="$2"
	commontest "${FUNCNAME[0]}" $testname $teststatus
}

kvmplutotest() {
	testname="$1"
	teststatus="$2"
	commontest "${FUNCNAME[0]}" $testname $teststatus
}

skiptest() {
	testname="$1"
	teststatus="$2"
	commontest "${FUNCNAME[0]}" $testname $teststatus
}

umlplutotest() {
	testname="$1"
	teststatus="$2"
}

umlXhost() {
	testname="$1"
	teststatus="$2"
}

for arg ; do
	case "$arg" in
	--re-sanitize)
		preprocess="../../utils/re-sanitize.sh"
		;;
	--meld)
		meldop="meld"
		;;
	--meld-show)
		meldop="echo meld"
		;;
	*)
		echo "$me: unexpected operand: $arg" >&2
		exit 1
		;;
	esac
done

. ./TESTLIST