run-fast-jsc 4.5 KB

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