Debian Codegraph @

rhino/testsrc/tests/process-logs.sh

raw symbols SCIP
1 #!/bin/bash -e
2 # -*- Mode: Shell-script; tab-width: 4; indent-tabs-mode: nil; -*-
3
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
8 if [[ -z "$TEST_DIR" ]]; then
9 cat <<EOF
10 `basename $0`: error
11
12 TEST_DIR, the location of the Sisyphus framework,
13 is required to be set prior to calling this script.
14 EOF
15 exit 2
16 fi
17
18 if [[ ! -e $TEST_DIR/bin/library.sh ]]; then
19 echo "TEST_DIR=$TEST_DIR"
20 echo ""
21 echo "This script requires the Sisyphus testing framework. Please "
22 echo "cvs check out the Sisyphys framework from mozilla/testing/sisyphus"
23 echo "and set the environment variable TEST_DIR to the directory where it"
24 echo "located."
25 echo ""
26
27 exit 2
28 fi
29
30 source $TEST_DIR/bin/library.sh
31
32 TEST_JSDIR=${TEST_JSDIR:-$TEST_DIR/tests/mozilla.org/js}
33
34 usage()
35 {
36 cat <<EOF
37 usage: process-logs.sh.sh -l testlogfiles -A arch -K kernel
38
39 variable description
40 =============== ============================================================
41 testlogfiles The test log to be processed. If testlogfiles is a file
42 pattern it must be single quoted to prevent the shell from
43 expanding it before it is passed to the script.
44 EOF
45 exit 2
46 }
47
48 while getopts "l:" optname;
49 do
50 case $optname in
51 l) testlogfiles=$OPTARG;;
52 esac
53 done
54
55 if [[ -z "$testlogfiles" ]]; then
56 usage
57 fi
58
59 for testlogfile in `ls $testlogfiles`; do
60
61 debug "testlogfile=$testlogfile"
62
63 case $testlogfile in
64 *.log)
65 worktestlogfile=$testlogfile
66 ;;
67 *.log.bz2)
68 worktestlogfile=`mktemp $testlogfile.XXXXXX`
69 bunzip2 -c $testlogfile > $worktestlogfile
70 ;;
71 *.log.gz)
72 worktestlogfile=`mktemp $testlogfile.XXXXXX`
73 gunzip -c $testlogfile > $worktestlogfile
74 ;;
75 *)
76 echo "unknown log type: $f"
77 exit 2
78 ;;
79 esac
80
81 case "$testlogfile" in
82 *,js,*) testtype=shell;;
83 *,firefox,*) testtype=browser;;
84 *,thunderbird,*) testtype=browser;;
85 *,fennec,*) testtype=browser;;
86 *) error "unknown testtype in logfile $testlogfile" $LINENO;;
87 esac
88
89 debug "testtype=$testtype"
90
91 case "$testlogfile" in
92 *,nightly*) buildtype=nightly;;
93 *,opt,*) buildtype=opt;;
94 *,debug,*) buildtype=debug;;
95 *) error "unknown buildtype in logfile $testlogfile" $LINENO;
96 esac
97
98 debug "buildtype=$buildtype"
99
100 branch=`echo $testlogfile | sed 's|.*,\([0-9]\.[0-9]*\.[0-9]*\).*|\1|'`
101
102 debug "branch=$branch"
103
104 repo=`grep -m 1 '^environment: TEST_MOZILLA_HG=' $worktestlogfile | sed 's|.*TEST_MOZILLA_HG=http://hg.mozilla.org.*/\([^\/]*\)|\1|'`
105 if [[ -z "$repo" ]]; then
106 repo=CVS
107 fi
108 debug "repo=$repo"
109
110 case "$testlogfile" in
111 *,nt,*) OSID=nt;;
112 *,linux,*) OSID=linux;;
113 *,darwin,*) OSID=darwin;;
114 *)
115 OSID=`grep -m 1 '^environment: OSID=' $worktestlogfile | sed 's|.*OSID=\(.*\)|\1|'`
116 if [[ -z "$OSID" ]]; then
117 error "unknown OS in logfile $testlogfile" $LINENO
118 fi
119 ;;
120 esac
121
122 debug "OSID=$OSID"
123
124 kernel=`grep -m 1 '^environment: TEST_KERNEL=' $worktestlogfile | sed 's|.*TEST_KERNEL=\(.*\)|\1|'`
125 if [[ "$OSID" == "linux" ]]; then
126 kernel=`echo $kernel | sed 's|\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*|\1.\2.\3|'`
127 fi
128 debug "kernel=$kernel"
129
130 arch=`grep -m 1 '^environment: TEST_PROCESSORTYPE=' $worktestlogfile | sed 's|.*TEST_PROCESSORTYPE=\(.*\)|\1|'`
131 debug "arch=$arch"
132
133 memory=`grep -m 1 '^environment: TEST_MEMORY=' $worktestlogfile | sed 's|.*TEST_MEMORY=\(.*\)|\1|'`
134
135 timezone=`basename $testlogfile | sed 's|^[-0-9]*\([-+]\)\([0-9]\{4,4\}\),.*|\1\2|'`
136 debug "timezone=$timezone"
137
138 jsoptions=`grep -m 1 '^arguments: javascriptoptions=' $worktestlogfile | sed 's|.*javascriptoptions=\(.*\)|\1|'`
139 if [[ -z "$jsoptions" ]]; then
140 jsoptions=none
141 fi
142 debug "jsoptions=$jsoptions"
143
144 outputprefix=$testlogfile
145
146 includetests="included-$branch-$testtype-$buildtype.tests"
147 excludetests="excluded-$branch-$testtype-$buildtype.tests"
148
149 grep '^include: ' $worktestlogfile | sed 's|include: ||' > $TEST_DIR/tests/mozilla.org/js/$includetests
150 grep '^exclude: ' $worktestlogfile | sed 's|exclude: ||' > $TEST_DIR/tests/mozilla.org/js/$excludetests
151
152 $TEST_DIR/tests/mozilla.org/js/known-failures.pl \
153 -b "$branch" \
154 -T "$buildtype" \
155 -R "$repo" \
156 -t "$testtype" \
157 -o "$OSID" \
158 -K "$kernel" \
159 -A "$arch" \
160 -M "$memory" \
161 -z "$timezone" \
162 -J "$jsoptions" \
163 -r "$TEST_JSDIR/failures.txt" \
164 -l "$worktestlogfile" \
165 -O "$outputprefix"
166
167 if [[ "$testlogfile" != "$worktestlogfile" ]]; then
168 rm $worktestlogfile
169 unset worktestlogfile
170 fi
171 done