diff options
author | Simon Marchi | 2016-12-03 16:24:16 +0000 |
---|---|---|
committer | Simon Marchi | 2016-12-03 22:59:23 +0000 |
commit | e8cc363899785680daf8066af96b13fb0be1def0 (patch) | |
tree | 16601245a645de4e1e3b02a4f5261fbb8c1ab324 | |
parent | e2c50198965346e2140e1ce3ef7445f0b79e1a32 (diff) | |
download | org.eclipse.cdt-e8cc363899785680daf8066af96b13fb0be1def0.tar.gz org.eclipse.cdt-e8cc363899785680daf8066af96b13fb0be1def0.tar.xz org.eclipse.cdt-e8cc363899785680daf8066af96b13fb0be1def0.zip |
MIBreakpointsTest: Factor out breakpoint validation
Almost the same code is used in multiple tests to validate breakpoint
attributes. We can factor that out in a few support functions.
Change-Id: I819da62cc9e6d7434438574b695131b4cea19c77
Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
-rw-r--r-- | dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIBreakpointsTest.java | 312 |
1 files changed, 164 insertions, 148 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIBreakpointsTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIBreakpointsTest.java index 0e78e88a70e..3752de2893e 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIBreakpointsTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIBreakpointsTest.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.tests.dsf.gdb.tests; import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -642,6 +643,119 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase { } } + /** + * Validate attributes of a breakpoint. + * + * @param breakpoint The breakpoint object. + * @param filename The filename in which the breakpoint is placed. + * @param lineNumber The line number at which the breakpoint is placed. + * @param condition The condition associated to the breakpoint (pass an + * empty string to denote "no condition"). + * @param ignoreCount The ignore hit count of this breakpoint. + * @param enabled Whether this breakpoint is enabled. + * @param pending Whether this breakpoint is pending. + */ + private void validateBreakpoint(MIBreakpointDMData breakpoint, + String filename, int lineNumber, String condition, int ignoreCount, + boolean enabled, boolean pending) { + assertThat("BreakpointService problem: breakpoint mismatch (wrong file name)", + breakpoint.getFileName(), equalTo(filename)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong line number)", + breakpoint.getLineNumber(), equalTo(lineNumber)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong condition)", + breakpoint.getCondition(), equalTo(condition)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong ignore count)", + breakpoint.getIgnoreCount(), equalTo(ignoreCount)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong enabled)", + breakpoint.isEnabled(), equalTo(enabled)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong pending)", + breakpoint.isPending(), equalTo(pending)); + } + + /** + * Validate attributes of a breakpoint. + * + * @param breakpoint The breakpoint object. + * @param filename The filename in which the breakpoint is placed. + * @param functionName The name of the function in which the breakpoint is placed. + * @param condition The condition associated to the breakpoint (pass an + * empty string to denote "no condition"). + * @param ignoreCount The ignore hit count of this breakpoint. + * @param enabled Whether this breakpoint is enabled. + * @param pending Whether this breakpoint is pending. + */ + private void validateBreakpoint(MIBreakpointDMData breakpoint, + String filename, String functionName, String condition, + int ignoreCount, boolean enabled, boolean pending) { + assertThat("BreakpointService problem: breakpoint mismatch (wrong file name)", + breakpoint.getFileName(), equalTo(filename)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong function name)", + breakpoint.getFunctionName(), equalTo(functionName)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong condition)", + breakpoint.getCondition(), equalTo(condition)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong ignore count)", + breakpoint.getIgnoreCount(), equalTo(ignoreCount)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong enabled)", + breakpoint.isEnabled(), equalTo(enabled)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong pending)", + breakpoint.isPending(), equalTo(pending)); + } + + /** + * Validate attributes of a breakpoint. + * + * @param breakpoint The breakpoint object. + * @param address The address at which the breakpoint is placed. + * @param condition The condition associated to the breakpoint (pass an + * empty string to denote "no condition"). + * @param ignoreCount The ignore hit count of this breakpoint. + * @param enabled Whether this breakpoint is enabled. + * @param pending Whether this breakpoint is pending. + */ + private void validateBreakpoint(MIBreakpointDMData breakpoint, + BigInteger address, String condition, int ignoreCount, + boolean enabled, boolean pending) { + assertThat("BreakpointService problem: breakpoint mismatch (wrong address)", + breakpoint.getAddresses()[0].getValue(), equalTo(address)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong condition)", + breakpoint.getCondition(), equalTo(condition)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong ignore count)", + breakpoint.getIgnoreCount(), equalTo(ignoreCount)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong enabled)", + breakpoint.isEnabled(), equalTo(enabled)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong pending)", + breakpoint.isPending(), equalTo(pending)); + } + + /** + * Validate attributes of a watchpoint. + * + * @param watchpoint The watchpoint object. + * @param expression The expression being watched. + * @param read Whether this watchpoint is a read watchpoint. + * @param write Whether this watchpoint is a write watchpoint. + * @param access Whether this watchpoint is an access watchpoint. + * @param enabled Whether this watchpoint is enabled. + * @param pending Whether this watchpoint is pending. + */ + private void validateWatchpoint(MIBreakpointDMData watchpoint, + String expression, boolean read, boolean write, boolean access, + boolean enabled, boolean pending) { + assertThat("BreakpointService problem: breakpoint mismatch (wrong expression)", + watchpoint.getExpression(), equalTo(expression)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong read state)", + watchpoint.isReadWatchpoint(), equalTo(read)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong write state)", + watchpoint.isWriteWatchpoint(), equalTo(write)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong access state)", + watchpoint.isAccessWatchpoint(), equalTo(access)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong enabled)", + watchpoint.isEnabled(), equalTo(enabled)); + assertThat("BreakpointService problem: breakpoint mismatch (wrong pending)", + watchpoint.isPending(), equalTo(pending)); + } + + // ======================================================================== // Test Cases // ------------------------------------------------------------------------ @@ -787,18 +901,11 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase { assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); + // Ensure that the breakpoint was correctly installed MIBreakpointDMData breakpoint1 = (MIBreakpointDMData) getBreakpoint(ref); - assertEquals("BreakpointService problem: breakpoint mismatch (wrong address)", - ADDRESS, breakpoint1.getAddresses()[0].getValue()); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong condition)", - breakpoint1.getCondition().equals(NO_CONDITION)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong ignore count)", - breakpoint1.getIgnoreCount() == 0); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong state)", - breakpoint1.isEnabled()); - assertTrue("BreakpointService problem: breakpoint mismatch (pending)", - !breakpoint1.isPending()); + validateBreakpoint(breakpoint1, ADDRESS, NO_CONDITION, 0, true, false); + // Ensure the BreakpointService holds only the right breakpoints IBreakpointDMContext[] breakpoints = getBreakpoints(fBreakpointsDmc); assertTrue("BreakpointService problem: expected " + 1 + " breakpoint(s), received " @@ -830,20 +937,11 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase { assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); + // Ensure that the breakpoint was correctly installed MIBreakpointDMData breakpoint1 = (MIBreakpointDMData) getBreakpoint(ref); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong file name)", - breakpoint1.getFileName().equals(SOURCE_NAME)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong line number)", - breakpoint1.getLineNumber() == LINE_NUMBER_1); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong condition)", - breakpoint1.getCondition().equals(NO_CONDITION)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong ignore count)", - breakpoint1.getIgnoreCount() == 0); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong state)", - breakpoint1.isEnabled()); - assertTrue("BreakpointService problem: breakpoint mismatch (pending)", - !breakpoint1.isPending()); + validateBreakpoint(breakpoint1, SOURCE_NAME, LINE_NUMBER_1, NO_CONDITION, 0, true, false); + // Ensure the BreakpointService holds only the right breakpoints IBreakpointDMContext[] breakpoints = getBreakpoints(fBreakpointsDmc); assertTrue("BreakpointService problem: expected " + 1 + " breakpoint(s), received " @@ -876,20 +974,11 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase { assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); + // Ensure that the breakpoint was correctly installed MIBreakpointDMData breakpoint1 = (MIBreakpointDMData) getBreakpoint(ref); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong file name)", - breakpoint1.getFileName().equals(SOURCE_NAME)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong line number)", - breakpoint1.getLineNumber() == LINE_NUMBER_1); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong condition)", - breakpoint1.getCondition().equals(NO_CONDITION)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong ignore count)", - breakpoint1.getIgnoreCount() == 0); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong state)", - !breakpoint1.isEnabled()); - assertTrue("BreakpointService problem: breakpoint mismatch (pending)", - !breakpoint1.isPending()); + validateBreakpoint(breakpoint1, SOURCE_NAME, LINE_NUMBER_1, NO_CONDITION, 0, false, false); + // Ensure the BreakpointService holds only the right breakpoints IBreakpointDMContext[] breakpoints = getBreakpoints(fBreakpointsDmc); assertTrue("BreakpointService problem: expected " + 1 + " breakpoint(s), received " @@ -921,18 +1010,11 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase { assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); + // Ensure that the breakpoint was correctly installed MIBreakpointDMData breakpoint1 = (MIBreakpointDMData) getBreakpoint(ref); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong file name)", - breakpoint1.getFileName().equals(SOURCE_NAME)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong function)", - breakpoint1.getFunctionName().equals(SIGNED_FUNCTION)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong condition)", - breakpoint1.getCondition().equals(NO_CONDITION)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong ignore count)", - breakpoint1.getIgnoreCount() == 0); - assertTrue("BreakpointService problem: breakpoint mismatch (pending)", - !breakpoint1.isPending()); + validateBreakpoint(breakpoint1, SOURCE_NAME, SIGNED_FUNCTION, NO_CONDITION, 0, true, false); + // Ensure the BreakpointService holds only the right breakpoints IBreakpointDMContext[] breakpoints = getBreakpoints(fBreakpointsDmc); assertTrue("BreakpointService problem: expected " + 1 + " breakpoint(s), received " @@ -965,18 +1047,11 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase { assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); + // Ensure that the breakpoint was correctly installed MIBreakpointDMData breakpoint1 = (MIBreakpointDMData) getBreakpoint(ref); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong file name)", - breakpoint1.getFileName().equals(SOURCE_NAME)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong line number)", - breakpoint1.getLineNumber() == LINE_NUMBER_1); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong condition)", - breakpoint1.getCondition().equals(CONDITION_1)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong ignore count)", - breakpoint1.getIgnoreCount() == 0); - assertTrue("BreakpointService problem: breakpoint mismatch (pending)", - !breakpoint1.isPending()); + validateBreakpoint(breakpoint1, SOURCE_NAME, LINE_NUMBER_1, CONDITION_1, 0, true, false); + // Ensure the BreakpointService holds only the right breakpoints IBreakpointDMContext[] breakpoints = getBreakpoints(fBreakpointsDmc); assertTrue("BreakpointService problem: expected " + 1 + " breakpoint(s), received " @@ -1009,18 +1084,11 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase { assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); + // Ensure that the breakpoint was correctly installed MIBreakpointDMData breakpoint1 = (MIBreakpointDMData) getBreakpoint(ref); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong file name)", - breakpoint1.getFileName().equals(SOURCE_NAME)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong line number)", - breakpoint1.getLineNumber() == LINE_NUMBER_1); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong condition)", - breakpoint1.getCondition().equals(NO_CONDITION)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong ignore count)", - breakpoint1.getIgnoreCount() == IGNORE_COUNT_1); - assertTrue("BreakpointService problem: breakpoint mismatch (pending)", - !breakpoint1.isPending()); + validateBreakpoint(breakpoint1, SOURCE_NAME, LINE_NUMBER_1, NO_CONDITION, IGNORE_COUNT_1, true, false); + // Ensure the BreakpointService holds only the right breakpoints IBreakpointDMContext[] breakpoints = getBreakpoints(fBreakpointsDmc); assertTrue("BreakpointService problem: expected " + 1 + " breakpoint(s), received " @@ -1052,18 +1120,11 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase { assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); + // Ensure that the breakpoint was correctly installed MIBreakpointDMData breakpoint1 = (MIBreakpointDMData) getBreakpoint(ref); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong file name)", - breakpoint1.getFileName().equals(SOURCE_NAME)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong line number)", - breakpoint1.getLineNumber() == LINE_NUMBER_1); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong condition)", - breakpoint1.getCondition().equals(NO_CONDITION)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong ignore count)", - breakpoint1.getIgnoreCount() == 0); - assertTrue("BreakpointService problem: breakpoint mismatch (pending)", - !breakpoint1.isPending()); + validateBreakpoint(breakpoint1, SOURCE_NAME, LINE_NUMBER_1, NO_CONDITION, 0, true, false); + // Create a function breakpoint breakpoint = new HashMap<String, Object>(); breakpoint.put(BREAKPOINT_TYPE_TAG, BREAKPOINT_TAG); @@ -1079,18 +1140,11 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase { assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); + // Ensure that the breakpoint was correctly installed MIBreakpointDMData breakpoint2 = (MIBreakpointDMData) getBreakpoint(ref); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong file name)", - breakpoint2.getFileName().equals(SOURCE_NAME)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong function)", - breakpoint2.getFunctionName().equals(SIGNED_FUNCTION)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong condition)", - breakpoint2.getCondition().equals(NO_CONDITION)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong ignore count)", - breakpoint2.getIgnoreCount() == 0); - assertTrue("BreakpointService problem: breakpoint mismatch (pending)", - !breakpoint2.isPending()); + validateBreakpoint(breakpoint2, SOURCE_NAME, SIGNED_FUNCTION, NO_CONDITION, 0, true, false); + // Ensure the BreakpointService holds only the right breakpoints IBreakpointDMContext[] breakpoints = getBreakpoints(fBreakpointsDmc); assertTrue("BreakpointService problem: expected " + 2 + " breakpoint(s), received " @@ -1132,18 +1186,11 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase { assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); + // Ensure that the breakpoint was correctly installed MIBreakpointDMData breakpoint1 = (MIBreakpointDMData) getBreakpoint(ref); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong file name)", - breakpoint1.getFileName().equals(SOURCE_NAME)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong line number)", - breakpoint1.getLineNumber() == LINE_NUMBER_1); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong condition)", - breakpoint1.getCondition().equals(NO_CONDITION)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong ignore count)", - breakpoint1.getIgnoreCount() == 0); - assertTrue("BreakpointService problem: breakpoint mismatch (pending)", - !breakpoint1.isPending()); + validateBreakpoint(breakpoint1, SOURCE_NAME, LINE_NUMBER_1, NO_CONDITION, 0, true, false); + // Create a second line breakpoint, same attributes... ref = insertBreakpoint(fBreakpointsDmc, breakpoint); @@ -1154,18 +1201,11 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase { assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); + // Ensure that the breakpoint was correctly installed MIBreakpointDMData breakpoint2 = (MIBreakpointDMData) getBreakpoint(ref); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong file name)", - breakpoint2.getFileName().equals(SOURCE_NAME)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong line number)", - breakpoint2.getLineNumber() == LINE_NUMBER_1); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong condition)", - breakpoint2.getCondition().equals(NO_CONDITION)); - assertTrue("BreakpointService problem: breakpoint mismatch (wrong ignore count)", - breakpoint2.getIgnoreCount() == 0); - assertTrue("BreakpointService problem: breakpoint mismatch (pending)", - !breakpoint2.isPending()); + validateBreakpoint(breakpoint2, SOURCE_NAME, LINE_NUMBER_1, NO_CONDITION, 0, true, false); + // Ensure the BreakpointService holds only the right breakpoints IBreakpointDMContext[] breakpoints = getBreakpoints(fBreakpointsDmc); assertTrue("BreakpointService problem: expected " + 2 + " breakpoint(s), received " @@ -1214,16 +1254,18 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase { // Wait for breakpoint to hit and for the expected number of breakpoint events to have occurred MIStoppedEvent event = SyncUtil.waitForStop(3000); waitForBreakpointEvent(2); + // Ensure the correct BreakpointEvent was received MIBreakpointDMData breakpoint1 = (MIBreakpointDMData) getBreakpoint(ref); + validateBreakpoint(breakpoint1, SOURCE_NAME, LINE_NUMBER_5, NO_CONDITION, 0, true, false); + assertTrue("BreakpointEvent problem: expected " + 2 + " BREAKPOINT event(s), received " + fBreakpointEventCount, fBreakpointEventCount == 2); assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_HIT event(s), received " + getBreakpointEventCount(BP_HIT), getBreakpointEventCount(BP_HIT) == 1); assertTrue("BreakpointService problem: breakpoint mismatch", fBreakpointRef.equals(breakpoint1.getNumber())); - assertTrue("BreakpointService problem: breakpoint mismatch (pending)", - !breakpoint1.isPending()); + clearEventCounters(); assertTrue("Did not stop because of breakpoint, but stopped because of: " + event.getClass().getCanonicalName(), event instanceof MIBreakpointHitEvent); @@ -1268,16 +1310,18 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase { // Wait for breakpoint to hit and for the expected number of breakpoint events to have occurred MIStoppedEvent event = SyncUtil.waitForStop(3000); waitForBreakpointEvent(2); + // Ensure the correct BreakpointEvent was received MIBreakpointDMData breakpoint1 = (MIBreakpointDMData) getBreakpoint(ref); + validateBreakpoint(breakpoint1, SOURCE_NAME, LINE_NUMBER_5, NO_CONDITION, 0, true, false); + assertTrue("BreakpointEvent problem: expected " + 2 + " BREAKPOINT event(s), received " + fBreakpointEventCount, fBreakpointEventCount == 2); assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_HIT event(s), received " + getBreakpointEventCount(BP_HIT), getBreakpointEventCount(BP_HIT) == 1); assertTrue("BreakpointService problem: breakpoint mismatch", fBreakpointRef.equals(breakpoint1.getNumber())); - assertTrue("BreakpointService problem: breakpoint mismatch (pending)", - !breakpoint1.isPending()); + clearEventCounters(); assertTrue("Did not stop because of breakpoint, but stopped because of: " + event.getClass().getCanonicalName(), event instanceof MIBreakpointHitEvent); @@ -1310,18 +1354,11 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase { assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); + // Ensure that the watchpoint was correctly installed MIBreakpointDMData watchpoint1 = (MIBreakpointDMData) getBreakpoint(ref); - assertTrue("BreakpointService problem: watchpoint mismatch (wrong expression)", - watchpoint1.getExpression().equals(EXPRESSION_1)); - assertTrue("BreakpointService problem: watchpoint mismatch (wrong read state)", - !watchpoint1.isReadWatchpoint()); - assertTrue("BreakpointService problem: watchpoint mismatch (wrong write state)", - watchpoint1.isWriteWatchpoint()); - assertTrue("BreakpointService problem: watchpoint mismatch (wrong access state)", - !watchpoint1.isAccessWatchpoint()); - assertTrue("BreakpointService problem: breakpoint mismatch (pending)", - !watchpoint1.isPending()); + validateWatchpoint(watchpoint1, EXPRESSION_1, false, true, false, true, false); + // Ensure the BreakpointService holds only the right watchpoints IBreakpointDMContext[] watchpoints = getBreakpoints(fBreakpointsDmc); assertTrue("BreakpointService problem: expected " + 1 + " watchpoints(s), received " @@ -1353,18 +1390,11 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase { assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); + // Ensure that the watchpoint was correctly installed MIBreakpointDMData watchpoint1 = (MIBreakpointDMData) getBreakpoint(ref); - assertTrue("BreakpointService problem: watchpoint mismatch (wrong expression)", - watchpoint1.getExpression().equals(EXPRESSION_1)); - assertTrue("BreakpointService problem: watchpoint mismatch (wrong read state)", - watchpoint1.isReadWatchpoint()); - assertTrue("BreakpointService problem: watchpoint mismatch (wrong write state)", - !watchpoint1.isWriteWatchpoint()); - assertTrue("BreakpointService problem: watchpoint mismatch (wrong access state)", - !watchpoint1.isAccessWatchpoint()); - assertTrue("BreakpointService problem: breakpoint mismatch (pending)", - !watchpoint1.isPending()); + validateWatchpoint(watchpoint1, EXPRESSION_1, true, false, false, true, false); + // Ensure the BreakpointService holds only the right watchpoints IBreakpointDMContext[] watchpoints = getBreakpoints(fBreakpointsDmc); assertTrue("BreakpointService problem: expected " + 1 + " watchpoints(s), received " @@ -1397,18 +1427,11 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase { assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received " + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); + // Ensure that the watchpoint was correctly installed MIBreakpointDMData watchpoint1 = (MIBreakpointDMData) getBreakpoint(ref); - assertTrue("BreakpointService problem: watchpoint mismatch (wrong expression)", - watchpoint1.getExpression().equals(EXPRESSION_1)); - assertTrue("BreakpointService problem: watchpoint mismatch (wrong read state)", - !watchpoint1.isReadWatchpoint()); - assertTrue("BreakpointService problem: watchpoint mismatch (wrong write state)", - !watchpoint1.isWriteWatchpoint()); - assertTrue("BreakpointService problem: watchpoint mismatch (wrong access state)", - watchpoint1.isAccessWatchpoint()); - assertTrue("BreakpointService problem: breakpoint mismatch (pending)", - !watchpoint1.isPending()); + validateWatchpoint(watchpoint1, EXPRESSION_1, false, false, true, true, false); + // Ensure the BreakpointService holds only the right watchpoints IBreakpointDMContext[] watchpoints = getBreakpoints(fBreakpointsDmc); assertTrue("BreakpointService problem: expected " + 1 + " watchpoints(s), received " @@ -1455,18 +1478,11 @@ public class MIBreakpointsTest extends BaseParametrizedTestCase { assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_HIT event(s), received " + getBreakpointEventCount(BP_HIT), getBreakpointEventCount(BP_HIT) == 1); clearEventCounters(); + // Ensure that the watchpoint was correctly installed MIBreakpointDMData watchpoint1 = (MIBreakpointDMData) getBreakpoint(ref); - assertTrue("BreakpointService problem: watchpoint mismatch (wrong expression)", - watchpoint1.getExpression().equals(EXPRESSION_1)); - assertTrue("BreakpointService problem: watchpoint mismatch (wrong read state)", - !watchpoint1.isReadWatchpoint()); - assertTrue("BreakpointService problem: watchpoint mismatch (wrong write state)", - watchpoint1.isWriteWatchpoint()); - assertTrue("BreakpointService problem: watchpoint mismatch (wrong access state)", - !watchpoint1.isAccessWatchpoint()); - assertTrue("BreakpointService problem: breakpoint mismatch (pending)", - !watchpoint1.isPending()); + validateWatchpoint(watchpoint1, EXPRESSION_1, false, true, false, true, false); + // Ensure the BreakpointService holds only the right watchpoints IBreakpointDMContext[] watchpoints = getBreakpoints(fBreakpointsDmc); assertTrue("BreakpointService problem: expected " + 1 + " watchpoints(s), received " |