Wed, 09 Jan 2013 22:32:40 +0530
8005940: provide ant targets to get and update external test scripts
Reviewed-by: jlaskey, lagergren
jlaskey@3 | 1 | /* |
jlaskey@7 | 2 | * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
jlaskey@3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jlaskey@3 | 4 | * |
jlaskey@3 | 5 | * This code is free software; you can redistribute it and/or modify it |
jlaskey@3 | 6 | * under the terms of the GNU General Public License version 2 only, as |
jlaskey@3 | 7 | * published by the Free Software Foundation. |
jlaskey@3 | 8 | * |
jlaskey@3 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jlaskey@3 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jlaskey@3 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jlaskey@3 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
jlaskey@3 | 13 | * accompanied this code). |
jlaskey@3 | 14 | * |
jlaskey@3 | 15 | * You should have received a copy of the GNU General Public License version |
jlaskey@3 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
jlaskey@3 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jlaskey@3 | 18 | * |
jlaskey@3 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
jlaskey@3 | 20 | * or visit www.oracle.com if you need additional information or have any |
jlaskey@3 | 21 | * questions. |
jlaskey@3 | 22 | */ |
jlaskey@3 | 23 | |
jlaskey@3 | 24 | /** |
jlaskey@3 | 25 | * runsunspider : runs the sunspider tests and checks for compliance |
jlaskey@3 | 26 | * |
jlaskey@3 | 27 | * @test |
jlaskey@3 | 28 | * @option -timezone=PST |
jlaskey@3 | 29 | * @runif external.sunspider |
jlaskey@3 | 30 | */ |
jlaskey@3 | 31 | |
jlaskey@3 | 32 | /* |
jlaskey@3 | 33 | * Copyright (c) 2010-2011, Oracle and/or its affiliates. All rights reserved. |
jlaskey@3 | 34 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jlaskey@3 | 35 | * |
jlaskey@3 | 36 | * This code is free software; you can redistribute it and/or modify it |
jlaskey@3 | 37 | * under the terms of the GNU General Public License version 2 only, as |
jlaskey@3 | 38 | * published by the Free Software Foundation. Oracle designates this |
jlaskey@3 | 39 | * particular file as subject to the "Classpath" exception as provided |
jlaskey@3 | 40 | * by Oracle in the LICENSE file that accompanied this code. |
jlaskey@3 | 41 | * |
jlaskey@3 | 42 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jlaskey@3 | 43 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jlaskey@3 | 44 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jlaskey@3 | 45 | * version 2 for more details (a copy is included in the LICENSE file that |
jlaskey@3 | 46 | * accompanied this code). |
jlaskey@3 | 47 | * |
jlaskey@3 | 48 | * You should have received a copy of the GNU General Public License version |
jlaskey@3 | 49 | * 2 along with this work; if not, write to the Free Software Foundation, |
jlaskey@3 | 50 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jlaskey@3 | 51 | * |
jlaskey@3 | 52 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
jlaskey@3 | 53 | * or visit www.oracle.com if you need additional information or have any |
jlaskey@3 | 54 | * questions. |
jlaskey@3 | 55 | */ |
jlaskey@3 | 56 | |
jlaskey@3 | 57 | /** |
jlaskey@3 | 58 | * This is not a test, but a test "framework" for running sunspider tests. |
jlaskey@3 | 59 | * |
jlaskey@3 | 60 | */ |
jlaskey@3 | 61 | |
jlaskey@3 | 62 | function assertEq(a, b) { |
jlaskey@3 | 63 | if (a !== b) { |
jlaskey@3 | 64 | throw "ASSERTION FAILED: " + a + " should be " + b; |
jlaskey@3 | 65 | } |
jlaskey@3 | 66 | } |
jlaskey@3 | 67 | |
jlaskey@3 | 68 | var runs = 0; |
jlaskey@3 | 69 | var iterations__ = 1; |
jlaskey@3 | 70 | var total_time = 0; |
jlaskey@3 | 71 | |
jlaskey@3 | 72 | function runbench(name) { |
jlaskey@3 | 73 | var filename = name.split("/").pop(); |
jlaskey@3 | 74 | if (verbose_run) { |
jlaskey@3 | 75 | print("Running " + filename); |
jlaskey@3 | 76 | } |
jlaskey@3 | 77 | |
jlaskey@3 | 78 | var start = new Date; |
jlaskey@3 | 79 | for (var i = 0; i < iterations__; i++) { |
jlaskey@3 | 80 | load(name); |
jlaskey@3 | 81 | } |
jlaskey@3 | 82 | var stop = new Date - start; |
jlaskey@3 | 83 | total_time += stop; |
jlaskey@3 | 84 | |
jlaskey@3 | 85 | if (verbose_run) { |
jlaskey@3 | 86 | print(filename + " done in " + stop + " ms"); |
jlaskey@3 | 87 | } |
jlaskey@3 | 88 | runs++; |
jlaskey@3 | 89 | } |
jlaskey@3 | 90 | |
jlaskey@3 | 91 | function runsuite(args) { |
jlaskey@3 | 92 | var changed = false; |
jlaskey@3 | 93 | |
jlaskey@3 | 94 | try { |
jlaskey@3 | 95 | for (var n = 0; n < args.length; n++) { |
jlaskey@3 | 96 | if (args[n] == undefined) { |
jlaskey@3 | 97 | continue; |
jlaskey@3 | 98 | } |
jlaskey@3 | 99 | if (args[n].indexOf('--') == 0) { |
jlaskey@3 | 100 | continue; //ignore param |
jlaskey@3 | 101 | } |
jlaskey@3 | 102 | runbench(args[n]); |
jlaskey@3 | 103 | changed = true; |
jlaskey@3 | 104 | } |
jlaskey@3 | 105 | |
jlaskey@3 | 106 | } catch (e) { |
jlaskey@3 | 107 | print("error: " + e); |
jlaskey@3 | 108 | if (e.toString().indexOf(args) == 1) { |
jlaskey@3 | 109 | throw e; |
jlaskey@3 | 110 | } |
jlaskey@3 | 111 | // no scripting or something, silently fail |
jlaskey@3 | 112 | } |
jlaskey@3 | 113 | return changed; |
jlaskey@3 | 114 | } |
jlaskey@3 | 115 | |
jlaskey@3 | 116 | var args; |
jlaskey@3 | 117 | if (typeof $ARGS !== 'undefined') { |
jlaskey@3 | 118 | args = $ARGS; |
jlaskey@3 | 119 | } else if (typeof arguments !== 'undefined') { |
jlaskey@3 | 120 | args = arguments; |
jlaskey@3 | 121 | } |
jlaskey@3 | 122 | |
jlaskey@3 | 123 | var tests = [ |
sundar@19 | 124 | '3d-cube.js', |
sundar@19 | 125 | 'access-nsieve.js', |
sundar@19 | 126 | 'crypto-aes.js', |
sundar@19 | 127 | 'math-spectral-norm.js', |
sundar@19 | 128 | '3d-morph.js', |
sundar@19 | 129 | 'bitops-3bit-bits-in-byte.js', |
sundar@19 | 130 | 'crypto-md5.js', |
sundar@19 | 131 | '3d-raytrace.js', |
sundar@19 | 132 | 'bitops-bits-in-byte.js', |
sundar@19 | 133 | 'crypto-sha1.js', |
sundar@19 | 134 | 'regexp-dna.js', |
sundar@19 | 135 | 'access-binary-trees.js', |
sundar@19 | 136 | 'bitops-bitwise-and.js', |
sundar@19 | 137 | 'date-format-tofte.js', |
sundar@19 | 138 | 'string-fasta.js', |
sundar@19 | 139 | 'access-fannkuch.js', |
sundar@19 | 140 | 'bitops-nsieve-bits.js', |
sundar@19 | 141 | 'math-cordic.js', |
sundar@19 | 142 | 'string-tagcloud.js', |
sundar@19 | 143 | 'access-nbody.js', |
sundar@19 | 144 | 'controlflow-recursive.js', |
sundar@19 | 145 | 'math-partial-sums.js', |
sundar@19 | 146 | 'string-unpack-code.js' |
jlaskey@3 | 147 | ]; |
jlaskey@3 | 148 | |
jlaskey@3 | 149 | // handle the case this script may be run by a JS engine that doesn't |
jlaskey@3 | 150 | // support __DIR__ global variable. |
jlaskey@3 | 151 | var dir = (typeof(__DIR__) == 'undefined')? "test/script/basic/" : __DIR__; |
jlaskey@3 | 152 | |
jlaskey@3 | 153 | for (i in tests) { |
sundar@19 | 154 | tests[i] = dir + '../external/sunspider/tests/sunspider-1.0/' + tests[i]; |
jlaskey@3 | 155 | } |
jlaskey@3 | 156 | |
jlaskey@3 | 157 | var verbose_run = false; |
jlaskey@3 | 158 | |
jlaskey@3 | 159 | // check for a fileset from ant and split it - special case call from ant build.xml |
jlaskey@3 | 160 | if (args.length == 1 && args[0].toString().indexOf(' ') != -1) { |
jlaskey@3 | 161 | args[0] = args[0].replace(/\/$/, ''); |
jlaskey@3 | 162 | args = args[0].split(' '); |
jlaskey@3 | 163 | verbose_run = true; //for a file set, always run verbose for ant sunspider output |
jlaskey@3 | 164 | } |
jlaskey@3 | 165 | |
jlaskey@3 | 166 | |
jlaskey@3 | 167 | var tests_found = []; |
jlaskey@3 | 168 | |
jlaskey@3 | 169 | for (i in args) { |
jlaskey@3 | 170 | var arg = args[i]; |
jlaskey@3 | 171 | if (arg.indexOf('--') == 0) { |
jlaskey@3 | 172 | if (arg == '--verbose') { |
jlaskey@3 | 173 | verbose_run = true; |
jlaskey@3 | 174 | } |
jlaskey@3 | 175 | } else { |
jlaskey@3 | 176 | tests_found.push(arg); |
jlaskey@3 | 177 | } |
jlaskey@3 | 178 | } |
jlaskey@3 | 179 | |
jlaskey@3 | 180 | if (tests_found.length == 0) { |
jlaskey@3 | 181 | tests_found = tests; |
jlaskey@3 | 182 | } |
jlaskey@3 | 183 | |
jlaskey@3 | 184 | runsuite(tests_found); |
jlaskey@3 | 185 | |
jlaskey@3 | 186 | if (verbose_run) { |
jlaskey@3 | 187 | print(runs + "/" + tests_found.length + " tests were successfully run in " + total_time + " ms "); |
jlaskey@3 | 188 | } |
jlaskey@3 | 189 | |
jlaskey@3 | 190 | print("Sunspider finished!"); |