author | aefimov |
Tue, 10 Jan 2017 22:15:54 +0300 | |
changeset 43126 | 26c4004e8cc0 |
parent 36483 | 2bc58b5e99d3 |
permissions | -rw-r--r-- |
36483
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
1 |
/* |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
4 |
* |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
8 |
* |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
13 |
* accompanied this code). |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
14 |
* |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
18 |
* |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
21 |
* questions. |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
22 |
*/ |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
23 |
|
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
24 |
/** |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
25 |
* This file contains utility functions used by other tests. |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
26 |
* @subtest |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
27 |
*/ |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
28 |
|
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
29 |
var Files = Java.type('java.nio.file.Files'), |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
30 |
Paths = Java.type('java.nio.file.Paths'), |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
31 |
System = Java.type('java.lang.System') |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
32 |
|
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
33 |
var File = java.io.File |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
34 |
var windows = System.getProperty("os.name").startsWith("Windows") |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
35 |
var winCyg = false |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
36 |
|
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
37 |
var outPath = { |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
38 |
windows:0, //C:\dir |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
39 |
mixed:1 //C:/dir |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
40 |
} |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
41 |
|
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
42 |
if (windows) { |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
43 |
//Is there any better way to diffrentiate between cygwin/command prompt on windows |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
44 |
var term = System.getenv("TERM") |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
45 |
winCyg = term ? true:false |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
46 |
} |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
47 |
|
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
48 |
/** |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
49 |
* Returns which command is selected from PATH |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
50 |
* @param cmd name of the command searched from PATH |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
51 |
*/ |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
52 |
function which(cmd) { |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
53 |
var path = System.getenv("PATH") |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
54 |
var st = new java.util.StringTokenizer(path, File.pathSeparator) |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
55 |
while (st.hasMoreTokens()) { |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
56 |
var file = new File(st.nextToken(), cmd) |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
57 |
if (file.exists()) { |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
58 |
return (file.getAbsolutePath()) |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
59 |
} |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
60 |
} |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
61 |
} |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
62 |
|
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
63 |
/** |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
64 |
* Unix cygpath implementation |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
65 |
* Supports only two outputs,windows(C:\dir\) and mixed(C:/dir/) |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
66 |
*/ |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
67 |
function cygpath(path,mode) { |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
68 |
|
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
69 |
var newpath = path |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
70 |
if(path.startsWith("/cygdrive/")){ |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
71 |
var str = path.substring(10) |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
72 |
var index = str.indexOf('/',0) |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
73 |
var drv = str.substring(0,index) |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
74 |
var rstr = drv.toUpperCase() + ":" |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
75 |
newpath = str.replaceFirst(drv,rstr) |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
76 |
} |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
77 |
if (mode == outPath.windows) |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
78 |
return Paths.get(newpath).toString() |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
79 |
else { |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
80 |
newpath = newpath.replaceAll('\\\\','/') |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
81 |
return newpath |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
82 |
} |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
83 |
|
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
84 |
} |
2bc58b5e99d3
8138906: [TEST_BUG] Test test/script/trusted/JDK-8087292.js intermittently fails.
sdama
parents:
diff
changeset
|
85 |