author | iignatyev |
Fri, 01 Jun 2018 15:48:55 -0700 | |
changeset 50366 | 4d85990f9c4a |
parent 49934 | 44839fbb20db |
child 50618 | 2aa21bb12059 |
permissions | -rw-r--r-- |
49934
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
1 |
/* |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
2 |
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
4 |
* |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
8 |
* |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
14 |
* |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
18 |
* |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
22 |
*/ |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
23 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
24 |
import jdk.test.lib.Platform; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
25 |
import jdk.test.lib.Utils; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
26 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
27 |
import java.io.File; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
28 |
import java.io.IOException; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
29 |
import java.io.InputStream; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
30 |
import java.io.OutputStream; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
31 |
import java.nio.file.Path; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
32 |
import java.nio.file.Paths; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
33 |
import java.util.Arrays; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
34 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
35 |
/** |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
36 |
* Starts a new process to execute a command. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
37 |
* <p>Usage: --java|--cmd|--launcher <arg>+ |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
38 |
* <p>If {@code --cmd} flag is specified, the arguments are treated as |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
39 |
* a program to run and its arguments. Non-zero exit code of the created process |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
40 |
* will be reported as an {@link AssertionError}. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
41 |
* <p>If {@code --java} flag is specified, the arguments are passed to {@code java} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
42 |
* from JDK under test. If exit code doesn't equal to 0 or 95, {@link AssertionError} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
43 |
* will be thrown. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
44 |
* <p>If {@code --launcher} flag is specified, the arguments treated similar as |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
45 |
* for {@code --cmd}, but the started process will have the directory which |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
46 |
* contains {@code jvm.so} in dynamic library path, and {@code test.class.path} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
47 |
* as CLASSPATH environment variable. Exit codes are checked as in |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
48 |
* {@code --java}, i.e. 0 or 95 means pass. |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
49 |
*/ |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
50 |
public class ExecDriver { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
51 |
public static void main(String[] args) throws IOException, InterruptedException { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
52 |
boolean java = false; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
53 |
boolean launcher = false; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
54 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
55 |
String type = args[0]; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
56 |
switch (type) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
57 |
case "--java": |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
58 |
String[] oldArgs = args; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
59 |
int count; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
60 |
String libraryPath = System.getProperty("test.nativepath"); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
61 |
if (libraryPath != null && !libraryPath.isEmpty()) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
62 |
count = 4; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
63 |
args = new String[args.length + 3]; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
64 |
args[3] = "-Djava.library.path=" + libraryPath; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
65 |
} else { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
66 |
count = 3; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
67 |
args = new String[args.length + 2]; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
68 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
69 |
args[0] = javaBin(); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
70 |
args[1] = "-cp"; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
71 |
args[2] = Utils.TEST_CLASS_PATH; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
72 |
System.arraycopy(oldArgs, 1, args, count, oldArgs.length - 1); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
73 |
java = true; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
74 |
break; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
75 |
case "--launcher": |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
76 |
java = true; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
77 |
launcher = true; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
78 |
case "--cmd": |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
79 |
args = Arrays.copyOfRange(args, 1, args.length); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
80 |
break; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
81 |
default: |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
82 |
throw new Error("unknown type: " + type); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
83 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
84 |
// adding 'test.vm.opts' and 'test.java.opts' |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
85 |
if (java) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
86 |
String[] oldArgs = args; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
87 |
String[] testJavaOpts = Utils.getTestJavaOpts(); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
88 |
if (testJavaOpts.length > 0) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
89 |
args = new String[args.length + testJavaOpts.length]; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
90 |
// bin/java goes before options |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
91 |
args[0] = oldArgs[0]; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
92 |
// then external java options |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
93 |
System.arraycopy(testJavaOpts, 0, args, 1, testJavaOpts.length); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
94 |
// and then options and args from a test |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
95 |
System.arraycopy(oldArgs, 1, args, 1 + testJavaOpts.length, oldArgs.length - 1); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
96 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
97 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
98 |
String command = Arrays.toString(args); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
99 |
System.out.println("exec " + command); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
100 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
101 |
ProcessBuilder pb = new ProcessBuilder(args); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
102 |
// adding jvm.so to library path |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
103 |
if (launcher) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
104 |
Path dir = Paths.get(Utils.TEST_JDK); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
105 |
String name; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
106 |
if (Platform.isWindows()) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
107 |
dir = dir.resolve("bin") |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
108 |
.resolve(variant()) |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
109 |
.toAbsolutePath(); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
110 |
name = "PATH"; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
111 |
} else { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
112 |
dir = dir.resolve("lib") |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
113 |
.resolve(variant()) |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
114 |
.toAbsolutePath(); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
115 |
name = Platform.isOSX() ? "DYLD_LIBRARY_PATH" : "LD_LIBRARY_PATH"; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
116 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
117 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
118 |
System.out.println(" with " + name + " = " + |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
119 |
pb.environment() |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
120 |
.merge(name, dir.toString(), (x, y) -> y + File.pathSeparator + x)); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
121 |
System.out.println(" with CLASSPATH = " + |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
122 |
pb.environment() |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
123 |
.put("CLASSPATH", Utils.TEST_CLASS_PATH)); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
124 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
125 |
Process p = pb.start(); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
126 |
// inheritIO does not work as expected for @run driver |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
127 |
new Thread(() -> copy(p.getInputStream(), System.out)).start(); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
128 |
new Thread(() -> copy(p.getErrorStream(), System.out)).start(); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
129 |
int exitCode = p.waitFor(); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
130 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
131 |
if (exitCode != 0 && (!java || exitCode != 95)) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
132 |
throw new AssertionError(command + " exit code is " + exitCode); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
133 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
134 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
135 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
136 |
private static String variant() { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
137 |
if (Platform.isServer()) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
138 |
return "server"; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
139 |
} else if (Platform.isClient()) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
140 |
return "client"; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
141 |
} else if (Platform.isMinimal()) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
142 |
return "minimal"; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
143 |
} else { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
144 |
throw new Error("TESTBUG: unsuppported vm variant"); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
145 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
146 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
147 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
148 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
149 |
private static void copy(InputStream is, OutputStream os) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
150 |
byte[] buffer = new byte[1024]; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
151 |
int n; |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
152 |
try (InputStream close = is) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
153 |
while ((n = is.read(buffer)) != -1) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
154 |
os.write(buffer, 0, n); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
155 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
156 |
os.flush(); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
157 |
} catch (IOException e) { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
158 |
e.printStackTrace(); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
159 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
160 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
161 |
|
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
162 |
private static String javaBin() { |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
163 |
return Paths.get(Utils.TEST_JDK) |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
164 |
.resolve("bin") |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
165 |
.resolve("java") |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
166 |
.toAbsolutePath() |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
167 |
.toString(); |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
168 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
169 |
} |
44839fbb20db
8199643: [TESTBUG] Open source common VM testbase code
iignatyev
parents:
diff
changeset
|
170 |