File: gime-bisectdir.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 (101 lines) | stat: -rwxr-xr-x 2,111 bytes parent folder | download
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
#!/bin/sh

set -eu

if test "$#" -lt 1; then
    cat >>/dev/stderr <<EOF

Usage:

   $0 <summarydir> [ <test-result> }

Create the directory bisect/ containing json dumps of each test's
results.  In theory can be used to bisect a test.

EOF
    exit 1
fi

bindir=$(realpath $(dirname $0))

summarydir=$(realpath $1) ; shift
bisectdir=${summarydir}/bisect


echo 'cleaning out previous run'


find ${bisectdir} -name '*.tmp' -print | xargs --no-run-if-empty rm


echo 'creating a list of all test runs'

{
    {
	# ${summarydir}/${run}/summary.json
	find ${summarydir} \
	     -name summary.json \
	     -printf '%h\n'
    } | {
	sed -e 's;.*/;;'
    } | {
	sort -V
    } > ${bisectdir}/runs.tmp
    jq -R < ${bisectdir}/runs.tmp | jq -s > ${bisectdir}/runs.json
}

echo 'creating a list of all tests'

{
    {
	find ${summarydir} \
	     -name results.json \
	     -print
    } | {
	xargs jq -r '.[].test_name'
    } | {
	sort -u
    } > ${bisectdir}/tests.tmp
    jq -R < ${bisectdir}/tests.tmp | jq -s > ${bisectdir}/tests.json
}

echo 'merge ${summarydir}/${rundir}/${testdir}/OUTPUT/result.json into ${test}.json'

{
    while read testdir ; do
	echo -n "${testdir} " 1>&1
	while read rundir ; do
	    result=${summarydir}/${rundir}/${testdir}/OUTPUT/result.json
	    if test -r ${result} ; then
		echo -n "+" 1>&2
		jq --arg rundir "${rundir}" \
		   '. + { run: $rundir }' \
		   < ${result}
	    else
		echo -n "-" 1>&2
		echo '{ "run": "'"${rundir}"'" }'
	    fi
	done < ${bisectdir}/runs.tmp > ${bisectdir}/${testdir}.tmp
	jq -s \
	   < ${bisectdir}/${testdir}.tmp \
	   > ${bisectdir}/${testdir}.json
	echo 1>&2
    done < ${bisectdir}/tests.tmp
}

echo merging into all.json

{
    {
	jq '{ runs: . }' < ${bisectdir}/runs.json
	while read testdir ; do
	    # array of results
	    jq --arg testdir ${testdir} \
	       'reduce .[] as $d ({ ($testdir): [] }; .[$testdir] += [$d.result] )' \
	       < ${bisectdir}/${testdir}.json
	done < ${bisectdir}/tests.tmp | jq -s 'add|{ results: .}'
    } > ${bisectdir}/all.tmp
    jq -s 'add' \
       < ${bisectdir}/all.tmp \
       > ${bisectdir}/all.json
}