Skip to content
Permalink
Browse files
8276208: vmTestbase/nsk/jdb/repeat/repeat001/repeat001.java fails wit…
…h "AssertionError: Unexpected output"

Reviewed-by: cjplummer, iklam
  • Loading branch information
jakobcornell authored and plummercj committed Nov 3, 2021
1 parent 684edbb commit c7f070f5f17dad661cc3296f2e3cd7a1cd5fc742
Showing 2 changed files with 25 additions and 24 deletions.
@@ -85,10 +85,11 @@ protected static boolean isPrompt(String line) {
return line.trim().equals("main[1]");
}

protected static List<ListLine> parseListOutput(String[] lines) {
protected List<ListLine> parseListOutput(String[] lines) {
List<String> lineList = new ArrayList<>(Arrays.asList(lines));
if (!isPrompt(lineList.remove(lineList.size() - 1))) {
throw new AssertionError("Expected trailing prompt");
failure("Expected trailing prompt");
return null;
} else if (lineList.size() == 1 && lineList.get(0).equals("EOF")) {
return new ArrayList<>();
} else {
@@ -117,14 +118,14 @@ protected void runCases() {

protected void runCasesNoCleanup() {
if (jdb.receiveReplyFor(JdbCommand.repeat + "on").length != 1) {
throw new AssertionError("Missing or unexpected output");
failure("Missing or unexpected output");
}

List<ListLine> autoList = parseListOutput(jdb.receiveReplyFor(JdbCommand.list));
int lineNo = autoList.stream().filter(ListLine::active).findFirst().get().number();
List<ListLine> manualList = parseListOutput(jdb.receiveReplyFor(JdbCommand.list + (lineNo - 1)));
if (manualList.stream().filter(ListLine::active).findFirst().get().number() != lineNo) {
throw new AssertionError("Manual listing didn't mark the active source line");
failure("Manual listing didn't mark the active source line");
}

// Verify that we can correctly list by auto-advance all the way to EOF
@@ -137,36 +138,36 @@ protected void runCasesNoCleanup() {
List<ListLine> currList = parseListOutput(jdb.receiveReplyFor(command));
if (currList.equals(prevList)) {
// This guards against infinite looping
throw new AssertionError("Consecutive listings were identical");
failure("Consecutive listings were identical");
}
int prevEnd = prevList.get(prevList.size() - 1).number();
if (!currList.isEmpty() && currList.get(0).number() != prevEnd + 1) {
throw new AssertionError("Consecutive listings weren't for consecutive source chunks");
failure("Consecutive listings weren't for consecutive source chunks");
}
prevList = currList;
}
if (reps < 2) {
throw new AssertionError("Didn't get enough consecutive list reps");
failure("Didn't get enough consecutive list reps");
}

String[] lines = jdb.receiveReplyFor(JdbCommand.up);
if (!lines[0].equals("End of stack.") || !isPrompt(lines[1])) {
throw new AssertionError("Unexpected output from `up'");
failure("Unexpected output from `up'");
}
List<ListLine> resetList = parseListOutput(jdb.receiveReplyFor(JdbCommand.list));
if (!resetList.stream().anyMatch(ListLine::active)) {
throw new AssertionError("List target didn't reset to active line");
failure("List target didn't reset to active line");
}

List<ListLine> listing = parseListOutput(jdb.receiveReplyFor(JdbCommand.list + "1"));
if (!listing.stream().anyMatch(l -> l.number() == 1)) {
throw new AssertionError("Manual listing displayed the wrong lines");
failure("Manual listing displayed the wrong lines");
}

List<ListLine> targetedList = parseListOutput(jdb.receiveReplyFor(JdbCommand.list + "1"));
autoList = parseListOutput(jdb.receiveReplyFor(JdbCommand.list));
if (autoList.get(0).number() != targetedList.get(targetedList.size() - 1).number() + 1) {
throw new AssertionError("Auto-advance didn't work after targeted list");
failure("Auto-advance didn't work after targeted list");
}
}
}
@@ -94,55 +94,55 @@ protected void runCasesNoCleanup() {
// Verify that repeat is off initially
String[] reply = jdb.receiveReplyFor(JdbCommand.repeat);
if (reply.length != 2 || !isPrompt(reply[1])) {
throw new AssertionError("Unexpected output");
failure("Unexpected output");
}
if (!reply[0].equals("Repeat is off")) {
throw new AssertionError("Incorrect initial repeat setting");
failure("Incorrect initial repeat setting");
}

// Verify that list auto-advance is disabled
String[] firstList = jdb.receiveReplyFor(JdbCommand.list);
String[] secondList = jdb.receiveReplyFor(JdbCommand.list);
if (!Arrays.equals(firstList, secondList)) {
throw new AssertionError("Listing inconsistent with repeat off");
failure("Listing inconsistent with repeat off");
}

// Verify that command repetition doesn't happen when disabled
reply = jdb.receiveReplyFor("");
if (reply.length != 1 || !isPrompt(reply[0])) {
throw new AssertionError("Unexpected output");
failure("Unexpected output");
}

reply = jdb.receiveReplyFor(JdbCommand.repeat + "on");
if (reply.length != 1 || !isPrompt(reply[0])) {
throw new AssertionError("Unexpected output");
failure("Unexpected output");
}

// Verify that repeat is reported on
reply = jdb.receiveReplyFor(JdbCommand.repeat);
if (reply.length != 2 || !isPrompt(reply[1])) {
throw new AssertionError("Unexpected output");
failure("Unexpected output");
}
if (!reply[0].equals("Repeat is on")) {
throw new AssertionError("Incorrect repeat status reported");
failure("Incorrect repeat status reported");
}

// Verify that non-repeatable commands still don't repeat
if (jdb.receiveReplyFor(JdbCommand.print + "0").length != 2) {
throw new AssertionError("Unexpected output");
failure("Unexpected output");
}
if (jdb.receiveReplyFor("").length != 1) {
throw new AssertionError("Unexpected output");
failure("Unexpected output");
}

// Verify that repeated commands are repeatable
// (`up' just prints `End of stack.' since we're stopped in `main')
reply = jdb.receiveReplyFor("2 2 " + JdbCommand.up);
reply = jdb.receiveReplyFor("2 2 " + JdbCommand.up, true, 4);
if (reply.length != 5 || !isPrompt(reply[4])) {
throw new AssertionError("Unexpected output");
failure("Unexpected output");
}
if (!Arrays.equals(reply, jdb.receiveReplyFor(""))) {
throw new AssertionError("Repeated command didn't repeat correctly");
if (!Arrays.equals(reply, jdb.receiveReplyFor("", true, 4))) {
failure("Repeated command didn't repeat correctly");
}
}
}

1 comment on commit c7f070f

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on c7f070f Nov 3, 2021

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.