8033105: Make sure Nashorn test harness can run zlib benchmark
Reviewed-by: attila, hannesw
--- a/nashorn/src/jdk/nashorn/internal/lookup/MethodHandleFactory.java Fri Apr 18 21:24:34 2014 +0200
+++ b/nashorn/src/jdk/nashorn/internal/lookup/MethodHandleFactory.java Tue Apr 22 14:09:46 2014 +0200
@@ -36,6 +36,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
+
import jdk.nashorn.internal.runtime.ConsString;
import jdk.nashorn.internal.runtime.Debug;
import jdk.nashorn.internal.runtime.DebugLogger;
--- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java Fri Apr 18 21:24:34 2014 +0200
+++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptingFunctions.java Tue Apr 22 14:09:46 2014 +0200
@@ -157,7 +157,7 @@
// Set up ENV variables.
final Map<String, String> environment = processBuilder.environment();
environment.clear();
- for (Map.Entry<Object, Object> entry : envProperties.entrySet()) {
+ for (final Map.Entry<Object, Object> entry : envProperties.entrySet()) {
environment.put(JSType.toString(entry.getKey()), JSType.toString(entry.getValue()));
}
}
@@ -168,15 +168,15 @@
// Collect output.
final StringBuilder outBuffer = new StringBuilder();
- Thread outThread = new Thread(new Runnable() {
+ final Thread outThread = new Thread(new Runnable() {
@Override
public void run() {
- char buffer[] = new char[1024];
+ final char buffer[] = new char[1024];
try (final InputStreamReader inputStream = new InputStreamReader(process.getInputStream())) {
for (int length; (length = inputStream.read(buffer, 0, buffer.length)) != -1; ) {
outBuffer.append(buffer, 0, length);
}
- } catch (IOException ex) {
+ } catch (final IOException ex) {
exception[0] = ex;
}
}
@@ -184,15 +184,15 @@
// Collect errors.
final StringBuilder errBuffer = new StringBuilder();
- Thread errThread = new Thread(new Runnable() {
+ final Thread errThread = new Thread(new Runnable() {
@Override
public void run() {
- char buffer[] = new char[1024];
+ final char buffer[] = new char[1024];
try (final InputStreamReader inputStream = new InputStreamReader(process.getErrorStream())) {
for (int length; (length = inputStream.read(buffer, 0, buffer.length)) != -1; ) {
errBuffer.append(buffer, 0, length);
}
- } catch (IOException ex) {
+ } catch (final IOException ex) {
exception[1] = ex;
}
}
@@ -205,10 +205,10 @@
// If input is present, pass on to process.
try (OutputStreamWriter outputStream = new OutputStreamWriter(process.getOutputStream())) {
if (input != UNDEFINED) {
- String in = JSType.toString(input);
+ final String in = JSType.toString(input);
outputStream.write(in, 0, in.length());
}
- } catch (IOException ex) {
+ } catch (final IOException ex) {
// Process was not expecting input. May be normal state of affairs.
}
@@ -226,9 +226,9 @@
global.set(EXIT_NAME, exit, false);
// Propagate exception if present.
- for (int i = 0; i < exception.length; i++) {
- if (exception[i] != null) {
- throw exception[i];
+ for (final IOException element : exception) {
+ if (element != null) {
+ throw element;
}
}
--- a/nashorn/test/script/basic/compile-octane-splitter.js Fri Apr 18 21:24:34 2014 +0200
+++ b/nashorn/test/script/basic/compile-octane-splitter.js Tue Apr 22 14:09:46 2014 +0200
@@ -26,6 +26,7 @@
* @option -Dnashorn.compiler.splitter.threshold=1000
* @fork
* @runif external.octane
+ * @option -scripting
*/
compile_only = true;
--- a/nashorn/test/script/basic/compile-octane-splitter.js.EXPECTED Fri Apr 18 21:24:34 2014 +0200
+++ b/nashorn/test/script/basic/compile-octane-splitter.js.EXPECTED Tue Apr 22 14:09:46 2014 +0200
@@ -12,3 +12,4 @@
[richards] Compiled OK
[splay] Compiled OK
[typescript] Compiled OK
+[zlib] Compiled OK
--- a/nashorn/test/script/basic/compile-octane.js Fri Apr 18 21:24:34 2014 +0200
+++ b/nashorn/test/script/basic/compile-octane.js Tue Apr 22 14:09:46 2014 +0200
@@ -24,6 +24,7 @@
/**
* @test
* @runif external.octane
+ * @option -scripting
*/
compile_only = true;
--- a/nashorn/test/script/basic/compile-octane.js.EXPECTED Fri Apr 18 21:24:34 2014 +0200
+++ b/nashorn/test/script/basic/compile-octane.js.EXPECTED Tue Apr 22 14:09:46 2014 +0200
@@ -12,3 +12,4 @@
[richards] Compiled OK
[splay] Compiled OK
[typescript] Compiled OK
+[zlib] Compiled OK
--- a/nashorn/test/script/basic/run-octane.js Fri Apr 18 21:24:34 2014 +0200
+++ b/nashorn/test/script/basic/run-octane.js Tue Apr 22 14:09:46 2014 +0200
@@ -25,6 +25,14 @@
* @subtest
*/
+var read = readFully;
+
+function initZlib() {
+ zlib = new BenchmarkSuite('zlib', [152815148], [
+ new Benchmark('zlib', false, true, 10,
+ runZlib, undefined, tearDownZlib, null, 3)]);
+}
+
var tests = [
{name:"box2d", files:["box2d.js"], suite:"Box2DBenchmark"},
{name:"code-load", files:["code-load.js"], suite:"CodeLoad"},
@@ -39,9 +47,9 @@
{name:"regexp", files:["regexp.js"], suite:"RegExpSuite"},
{name:"richards", files:["richards.js"], suite:"Richards"},
{name:"splay", files:["splay.js"], suite:"Splay"},
- {name:"typescript", files:["typescript.js", "typescript-input.js", "typescript-compiler.js"], suite:"typescript"}
+ {name:"typescript", files:["typescript.js", "typescript-input.js", "typescript-compiler.js"], suite:"typescript"},
//zlib currently disabled - requires read
- // {name:"zlib", files:["zlib.js", "zlib-data.js"], suite:"zlib"},
+ {name:"zlib", files:["zlib.js", "zlib-data.js"], suite:"zlib", before:initZlib}
];
var dir = (typeof(__DIR__) == 'undefined') ? "test/script/basic/" : __DIR__;
@@ -78,6 +86,10 @@
print_verbose(arg, "loading '" + arg.name + "' [" + f + "]...");
load(file_name);
}
+
+ if (typeof arg.before !== 'undefined') {
+ arg.before();
+ }
if (compile_and_return) {
print_always(arg, "Compiled OK");
@@ -86,6 +98,7 @@
}
+
function run_one_benchmark(arg, iters) {
if (!load_bench(arg)) {
--- a/nashorn/test/script/basic/runsunspider-eager.js Fri Apr 18 21:24:34 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/**
- * runsunspider : runs the sunspider tests and checks for compliance
- *
- * @test
- * @option -timezone=PST
- * @runif external.sunspider
- */
-
-load(__DIR__ + "runsunspider.js");
-
--- a/nashorn/test/script/basic/runsunspider.js Fri Apr 18 21:24:34 2014 +0200
+++ b/nashorn/test/script/basic/runsunspider.js Tue Apr 22 14:09:46 2014 +0200
@@ -24,7 +24,9 @@
/**
* runsunspider : runs the sunspider tests and checks for compliance
*
- * @subtest
+ * @test
+ * @option -timezone=PST
+ * @runif external.sunspider
*/
/**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/runsunspider.js.EXPECTED Tue Apr 22 14:09:46 2014 +0200
@@ -0,0 +1,1 @@
+Sunspider finished!