Skip to content

Commit

Permalink
8258799: [Testbug] RandomCommandsTest must check if tested directive …
Browse files Browse the repository at this point in the history
…is added via jcmd

Reviewed-by: kvn, iignatyev
  • Loading branch information
Nils Eliasson committed Feb 3, 2021
1 parent b0ee7a8 commit 472bf62
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class JcmdStateBuilder implements StateBuilder<JcmdCommand> {
private final Map<MethodDescriptor, List<CompileCommand>> matchBlocks
= new LinkedHashMap<>();
private final List<CompileCommand> inlines = new ArrayList<>();
private boolean isFileValid = true;
public boolean isFileValid = true;

public JcmdStateBuilder(String fileName) {
directiveBuilder = new DirectiveBuilder(fileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,21 @@
*/
public final class Scenario {
private final boolean isValid;
private final boolean isJcmdValid;
private final Map<Executable, State> states;
private final List<Consumer<OutputAnalyzer>> processors;
private final Executor executor;
private final Consumer<List<OutputAnalyzer>> jcmdProcessor;

private Scenario(boolean isValid,
boolean isJcmdValid,
List<String> vmopts,
Map<Executable, State> states,
List<CompileCommand> compileCommands,
List<JcmdCommand> jcmdCommands,
List<CompileCommand> directives) {
this.isValid = isValid;
this.isJcmdValid = isJcmdValid;
this.states = states;
processors = new ArrayList<>();
processors.add(new LogProcessor(states));
Expand Down Expand Up @@ -121,7 +124,18 @@ public void execute() {
} else {
// two cases for invalid inputs.
if (mainOutput.getExitValue() == 0) {
mainOutput.shouldContain("CompileCommand: An error occurred during parsing");
if (!isJcmdValid) {
boolean parse_error_found = false;
for(OutputAnalyzer out : outputList) {
if (out.getOutput().contains("Parsing of compiler directives failed")) {
parse_error_found = true;
break;
}
}
Asserts.assertTrue(parse_error_found, "'Parsing of compiler directives failed' missing from output");
} else {
mainOutput.shouldContain("CompileCommand: An error occurred during parsing");
}
} else {
Asserts.assertNE(mainOutput.getExitValue(), 0, "VM should exit with "
+ "error for incorrect directives");
Expand Down Expand Up @@ -253,6 +267,7 @@ public void add(CompileCommand compileCommand) {

public Scenario build() {
boolean isValid = true;
boolean isJcmdValid = true;

// Get states from each of the state builders
Map<Executable, State> commandFileStates
Expand Down Expand Up @@ -315,6 +330,7 @@ public Scenario build() {
options.addAll(builder.getOptions());
isValid &= builder.isValid();
}
isJcmdValid = jcmdStateBuilder.isFileValid;
options.addAll(jcmdStateBuilder.getOptions());

/*
Expand All @@ -328,7 +344,7 @@ public Scenario build() {
.forEach(entry -> entry.getValue().setLog(true));
}

return new Scenario(isValid, options, finalStates, ccList,
return new Scenario(isValid, isJcmdValid, options, finalStates, ccList,
jcmdCommands, directives);
}

Expand Down

1 comment on commit 472bf62

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.