| 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: runtests.sh -p products -b branches -e extra\\ |
| 38 | -T buildtypes -B buildcommands \\ |
| 39 | [-v] [-S] [-X excludetests] [-I includetests] [-c] [-t] \\ |
| 40 | [-J javascriptoptions] |
| 41 | |
| 42 | variable description |
| 43 | =============== ============================================================ |
| 44 | -p products space separated list of js, firefox, fennec |
| 45 | -b branches space separated list of supported branches. see library.sh |
| 46 | -e extra optional. extra qualifier to pick build tree and mozconfig. |
| 47 | -T buildtypes space separated list of build types opt debug |
| 48 | -B buildcommands optional space separated list of build commands |
| 49 | clean, checkout, build. If not specified, defaults to |
| 50 | 'clean checkout build'. |
| 51 | If you wish to skip any build steps, simply specify a value |
| 52 | not containing any of the build commands, e.g. 'none'. |
| 53 | -v optional. verbose - copies log file output to stdout. |
| 54 | -S optional. summary - output tailered for use with |
| 55 | Buildbot|Tinderbox |
| 56 | -X excludetests optional. By default the test will exclude the |
| 57 | tests listed in spidermonkey-n-\$branch.tests, |
| 58 | performance-\$branch.tests. excludetests is a list of either |
| 59 | individual tests, manifest files or sub-directories which |
| 60 | will override the default exclusion list. |
| 61 | -I includetests optional. By default the test will include the |
| 62 | JavaScript tests appropriate for the branch. includetests is a |
| 63 | list of either individual tests, manifest files or |
| 64 | sub-directories which will override the default inclusion |
| 65 | list. |
| 66 | -c optional. By default the test will exclude tests |
| 67 | which crash on this branch, test type, build type and |
| 68 | operating system. -c will include tests which crash. |
| 69 | Typically this should only be used in combination with -R. |
| 70 | This has no effect on shell based tests which execute crash |
| 71 | tests regardless. |
| 72 | -t optional. By default the test will exclude tests |
| 73 | which time out on this branch, test type, build type and |
| 74 | operating system. -t will include tests which timeout. |
| 75 | -J jsoptions optional. Set JavaScript options: |
| 76 | -Z n Set gczeal to n. Currently, only valid for |
| 77 | debug builds of Gecko 1.8.1.15, 1.9.0 and later. |
| 78 | -z optional. use split objects in the shell. |
| 79 | -j optional. use JIT in the shell. Only available on 1.9.1 and later |
| 80 | |
| 81 | if an argument contains more than one value, it must be quoted. |
| 82 | EOF |
| 83 | exit 2 |
| 84 | } |
| 85 | |
| 86 | verbose=0 |
| 87 | |
| 88 | while getopts "p:b:T:B:e:X:I:J:vSct" optname; |
| 89 | do |
| 90 | case $optname in |
| 91 | p) products=$OPTARG;; |
| 92 | b) branches=$OPTARG;; |
| 93 | T) buildtypes=$OPTARG;; |
| 94 | e) extra="$OPTARG" |
| 95 | extraflag="-e $OPTARG";; |
| 96 | B) buildcommands=$OPTARG;; |
| 97 | v) verbose=1 |
| 98 | verboseflag="-v";; |
| 99 | S) summary=1;; |
| 100 | X) excludetests=$OPTARG;; |
| 101 | I) includetests=$OPTARG;; |
| 102 | J) javascriptoptions=$OPTARG;; |
| 103 | c) crashes=1;; |
| 104 | t) timeouts=1;; |
| 105 | esac |
| 106 | done |
| 107 | |
| 108 | # javascriptoptions will be passed by environment to test.sh |
| 109 | |
| 110 | if [[ -z "$products" || -z "$branches" || -z "$buildtypes" ]]; then |
| 111 | usage |
| 112 | fi |
| 113 | |
| 114 | if [[ -z "$buildcommands" ]]; then |
| 115 | buildcommands="clean checkout build" |
| 116 | fi |
| 117 | |
| 118 | case $buildtypes in |
| 119 | nightly) |
| 120 | buildtypes="nightly-$OSID" |
| 121 | ;; |
| 122 | opt|debug|opt*debug) |
| 123 | if [[ -n "$buildcommands" ]]; then |
| 124 | builder.sh -p "$products" -b "$branches" $extraflag -B "$buildcommands" -T "$buildtypes" "$verboseflag" |
| 125 | fi |
| 126 | ;; |
| 127 | esac |
| 128 | |
| 129 | testlogfilelist=`mktemp /tmp/TESTLOGFILES.XXXX` |
| 130 | trap "_exit; rm -f $testlogfilelist" EXIT |
| 131 | |
| 132 | export testlogfiles |
| 133 | export testlogfile |
| 134 | |
| 135 | # because without pipefail, the pipe will not return a non-zero |
| 136 | # exit code, we must pipe stderr from tester.sh to stdout and then |
| 137 | # look into the testlogfilelist for the error |
| 138 | |
| 139 | branchesextra=`combo.sh -d - "$branches" "$extra"` |
| 140 | |
| 141 | # can't test tester.sh's exit code to see if there was |
| 142 | # an error since we are piping it and can't count on pipefail |
| 143 | tester.sh -t "$TEST_JSDIR/test.sh" $verboseflag "$products" "$branchesextra" "$buildtypes" 2>&1 | tee -a $testlogfilelist |
| 144 | testlogfiles="`grep '^log:' $testlogfilelist|sed 's|^log: ||'`" |
| 145 | |
| 146 | fatalerrors=`grep 'FATAL ERROR' $testlogfiles | cat` |
| 147 | if [[ -n "$fatalerrors" ]]; then |
| 148 | testlogarray=( $testlogfiles ) |
| 149 | let itestlog=${#testlogarray[*]}-1 |
| 150 | error "`tail -n 20 ${testlogarray[$itestlog]}`" $LINENO |
| 151 | fi |
| 152 | |
| 153 | for testlogfile in $testlogfiles; do |
| 154 | |
| 155 | if [[ -n "$DEBUG" ]]; then |
| 156 | dumpvars testlogfile |
| 157 | fi |
| 158 | |
| 159 | case "$testlogfile" in |
| 160 | *,js,*) testtype=shell;; |
| 161 | *,firefox,*) testtype=browser;; |
| 162 | *,thunderbird,*) testtype=browser;; |
| 163 | *,fennec,*) testtype=browser;; |
| 164 | *) error "unknown testtype in logfile $testlogfile" $LINENO;; |
| 165 | esac |
| 166 | |
| 167 | case "$testlogfile" in |
| 168 | *,opt,*) buildtype=opt;; |
| 169 | *,debug,*) buildtype=debug;; |
| 170 | *,nightly*) buildtype=opt;; |
| 171 | *) error "unknown buildtype in logfile $testlogfile" $LINENO;; |
| 172 | esac |
| 173 | |
| 174 | branch=`echo $testlogfile | sed 's|.*,\([0-9]\.[0-9]*\.[0-9]*\).*|\1|'` |
| 175 | |
| 176 | |
| 177 | repo=`grep -m 1 '^environment: TEST_MOZILLA_HG=' $testlogfile | sed 's|.*TEST_MOZILLA_HG=http://hg.mozilla.org.*/\([^\/]*\)|\1|'` |
| 178 | if [[ -z "$repo" ]]; then |
| 179 | repo=CVS |
| 180 | fi |
| 181 | debug "repo=$repo" |
| 182 | |
| 183 | outputprefix=$testlogfile |
| 184 | |
| 185 | if [[ -n "$DEBUG" ]]; then |
| 186 | dumpvars branch buildtype testtype OSID testlogfile TEST_PROCESSORTYPE TEST_KERNEL outputprefix |
| 187 | fi |
| 188 | |
| 189 | if ! $TEST_DIR/tests/mozilla.org/js/known-failures.pl \ |
| 190 | -b $branch \ |
| 191 | -T $buildtype \ |
| 192 | -R $repo \ |
| 193 | -t $testtype \ |
| 194 | -J "$javascriptoptions" \ |
| 195 | -o "$OSID" \ |
| 196 | -K "$TEST_KERNEL" \ |
| 197 | -A "$TEST_PROCESSORTYPE" \ |
| 198 | -M "$TEST_MEMORY" \ |
| 199 | -z `date +%z` \ |
| 200 | -l $testlogfile \ |
| 201 | -r $TEST_JSDIR/failures.txt \ |
| 202 | -O $outputprefix; then |
| 203 | error "known-failures.pl" $LINENO |
| 204 | fi |
| 205 | |
| 206 | if [[ -n "$summary" ]]; then |
| 207 | |
| 208 | # use let to work around mac problem where numbers were |
| 209 | # output with leading characters. |
| 210 | # if let's arg evaluates to 0, let will return 1 |
| 211 | # so we need to test |
| 212 | |
| 213 | if let npass="`grep TEST_RESULT=PASSED ${outputprefix}-results-all.log | wc -l`"; then true; fi |
| 214 | if let nfail="`cat ${outputprefix}-results-failures.log | wc -l`"; then true; fi |
| 215 | if let nfixes="`cat ${outputprefix}-results-possible-fixes.log | wc -l`"; then true; fi |
| 216 | if let nregressions="`cat ${outputprefix}-results-possible-regressions.log | wc -l`"; then true; fi |
| 217 | |
| 218 | echo -e "\nJavaScript Tests $branch $buildtype $testtype\n" |
| 219 | echo -e "\nFailures:\n" |
| 220 | cat "${outputprefix}-results-failures.log" |
| 221 | echo -e "\nPossible Fixes:\n" |
| 222 | cat "${outputprefix}-results-possible-fixes.log" |
| 223 | echo -e "\nPossible Regressions:\n" |
| 224 | cat "${outputprefix}-results-possible-regressions.log" |
| 225 | echo -e "\nTinderboxPrint:<div title=\"$testlogfile\">\n" |
| 226 | echo -e "\nTinderboxPrint:js tests<br/>$branch $buildtype $testtype<br/>$npass/$nfail<br/>F:$nfixes R:$nregressions" |
| 227 | echo -e "\nTinderboxPrint:</div>\n" |
| 228 | fi |
| 229 | |
| 230 | done |