1 /*
2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
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
24
25 package org.graalvm.compiler.hotspot.lir.test;
26
27 import static org.graalvm.compiler.test.SubprocessUtil.getVMCommandLine;
28 import static org.graalvm.compiler.test.SubprocessUtil.withoutDebuggerArguments;
29
30 import java.util.ArrayList;
31 import java.util.Iterator;
32 import java.util.List;
33
34 import org.graalvm.compiler.api.directives.GraalDirectives;
35 import org.graalvm.compiler.core.common.LIRKind;
36 import org.graalvm.compiler.hotspot.HotSpotBackend;
37 import org.graalvm.compiler.hotspot.debug.BenchmarkCounters;
38 import org.graalvm.compiler.lir.ConstantValue;
39 import org.graalvm.compiler.lir.gen.LIRGeneratorTool;
40 import org.graalvm.compiler.lir.jtt.LIRTest;
41 import org.graalvm.compiler.lir.jtt.LIRTestSpecification;
42 import org.graalvm.compiler.test.SubprocessUtil;
43 import org.junit.Assert;
44 import org.junit.Assume;
45 import org.junit.Before;
46 import org.junit.Test;
47
48 import jdk.vm.ci.amd64.AMD64;
49 import jdk.vm.ci.meta.JavaConstant;
50 import jdk.vm.ci.meta.JavaKind;
51 import jdk.vm.ci.meta.ResolvedJavaMethod;
52
104 vmArgs.add("-Dgraal." + BenchmarkCounters.Options.AbortOnBenchmarkCounterOverflow.getName() + "=true");
105 vmArgs.add("-D" + SUBPROCESS_PROPERTY + "=true");
106
107 // Disable increment range checks (e.g. HotSpotCounterOp.checkIncrements())
108 vmArgs.add("-dsa");
109 vmArgs.add("-da");
110
111 List<String> mainClassAndArgs = new ArrayList<>();
112 mainClassAndArgs.add("com.oracle.mxtool.junit.MxJUnitWrapper");
113 mainClassAndArgs.add(BenchmarkCounterOverflowTest.class.getName());
114
115 SubprocessUtil.Subprocess proc = SubprocessUtil.java(vmArgs, mainClassAndArgs);
116
117 if (VERBOSE) {
118 System.out.println(proc);
119 }
120
121 Assert.assertNotEquals("Expected non-zero exit status", 0, proc.exitCode);
122
123 Iterator<String> it = proc.output.iterator();
124 while (it.hasNext()) {
125 String line = it.next();
126 if (line.contains("Problematic frame:")) {
127 if (!it.hasNext()) {
128 // no more line
129 break;
130 }
131 line = it.next();
132 if (line.contains(BenchmarkCounterOverflowTest.class.getName() + ".test")) {
133 return;
134 }
135 Assert.fail("Unexpected stack trace: " + line);
136 }
137 }
138 Assert.fail(String.format("Could not find method in output:%n%s", proc));
139 }
140 }
|
1 /*
2 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
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
24
25 package org.graalvm.compiler.hotspot.lir.test;
26
27 import static org.graalvm.compiler.test.SubprocessUtil.getVMCommandLine;
28 import static org.graalvm.compiler.test.SubprocessUtil.withoutDebuggerArguments;
29
30 import java.io.File;
31 import java.util.ArrayList;
32 import java.util.Iterator;
33 import java.util.List;
34 import java.util.regex.Matcher;
35 import java.util.regex.Pattern;
36
37 import org.graalvm.compiler.api.directives.GraalDirectives;
38 import org.graalvm.compiler.core.common.LIRKind;
39 import org.graalvm.compiler.hotspot.HotSpotBackend;
40 import org.graalvm.compiler.hotspot.debug.BenchmarkCounters;
41 import org.graalvm.compiler.lir.ConstantValue;
42 import org.graalvm.compiler.lir.gen.LIRGeneratorTool;
43 import org.graalvm.compiler.lir.jtt.LIRTest;
44 import org.graalvm.compiler.lir.jtt.LIRTestSpecification;
45 import org.graalvm.compiler.test.SubprocessUtil;
46 import org.junit.Assert;
47 import org.junit.Assume;
48 import org.junit.Before;
49 import org.junit.Test;
50
51 import jdk.vm.ci.amd64.AMD64;
52 import jdk.vm.ci.meta.JavaConstant;
53 import jdk.vm.ci.meta.JavaKind;
54 import jdk.vm.ci.meta.ResolvedJavaMethod;
55
107 vmArgs.add("-Dgraal." + BenchmarkCounters.Options.AbortOnBenchmarkCounterOverflow.getName() + "=true");
108 vmArgs.add("-D" + SUBPROCESS_PROPERTY + "=true");
109
110 // Disable increment range checks (e.g. HotSpotCounterOp.checkIncrements())
111 vmArgs.add("-dsa");
112 vmArgs.add("-da");
113
114 List<String> mainClassAndArgs = new ArrayList<>();
115 mainClassAndArgs.add("com.oracle.mxtool.junit.MxJUnitWrapper");
116 mainClassAndArgs.add(BenchmarkCounterOverflowTest.class.getName());
117
118 SubprocessUtil.Subprocess proc = SubprocessUtil.java(vmArgs, mainClassAndArgs);
119
120 if (VERBOSE) {
121 System.out.println(proc);
122 }
123
124 Assert.assertNotEquals("Expected non-zero exit status", 0, proc.exitCode);
125
126 Iterator<String> it = proc.output.iterator();
127 boolean foundProblematicFrame = false;
128 while (it.hasNext()) {
129 String line = it.next();
130 if (line.contains("Problematic frame:")) {
131 if (!it.hasNext()) {
132 // no more line
133 break;
134 }
135 line = it.next();
136 if (line.contains(BenchmarkCounterOverflowTest.class.getName() + ".test")) {
137 foundProblematicFrame = true;
138 break;
139 }
140 Assert.fail("Unexpected stack trace: " + line);
141 }
142 }
143 // find and delete hserr file
144 while (it.hasNext()) {
145 String line = it.next();
146 if (line.contains("An error report file with more information is saved as:")) {
147 if (!it.hasNext()) {
148 // no more line
149 break;
150 }
151 line = it.next();
152 Pattern pattern = Pattern.compile("^# (.*hs_err_pid.*log)$");
153 Matcher matcher = pattern.matcher(line);
154 if (matcher.matches()) {
155 File hserrFile = new File(matcher.group(1));
156 if (hserrFile.exists()) {
157 if (VERBOSE) {
158 System.out.println("Deleting error report file:" + hserrFile.getAbsolutePath());
159 }
160 hserrFile.delete();
161 }
162 }
163 }
164 }
165 Assert.assertTrue(String.format("Could not find method in output:%n%s", proc), foundProblematicFrame);
166 }
167 }
|