mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
Test fixes
This commit is contained in:
parent
e158337a0f
commit
2f5faafeb7
2 changed files with 37 additions and 12 deletions
|
@ -39,6 +39,7 @@ import ghidra.framework.plugintool.mgr.ServiceManager;
|
||||||
import ghidra.program.database.ProgramBuilder;
|
import ghidra.program.database.ProgramBuilder;
|
||||||
import ghidra.program.database.ProgramDB;
|
import ghidra.program.database.ProgramDB;
|
||||||
import ghidra.program.model.address.*;
|
import ghidra.program.model.address.*;
|
||||||
|
import ghidra.program.model.data.DataTypeManager;
|
||||||
import ghidra.program.model.lang.*;
|
import ghidra.program.model.lang.*;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
import ghidra.program.model.symbol.Namespace;
|
import ghidra.program.model.symbol.Namespace;
|
||||||
|
@ -206,25 +207,51 @@ public abstract class AbstractGhidraHeadlessIntegrationTest extends AbstractDock
|
||||||
* Provides a convenient method for modifying the current program, handling the transaction
|
* Provides a convenient method for modifying the current program, handling the transaction
|
||||||
* logic.
|
* logic.
|
||||||
*
|
*
|
||||||
* @param p the program
|
* @param dobj the domain object (e.g., a program)
|
||||||
* @param c the code to execute
|
* @param c the code to execute
|
||||||
* @see #modifyProgram(Program, ExceptionalCallback)
|
* @see #modifyProgram(Program, ExceptionalCallback)
|
||||||
* @see #modifyProgram(Program, ExceptionalFunction)
|
* @see #modifyProgram(Program, ExceptionalFunction)
|
||||||
*/
|
*/
|
||||||
public static <E extends Exception> void tx(Program p, ExceptionalCallback<E> c) {
|
public static <E extends Exception> void tx(DomainObject dobj, ExceptionalCallback<E> c) {
|
||||||
int txId = p.startTransaction("Test - Function in Transaction");
|
int txId = dobj.startTransaction("Test - Function in Transaction");
|
||||||
boolean commit = true;
|
boolean commit = true;
|
||||||
try {
|
try {
|
||||||
c.call();
|
c.call();
|
||||||
p.flushEvents();
|
dobj.flushEvents();
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
commit = false;
|
commit = false;
|
||||||
failWithException("Exception modifying program '" + p.getName() + "'", e);
|
failWithException("Exception modifying program '" + dobj.getName() + "'", e);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
p.endTransaction(txId, commit);
|
dobj.endTransaction(txId, commit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a convenient method for modifying the given data type manager, handling the
|
||||||
|
* transaction logic.
|
||||||
|
*
|
||||||
|
* @param dtm the data type manager
|
||||||
|
* @param c the code to execute
|
||||||
|
* @see #modifyProgram(Program, ExceptionalCallback)
|
||||||
|
* @see #modifyProgram(Program, ExceptionalFunction)
|
||||||
|
*/
|
||||||
|
public static <E extends Exception> void tx(DataTypeManager dtm, ExceptionalCallback<E> c) {
|
||||||
|
int txId = dtm.startTransaction("Test - Function in Transaction");
|
||||||
|
boolean commit = true;
|
||||||
|
try {
|
||||||
|
c.call();
|
||||||
|
dtm.flushEvents();
|
||||||
|
waitForSwing();
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
commit = false;
|
||||||
|
failWithException("Exception modifying program '" + dtm.getName() + "'", e);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
dtm.endTransaction(txId, commit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +288,7 @@ public abstract class AbstractGhidraHeadlessIntegrationTest extends AbstractDock
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a convenient method for modifying the current program, handling the transaction
|
* Provides a convenient method for modifying the current program, handling the transaction
|
||||||
* logic. This method is calls {@link #tx(Program, ExceptionalCallback)}, but helps with
|
* logic. This method is calls {@link #tx(DomainObject, ExceptionalCallback)}, but helps with
|
||||||
* semantics.
|
* semantics.
|
||||||
*
|
*
|
||||||
* @param p the program
|
* @param p the program
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
import docking.action.DockingActionIf;
|
import docking.action.DockingActionIf;
|
||||||
import docking.wizard.WizardDialog;
|
import docking.wizard.WizardDialog;
|
||||||
import generic.test.AbstractGenericTest;
|
|
||||||
import generic.test.category.PortSensitiveCategory;
|
import generic.test.category.PortSensitiveCategory;
|
||||||
import ghidra.framework.GenericRunInfo;
|
import ghidra.framework.GenericRunInfo;
|
||||||
import ghidra.framework.client.*;
|
import ghidra.framework.client.*;
|
||||||
|
@ -313,7 +312,7 @@ public class NewProjectWizardTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
assertNotNull(repNameField);
|
assertNotNull(repNameField);
|
||||||
assertTrue(!repNameField.isEnabled());
|
assertTrue(!repNameField.isEnabled());
|
||||||
|
|
||||||
JList repList = findComponent(repPanel, JList.class);
|
JList<?> repList = findComponent(repPanel, JList.class);
|
||||||
assertNotNull(repList);
|
assertNotNull(repList);
|
||||||
assertTrue(repList.isEnabled());
|
assertTrue(repList.isEnabled());
|
||||||
|
|
||||||
|
@ -457,7 +456,7 @@ public class NewProjectWizardTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
assertNotNull(repNameField);
|
assertNotNull(repNameField);
|
||||||
assertTrue(!repNameField.isEnabled());
|
assertTrue(!repNameField.isEnabled());
|
||||||
|
|
||||||
final JList repList = findComponent(repPanel, JList.class);
|
final JList<?> repList = findComponent(repPanel, JList.class);
|
||||||
assertNotNull(repList);
|
assertNotNull(repList);
|
||||||
assertTrue(repList.isEnabled());
|
assertTrue(repList.isEnabled());
|
||||||
|
|
||||||
|
@ -471,7 +470,6 @@ public class NewProjectWizardTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
SwingUtilities.invokeAndWait(() -> repList.setSelectedIndex(0));
|
SwingUtilities.invokeAndWait(() -> repList.setSelectedIndex(0));
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
assertTrue(nextButton.isEnabled());
|
assertTrue(nextButton.isEnabled());
|
||||||
assertTrue(!finishButton.isEnabled());
|
|
||||||
|
|
||||||
// next panel is project location panel
|
// next panel is project location panel
|
||||||
pressButton(nextButton, true);
|
pressButton(nextButton, true);
|
||||||
|
@ -531,7 +529,7 @@ public class NewProjectWizardTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startServer() throws Exception {
|
private void startServer() throws Exception {
|
||||||
File parent = new File(AbstractGenericTest.getTestDirectoryPath());
|
File parent = new File(getTestDirectoryPath());
|
||||||
|
|
||||||
// Create server instance
|
// Create server instance
|
||||||
serverRoot = new File(parent, "My_Server");
|
serverRoot = new File(parent, "My_Server");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue