author | jlahoda |
Wed, 27 Nov 2019 09:00:01 +0100 | |
changeset 59285 | 7799a51dbe30 |
parent 50154 | d2d6bc39ea88 |
permissions | -rw-r--r-- |
50154
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
1 |
/* |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
2 |
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved. |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
4 |
* |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
8 |
* |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
13 |
* accompanied this code). |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
14 |
* |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
18 |
* |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
21 |
* questions. |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
22 |
*/ |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
23 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
24 |
package nsk.sysdict.share; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
25 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
26 |
import nsk.share.Denotation; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
27 |
import nsk.share.Failure; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
28 |
import nsk.share.TestFailure; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
29 |
import nsk.share.sysdict.ClassLoadersBTree; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
30 |
import nsk.share.test.Tests; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
31 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
32 |
/** |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
33 |
* This class is used by btree tests. |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
34 |
*/ |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
35 |
public class BTreeTest extends SysDictTest { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
36 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
37 |
public BTreeTest(String[] args) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
38 |
parseArgs(args); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
39 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
40 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
41 |
public static void main(String args[]) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
42 |
Tests.runTest(new BTreeTest(args), args); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
43 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
44 |
private int height; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
45 |
protected int level; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
46 |
String[] nodeNames; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
47 |
String[] classNames; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
48 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
49 |
@Override |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
50 |
protected void parseArgs(String args[]) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
51 |
super.parseArgs(args); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
52 |
for (int i = 0; i < args.length; i++) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
53 |
if (args[i].equals("-level")) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
54 |
level = Integer.parseInt(args[i + 1]); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
55 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
56 |
if (args[i].equals("-height")) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
57 |
height = Integer.parseInt(args[i + 1]); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
58 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
59 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
60 |
try { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
61 |
// Load FatsInfo with URLClassLoader btree.jar & fats.jar should not |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
62 |
// present in classpath |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
63 |
Class info; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
64 |
if (useFats) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
65 |
info = createJarLoader().loadClass(PACKAGE_PREFIX + "FatsInfo"); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
66 |
} else { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
67 |
info = createJarLoader().loadClass(PACKAGE_PREFIX + "BTreeInfo"); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
68 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
69 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
70 |
if (height == 0) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
71 |
height = info.getField("HEIGHT").getInt(null) - 1; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
72 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
73 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
74 |
if (level == 0) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
75 |
level = height - 1; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
76 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
77 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
78 |
if (level >= height) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
79 |
throw new Failure("Icorrect level : " + level + " .Should be less then " + height); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
80 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
81 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
82 |
// generate names for all nodes at the given level: |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
83 |
Denotation denotation = null; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
84 |
if (!useFats) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
85 |
denotation = (Denotation) info.getField("nodesDenotation").get(null); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
86 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
87 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
88 |
// Set all classnames |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
89 |
String prefix = PACKAGE_PREFIX + info.getField("rootName").get(null); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
90 |
nodeNames = new String[1 << level]; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
91 |
classNames = new String[1 << level]; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
92 |
for (int i = 0; i < nodeNames.length; i++) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
93 |
if (useFats) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
94 |
classNames[i] = prefix + ((String[]) info.getField("nodeNames").get(null))[height - 1]; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
95 |
} else { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
96 |
nodeNames[i] = denotation.nameFor(level, i); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
97 |
classNames[i] = prefix + nodeNames[i]; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
98 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
99 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
100 |
System.out.println("The level = " + level + " the height = " + height); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
101 |
} catch (Exception e) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
102 |
throw new TestFailure("Can't initialize test correctly", e); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
103 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
104 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
105 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
106 |
@Override |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
107 |
protected final String[] getClassNames() { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
108 |
return classNames; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
109 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
110 |
|
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
111 |
@Override |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
112 |
protected final ClassLoader[] createLoaders() { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
113 |
ClassLoader jarLoader = createJarLoader(); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
114 |
ClassLoader loaders[] = new ClassLoader[nodeNames.length]; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
115 |
ClassLoadersBTree loadersTree = new ClassLoadersBTree(jarLoader, height); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
116 |
for (int i = 0; i < loaders.length; i++) { |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
117 |
loaders[i] = loadersTree.getLoader(nodeNames[i]); |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
118 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
119 |
return loaders; |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
120 |
} |
d2d6bc39ea88
8199252: [TESTBUG] Open source VM testbase system dictionary tests
mseledtsov
parents:
diff
changeset
|
121 |
} |