author | coleenp |
Mon, 29 Jul 2019 10:34:20 -0400 | |
changeset 57567 | b000362a89a0 |
parent 51411 | test/hotspot/jtreg/runtime/SharedArchiveFile/serviceability/transformRelatedClasses/TransformTestCommon.java@4699147a4f91 |
permissions | -rw-r--r-- |
41182 | 1 |
/* |
57567
b000362a89a0
8202339: [TESTBUG] Consolidate the tests in runtime/SharedArchiveFile and runtime/appcds
coleenp
parents:
51411
diff
changeset
|
2 |
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
41182 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
46389 | 24 |
import jdk.test.lib.cds.CDSTestUtils; |
41182 | 25 |
import jdk.test.lib.process.OutputAnalyzer; |
26 |
||
27 |
// This class contains methods common to all transformation test cases |
|
28 |
public class TransformTestCommon { |
|
29 |
||
30 |
// get parameters to an agent depending on the test case |
|
31 |
// these parameters will instruct the agent which classes should be |
|
32 |
// transformed |
|
33 |
public static String getAgentParams(TestEntry entry, |
|
34 |
String parent, String child) { |
|
35 |
||
36 |
if (entry.transformParent && entry.transformChild) |
|
37 |
return parent + "," + child; |
|
38 |
if (entry.transformParent) |
|
39 |
return parent; |
|
40 |
if (entry.transformChild) |
|
41 |
return child; |
|
42 |
||
43 |
return ""; |
|
44 |
} |
|
45 |
||
46 |
||
47 |
private static void checkTransformationResults(TestEntry entry, |
|
48 |
OutputAnalyzer out) |
|
49 |
throws Exception { |
|
50 |
||
51 |
if (entry.transformParent) |
|
52 |
out.shouldContain(TransformUtil.ParentCheckPattern + |
|
53 |
TransformUtil.AfterPattern); |
|
54 |
||
55 |
if (entry.transformChild) |
|
56 |
out.shouldContain(TransformUtil.ChildCheckPattern + |
|
57 |
TransformUtil.AfterPattern); |
|
58 |
} |
|
59 |
||
60 |
||
61 |
private static void checkSharingByClass(TestEntry entry, OutputAnalyzer out, |
|
62 |
String parent, String child) |
|
63 |
throws Exception { |
|
64 |
||
48557 | 65 |
String parentSharedMatch = " " + parent + " source: shared objects file"; |
66 |
String childSharedMatch = " " + child + " source: shared objects file"; |
|
41182 | 67 |
|
68 |
if (entry.isParentExpectedShared) |
|
69 |
out.shouldContain(parentSharedMatch); |
|
70 |
else |
|
71 |
out.shouldNotContain(parentSharedMatch); |
|
72 |
||
73 |
if (entry.isChildExpectedShared) |
|
74 |
out.shouldContain(childSharedMatch); |
|
75 |
else |
|
76 |
out.shouldNotContain(childSharedMatch); |
|
77 |
} |
|
78 |
||
79 |
||
80 |
// Both parent and child classes should be passed to ClassFileTransformer.transform() |
|
81 |
// exactly once. |
|
82 |
private static void checkTransformationCounts(TestEntry entry, OutputAnalyzer out, |
|
83 |
String parent, String child) |
|
84 |
throws Exception { |
|
85 |
||
86 |
String patternBase = "TransformerAgent: SimpleTransformer called for: "; |
|
87 |
||
88 |
out.shouldContain(patternBase + child + "@1"); |
|
89 |
out.shouldContain(patternBase + parent + "@1"); |
|
90 |
||
91 |
out.shouldNotContain(patternBase + child + "@2"); |
|
92 |
out.shouldNotContain(patternBase + parent + "@2"); |
|
93 |
} |
|
94 |
||
95 |
||
96 |
public static void checkResults(TestEntry entry, OutputAnalyzer out, |
|
97 |
String parent, String child) |
|
98 |
throws Exception { |
|
99 |
||
100 |
// If we were not able to map an archive, |
|
101 |
// then do not perform other checks, since |
|
102 |
// there was no sharing at all |
|
51411
4699147a4f91
8209164: [TESTBUG] Apply jtreg skipped status to cds tests
mseledtsov
parents:
48557
diff
changeset
|
103 |
CDSTestUtils.checkMappingFailure(out); |
41182 | 104 |
|
105 |
String childVmName = child.replace('.', '/'); |
|
106 |
String parentVmName = parent.replace('.', '/'); |
|
107 |
||
108 |
CDSTestUtils.checkExec(out); |
|
109 |
checkTransformationCounts(entry, out, parentVmName, childVmName); |
|
110 |
checkTransformationResults(entry, out); |
|
111 |
checkSharingByClass(entry, out, parent, child); |
|
112 |
} |
|
113 |
} |