Skip to content

Commit

Permalink
8147018: CompilerControl: Improve handling of timeouts and failures f…
Browse files Browse the repository at this point in the history
…or tests

Dump expected method states, improve compile commands dumping in CompilerControl tests

Reviewed-by: iignatyev, rbackman
  • Loading branch information
Evgeny Nikitin committed Apr 23, 2020
1 parent fc842d2 commit 9122028
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 16 deletions.
Expand Up @@ -63,7 +63,6 @@ public void test() {
MethodDescriptor md = getValidMethodDescriptor(exec); MethodDescriptor md = getValidMethodDescriptor(exec);
CompileCommand compileCommand = new JcmdCommand(Command.COMPILEONLY, CompileCommand compileCommand = new JcmdCommand(Command.COMPILEONLY,
md, null, Scenario.Type.JCMD, Scenario.JcmdType.ADD); md, null, Scenario.Type.JCMD, Scenario.JcmdType.ADD);
compileCommand.print();
builder.add(compileCommand); builder.add(compileCommand);
} }
// Remove half of them // Remove half of them
Expand Down
Expand Up @@ -76,7 +76,6 @@ public void test() {
CompileCommand compileCommand = new CompileCommand(command, CompileCommand compileCommand = new CompileCommand(command,
methodDescriptor, cmdGen.generateCompiler(), methodDescriptor, cmdGen.generateCompiler(),
Scenario.Type.DIRECTIVE); Scenario.Type.DIRECTIVE);
compileCommand.print();
builder.add(compileCommand); builder.add(compileCommand);
} }
// clear the stack // clear the stack
Expand Down
Expand Up @@ -66,7 +66,6 @@ public void test() {
cmdGen.generateCommand(), methodDescriptor, cmdGen.generateCommand(), methodDescriptor,
cmdGen.generateCompiler(), Scenario.Type.JCMD, cmdGen.generateCompiler(), Scenario.Type.JCMD,
Scenario.JcmdType.ADD); Scenario.JcmdType.ADD);
compileCommand.print();
builder.add(compileCommand); builder.add(compileCommand);
} }
// clear the stack // clear the stack
Expand Down
Expand Up @@ -73,7 +73,6 @@ public void test() {
CompileCommand compileCommand = new CompileCommand(command, CompileCommand compileCommand = new CompileCommand(command,
methodDescriptor, cmdGen.generateCompiler(), methodDescriptor, cmdGen.generateCompiler(),
Scenario.Type.DIRECTIVE); Scenario.Type.DIRECTIVE);
compileCommand.print();
builder.add(compileCommand); builder.add(compileCommand);
} }
// print all directives // print all directives
Expand Down
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -76,7 +76,6 @@ public void test() {
builder.addFlag("-XX:+UnlockDiagnosticVMOptions"); builder.addFlag("-XX:+UnlockDiagnosticVMOptions");
builder.addFlag("-XX:CompilerDirectivesLimit=101"); builder.addFlag("-XX:CompilerDirectivesLimit=101");
for (CompileCommand cc : testCases) { for (CompileCommand cc : testCases) {
cc.print();
builder.add(cc); builder.add(cc);
} }
Scenario scenario = builder.build(); Scenario scenario = builder.build();
Expand Down
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -49,7 +49,6 @@ public void test() {
CommandGenerator cmdGen = new CommandGenerator(); CommandGenerator cmdGen = new CommandGenerator();
CompileCommand compileCommand = cmdGen.generateCompileCommand(command, CompileCommand compileCommand = cmdGen.generateCompileCommand(command,
md, type); md, type);
compileCommand.print();
builder.add(compileCommand); builder.add(compileCommand);
Scenario scenario = builder.build(); Scenario scenario = builder.build();
scenario.execute(); scenario.execute();
Expand Down
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -58,6 +58,13 @@ public class CompileAction {
*/ */
public static void checkCompiled(Executable executable, public static void checkCompiled(Executable executable,
State state) { State state) {
{ // Dumping the state being checked
System.out.println("Checking expected compilation state: {");
System.out.println(" method: " + executable);
state.toString().lines()
.map(line -> " " + line).forEach(System.out::println);
System.out.println("}");
}
int first = COMP_LEVELS[0]; int first = COMP_LEVELS[0];
if (first < 4) { if (first < 4) {
checkCompilation(executable, first, state.isC1Compilable()); checkCompilation(executable, first, state.isC1Compilable());
Expand Down
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -57,10 +57,25 @@ public boolean isValid() {
} }


/** /**
* Prints compile command to the system output * Formats the command according to the following pattern:
* {@code <command_name> Type: <type> Compiler: <compiler> MethodDescriptor: <method_descriptor> IsValid: <true/false>}
* Sample output:
* COMPILEONLY Type: OPTION Compiler: C1 MethodDescriptor: *Klass.method* IsValid: true
*/ */
public void print() { protected String formatFields() {
System.out.printf("%s (type: %s): %s (valid: %b)%n", command.name(), return command.name() +
type.name(), methodDescriptor.getString(), isValid()); " Type: " + type +
" Compiler: " + compiler +
" MethodDescriptor: " + (methodDescriptor == null ? "null" : methodDescriptor.getString()) +
" IsValid: " + isValid();
}

/**
* Returns formatted string representation in the form
* {@code "(CompileCommand Field1: <field1> Field2: <field2> ...)}
* The fields are formatted by {@link #formatFields()}.
*/
public String toString() {
return "(CompileCommand " + formatFields() + ")";
} }
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -36,4 +36,13 @@ public JcmdCommand(Command command,
super(command, methodDescriptor, compiler, type); super(command, methodDescriptor, compiler, type);
this.jcmdType = jcmdType; this.jcmdType = jcmdType;
} }

/**
* Enchances parent's class method with the the JCMDtype printing:
* {@code ... JCMDType: <jcmd_type>}
*/
protected String formatFields() {
return super.formatFields() + " JCMDType: " + jcmdType;
}

} }
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -214,6 +214,7 @@ public void addFlag(String flag) {
} }


public void add(CompileCommand compileCommand) { public void add(CompileCommand compileCommand) {
System.out.println(compileCommand);
String[] vmOptions = compileCommand.command.vmOpts; String[] vmOptions = compileCommand.command.vmOpts;
Collections.addAll(vmopts, vmOptions); Collections.addAll(vmopts, vmOptions);
if (compileCommand.command == Command.LOG) { if (compileCommand.command == Command.LOG) {
Expand Down

0 comments on commit 9122028

Please sign in to comment.