[Release] Webkit2-efl-123997_0.11.85
[framework/web/webkit-efl.git] / Tools / Scripts / run-fast-jsc
1 #! /bin/sh
2
3 # Copyright (C) 2012 Apple Inc. All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 # 1. Redistributions of source code must retain the above copyright
9 #    notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 #    notice, this list of conditions and the following disclaimer in the
12 #    documentation and/or other materials provided with the distribution.
13 #
14 # THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
18 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
25
26 # Script to run selected LayoutTests/fast/{js,regex} tests using jsc
27
28 jscCmd="/System/Library/Frameworks/JavaScriptCore.framework/Resources/jsc"
29 testRoot=/tmp/LayoutTests
30 resultsRoot=`date \+/tmp/results-%Y-%m-%d-%H-%M-%S`
31 testList="unset"
32
33 cmdName=`basename $0`
34
35 function usage()
36 {
37     echo "usage: $cmdName [[--jsc | -j] <path-to-jsc>] [[--results-dir | -r] <results-path>]"
38     echo "                    [[--test-root | -t] <test-root-path>] [[--test-list | -l] <test-list-file>]"
39     exit 1
40 }
41
42 while [ $# -gt 1 ]
43 do
44     case $1 in
45     --jsc|-j)
46         jscCmd=$2
47         ;;
48     --results-dir|-r)
49         resultsRoot=$2
50         ;;
51     --test-root|-t)
52         testRoot=$2
53         ;;
54     --test-list|-l)
55         testList=$2
56         ;;
57     *)
58         echo "Unrecognized option \"$1\""
59         usage
60         ;;
61     esac
62
63     shift 2
64 done
65
66 if [ $# -gt 0 ]
67 then
68     echo "Extra argument \"$1\""
69     usage
70 fi
71
72 if [ $testList = "unset" ]
73 then
74     testList=$testRoot/fast/js/jsc-test-list
75 fi
76
77 preScript=$testRoot/fast/js/resources/standalone-pre.js
78 postScript=$testRoot/fast/js/resources/standalone-post.js
79 passList=$resultsRoot/passed
80 failList=$resultsRoot/failed
81 crashList=$resultsRoot/crashed
82
83 numTestsRun=0
84 numPassed=0
85 numFailed=0
86 numCrashed=0
87
88 rm -rf $resultsRoot
89 rm -f jsc-tests-passed jsc-tests-failed
90
91 for test in `cat $testList`
92 do
93     testPassed=0
94     testCrashed=0
95     testName=`basename $test`
96     dirName=`dirname $test`
97      
98     expectedOut="$testRoot/$dirName/${testName}-expected.txt"
99     actualOut="$resultsRoot/$dirName/${testName}-out.txt"
100     actualErr="$resultsRoot/$dirName/${testName}-err.txt"
101     diffOut="$resultsRoot/$dirName/${testName}-diff.txt"
102     jsTest="$testRoot/$dirName/script-tests/${testName}.js"
103
104     if [ ! -d "$resultsRoot/$dirName" ]
105     then
106         mkdir -p "$resultsRoot/$dirName"
107     fi
108
109     if [ -f $expectedOut -a -f $jsTest ]
110     then
111         echo "Testing $test ... \c"
112         let numTestsRun=$numTestsRun+1
113         $jscCmd $preScript $jsTest $postScript 2>$actualErr > $actualOut
114         JSC_RES=$?
115         
116         if [ $JSC_RES -eq 0 ]
117         then
118             diff $actualOut $expectedOut > $diffOut
119             if [ $? -eq 0 ]
120             then
121                 testPassed=1
122                 echo "PASSED"
123             else
124                 testPassed=0
125                 echo "FAILED"
126             fi
127         else
128             testPassed=0
129             if [ $JSC_RES -gt 128 ]
130             then
131                 testCrashed=1
132                 echo "CRASHED"
133             else
134                 echo "ERROR: $JSC_RES"
135             fi
136         fi
137
138         if [ $testPassed -eq 1 ]
139         then
140             echo "$test" >> $passList
141             let numPassed=$numPassed+1
142         else
143             echo "$test" >> $failList
144             let numFailed=$numFailed+1
145             if [ $testCrashed -eq 1 ]
146             then
147                 echo "$test" >> $crashList
148                 let numCrashed=$numCrashed+1
149             fi
150         fi
151     fi
152 done
153
154 if [ $numPassed -eq $numTestsRun ]
155 then
156     echo "All $numTestsRun tests passed!" | tee $resultsRoot/summary
157 else
158     echo "$numPassed tests passed, $numFailed tests failed, $numCrashed tests crashed." | tee $resultsRoot/summary
159 fi
160
161 echo "Test results in $resultsRoot"