File: never-passed.sh

package info (click to toggle)
libreswan 5.2-2.3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 81,644 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 (100 lines) | stat: -rwxr-xr-x 2,194 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
#!/bin/sh

set -eu

output="<expectation> <nr-passed> <nr-failed> <runs-since-pass> <runs-since-fail> <total-runs> <test>"
if test $# -ne 1 ; then
    cat <<EOF >/dev/stderr

Usage:

    $0 <results-directory>

List some test stats in the form:

    ${output}

EOF

    exit 1
fi

cd $1

# Create a list of completed test runs in reverse version order (i.e.,
# latest version is first).  Presumably only completed test runs have
# the TESTLIST file.

runs=$(find . -name TESTLIST -print -prune | cut -d/ -f2 | sort -V -r)

# Use the TESTLIST from the most recent complete test run (use
# status.json to exclude the current test run).

TESTLIST=
for run in ${runs} ; do
    if grep "\"${run}\"" status.json; then
	echo "Skipping ${run}" 1>&2
    else
	TESTLIST=${run}/TESTLIST
	break;
    fi
done
if test -z "${TESTLIST}" ; then
    echo TESTLIST not found 1>&2
    exit 1
fi

# Drop some hints on how to use the output.

hints() {
    cat <<EOF 1>&2
Using ${TESTLIST}
${output}
sort -k 2,2n -k 6,6nr
EOF
}

hints

while read kind test expectation junk ; do
    case "${kind}" in
	kvmplutotest ) ;;
	* ) continue ;;
    esac
    nr_passed=0
    nr_failed=0
    total_runs=0
    runs_since_fail=
    runs_since_pass=
    for run in ${runs} ; do
	result=${run}/${test}/OUTPUT/RESULT
	if test ! -r ${result} ; then
	    # missing is treated like a fail; probably when the test
	    # was added.
	    continue
	fi
	total_runs=$((${total_runs} + 1))
	if grep -e '"result" *: *"passed"' < ${result} > /dev/null ; then
	    nr_passed=$((${nr_passed} + 1))
	    if test "${runs_since_pass}" = ""; then
		runs_since_pass=$((${total_runs} - 1))
	    fi
	else
	    nr_failed=$((${nr_failed} + 1))
	    if test "${runs_since_fail}" = ""; then
		runs_since_fail=$((${total_runs} - 1))
	    fi
	fi
    done
    if test "${runs_since_pass}" = ""; then
	runs_since_pass=${total_runs}
    fi
    if test "${runs_since_fail}" = ""; then
	runs_since_fail=${total_runs}
    fi
    # output in a format that is friendly to commands like 'sort -n -r'
    # and 'sort -k 1n -k 3nr'
    echo ${expectation} ${nr_passed} ${nr_failed} ${runs_since_pass} ${runs_since_fail} ${total_runs} ${test}
done < ${TESTLIST}

hints