Skip to content

Commit 7f4a9f6

Browse files
committed
8266088: compiler/arguments/TestPrintOptoAssemblyLineNumbers test should user driver mode
Reviewed-by: kvn
1 parent f560b89 commit 7f4a9f6

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

test/hotspot/jtreg/compiler/arguments/TestPrintOptoAssemblyLineNumbers.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
3+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
34
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
45
*
56
* This code is free software; you can redistribute it and/or modify it
@@ -28,44 +29,46 @@
2829
*
2930
* @requires vm.compiler2.enabled & vm.debug == true
3031
*
31-
* @library /compiler/patches /test/lib
32-
* @run main/othervm compiler.arguments.TestPrintOptoAssemblyLineNumbers
33-
*/
32+
* @library /test/lib
33+
* @run driver compiler.arguments.TestPrintOptoAssemblyLineNumbers
34+
*/
3435

3536
package compiler.arguments;
3637

37-
import jdk.test.lib.Asserts;
3838
import jdk.test.lib.process.OutputAnalyzer;
3939
import jdk.test.lib.process.ProcessTools;
4040

41+
// THIS TEST IS LINE NUMBER SENSITIVE
42+
4143
public class TestPrintOptoAssemblyLineNumbers {
4244
public static void main(String[] args) throws Throwable {
4345
// create subprocess to run some code with -XX:+PrintOptoAssembly enabled
44-
String[] procArgs = new String[]{
46+
String[] procArgs = new String[] {
4547
"-XX:+UnlockDiagnosticVMOptions",
4648
"-XX:-TieredCompilation",
4749
"-XX:+PrintOptoAssembly",
48-
"compiler.arguments.TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly"
49-
};
50+
CheckC2OptoAssembly.class.getName()
51+
};
5052

5153
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs);
52-
String output = new OutputAnalyzer(pb.start()).getOutput();
54+
OutputAnalyzer oa = new OutputAnalyzer(pb.start());
55+
oa.shouldHaveExitValue(0);
5356

54-
if(output.contains("TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly::main @ bci:11")){
57+
if (oa.getOutput().contains("TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly::main @ bci:11")) {
5558
// if C2 optimizer invoked ensure output includes line numbers:
56-
Asserts.assertTrue(output.contains("TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly::main @ bci:11 (line 68)"));
59+
oa.stdoutShouldContain("TestPrintOptoAssemblyLineNumbers$CheckC2OptoAssembly::main @ bci:11 (line 71)");
5760
}
5861
}
5962

60-
public static class CheckC2OptoAssembly{ // contents of this class serves to just invoke C2
61-
public static boolean foo(String arg){
63+
public static class CheckC2OptoAssembly { // contents of this class serves to just invoke C2
64+
public static boolean foo(String arg) {
6265
return arg.contains("45");
6366
}
6467

65-
public static void main(String[] args){
68+
public static void main(String[] args) {
6669
int count = 0;
67-
for(int x = 0; x < 200_000; x++){
68-
if(foo("something" + x)){ // <- test expects this line of code to be on line 68
70+
for (int x = 0; x < 200_000; x++) {
71+
if (foo("something" + x)) { // <- test expects this line of code to be on line 71
6972
count += 1;
7073
}
7174
}

0 commit comments

Comments
 (0)