GP-0: Fix timing issue in debugger copy actions test

This commit is contained in:
Dan 2022-03-31 15:49:27 -04:00
parent 65a7105cbf
commit c391b7cb65
2 changed files with 26 additions and 20 deletions

View file

@ -787,8 +787,7 @@ public class DebuggerCopyIntoProgramDialog extends DialogComponentProvider {
}
protected void executeEntry(RangeEntry entry, Program dest, TraceRecorder recorder,
TaskMonitor monitor)
throws Exception {
TaskMonitor monitor) throws Exception {
MemoryBlock block = executeEntryBlock(entry, dest, monitor);
Address dstMin = entry.getDstRange().getMinAddress();
if (block.isOverlay()) {

View file

@ -19,7 +19,6 @@ import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
@ -39,6 +38,7 @@ import ghidra.app.plugin.core.debug.gui.listing.DebuggerListingProvider;
import ghidra.app.plugin.core.debug.service.modules.DebuggerStaticMappingServicePlugin;
import ghidra.app.services.ActionSource;
import ghidra.app.services.DebuggerStaticMappingService;
import ghidra.async.AsyncTestUtils;
import ghidra.dbg.DebuggerModelListener;
import ghidra.dbg.target.TargetObject;
import ghidra.program.model.address.*;
@ -53,7 +53,8 @@ import ghidra.trace.model.memory.TraceMemoryFlag;
import ghidra.util.database.UndoableTransaction;
@Category(NightlyCategory.class)
public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerGUITest {
public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerGUITest
implements AsyncTestUtils {
DebuggerCopyActionsPlugin copyActionsPlugin;
DebuggerListingPlugin listingPlugin;
@ -87,7 +88,7 @@ public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerG
}
@Test
public void testActionCopyIntoCurrentProgramWithoutRelocationCreateBlocks() throws Exception {
public void testActionCopyIntoCurrentProgramWithoutRelocationCreateBlocks() throws Throwable {
assertDisabled(copyActionsPlugin.actionCopyIntoCurrentProgram);
createProgram();
@ -120,7 +121,7 @@ public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerG
assertEquals(".text", entry.getBlockName());
assertTrue(entry.isCreate());
dialog.okCallback();
dialog.lastTask.get(1000, TimeUnit.MILLISECONDS);
waitOn(dialog.lastTask);
waitForSwing();
MemoryBlock text = Unique.assertOne(Arrays.asList(program.getMemory().getBlocks()));
@ -128,7 +129,7 @@ public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerG
}
@Test
public void testActionCopyIntoCurrentProgramWithoutRelocationCrossLanguage() throws Exception {
public void testActionCopyIntoCurrentProgramWithoutRelocationCrossLanguage() throws Throwable {
assertDisabled(copyActionsPlugin.actionCopyIntoCurrentProgram);
createProgram(getSLEIGH_X86_LANGUAGE());
@ -201,7 +202,7 @@ public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerG
assertTrue(entry.isCreate());
dialog.okCallback();
dialog.lastTask.get(1000, TimeUnit.MILLISECONDS);
waitOn(dialog.lastTask);
waitForSwing();
byte[] dest = new byte[4];
@ -210,7 +211,7 @@ public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerG
}
@Test
public void testActionCopyIntoCurrentProgramWithRelocationExistingBlocks() throws Exception {
public void testActionCopyIntoCurrentProgramWithRelocationExistingBlocks() throws Throwable {
assertDisabled(copyActionsPlugin.actionCopyIntoCurrentProgram);
createAndOpenTrace();
@ -264,7 +265,7 @@ public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerG
assertEquals(".text *", entry.getBlockName());
assertFalse(entry.isCreate());
dialog.okCallback();
dialog.lastTask.get(1000, TimeUnit.MILLISECONDS);
waitOn(dialog.lastTask);
waitForSwing();
MemoryBlock text = Unique.assertOne(Arrays.asList(program.getMemory().getBlocks()));
@ -272,7 +273,7 @@ public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerG
}
@Test
public void testActionCopyIntoCurrentProgramWithRelocationOverlayBlocks() throws Exception {
public void testActionCopyIntoCurrentProgramWithRelocationOverlayBlocks() throws Throwable {
assertDisabled(copyActionsPlugin.actionCopyIntoCurrentProgram);
createAndOpenTrace();
@ -327,7 +328,7 @@ public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerG
assertEquals(".text_2", entry.getBlockName());
assertTrue(entry.isCreate());
dialog.okCallback();
dialog.lastTask.get(1000, TimeUnit.MILLISECONDS);
waitOn(dialog.lastTask);
waitForSwing();
MemoryBlock text2 =
@ -337,7 +338,7 @@ public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerG
}
@Test
public void testActionCopyIntoNewProgram() throws Exception {
public void testActionCopyIntoNewProgram() throws Throwable {
assertDisabled(copyActionsPlugin.actionCopyIntoNewProgram);
createAndOpenTrace();
@ -366,7 +367,7 @@ public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerG
assertTrue(entry.isCreate());
entry.setBlockName(".my_text");
dialog.okCallback();
dialog.lastTask.get(1000, TimeUnit.MILLISECONDS);
waitOn(dialog.lastTask);
waitForSwing();
// Declare my own, or the @After will try to release it erroneously
@ -379,7 +380,7 @@ public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerG
}
@Test
public void testActionCopyIntoNewProgramAdjacentRegions() throws Exception {
public void testActionCopyIntoNewProgramAdjacentRegions() throws Throwable {
assertDisabled(copyActionsPlugin.actionCopyIntoNewProgram);
createAndOpenTrace();
@ -422,7 +423,7 @@ public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerG
assertTrue(entry.isCreate());
dialog.okCallback();
dialog.lastTask.get(1000, TimeUnit.MILLISECONDS);
waitOn(dialog.lastTask);
waitForSwing();
// Declare my own, or the @After will try to release it erroneously
@ -431,7 +432,7 @@ public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerG
}
@Test
public void testActionCopyIntoNewProgramCaptureLive() throws Exception {
public void testActionCopyIntoNewProgramCaptureLive() throws Throwable {
assertDisabled(copyActionsPlugin.actionCopyIntoNewProgram);
createTestModel();
@ -482,7 +483,7 @@ public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerG
assertEquals(0, listener.count);
dialog.okCallback();
dialog.lastTask.get(10000, TimeUnit.MILLISECONDS);
waitOn(dialog.lastTask);
waitForSwing();
assertEquals(16, listener.count);
@ -494,7 +495,13 @@ public class DebuggerCopyActionsPluginTest extends AbstractGhidraHeadedDebuggerG
assertEquals(tb.addr(stSpace, 0x55550000), text.getStart());
assertEquals(".my_text", text.getName());
byte[] arr = new byte[8];
text.getBytes(tb.addr(stSpace, 0x55550000), arr);
assertArrayEquals(tb.arr(1, 2, 3, 4, 5, 6, 7, 8), arr);
/**
* While waitOn will ensure the read request completes, it doesn't ensure the recorder has
* actually written the result to the database, yet.
*/
waitForPass(noExc(() -> {
text.getBytes(tb.addr(stSpace, 0x55550000), arr);
assertArrayEquals(tb.arr(1, 2, 3, 4, 5, 6, 7, 8), arr);
}));
}
}