8276208: vmTestbase/nsk/jdb/repeat/repeat001/repeat001.java fails with "AssertionError: Unexpected output"

Reviewed-by: cjplummer, iklam
This commit is contained in:
Jakob Cornell 2021-11-03 18:18:16 +00:00 committed by Chris Plummer
parent 684edbb4c8
commit c7f070f5f1
2 changed files with 25 additions and 24 deletions

View File

@ -85,10 +85,11 @@ public class list003 extends JdbTest {
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 @@ public class list003 extends JdbTest {
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 @@ public class list003 extends JdbTest {
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");
}
}
}

View File

@ -94,55 +94,55 @@ public class repeat001 extends JdbTest {
// 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");
}
}
}