Skip to content

Ghidra is a software reverse engineering (SRE) framework

Test fixes

dragonmacher5b3e41ff1b79
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/functioncompare/actions/OpenFunctionTableAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/functioncompare/actions/OpenFunctionTableAction.java
index 186e336b19..3d8a3f4adb 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/functioncompare/actions/OpenFunctionTableAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/functioncompare/actions/OpenFunctionTableAction.java
@@ -24,7 +24,7 @@ import javax.swing.ImageIcon;
import docking.ActionContext;
import docking.action.*;
-import docking.widgets.dialogs.TableChooserDialog;
+import docking.widgets.dialogs.TableSelectionDialog;
import ghidra.app.plugin.core.functioncompare.FunctionComparisonProvider;
import ghidra.app.plugin.core.functioncompare.MultiFunctionComparisonPanel;
import ghidra.app.plugin.core.functionwindow.FunctionRowObject;
@@ -108,8 +108,8 @@ public class OpenFunctionTableAction extends DockingAction {
FunctionTableModel model = new FunctionTableModel(tool, currentProgram);
model.reload(programManagerService.getCurrentProgram());
- TableChooserDialog<FunctionRowObject> diag =
- new TableChooserDialog<>("Select Functions: " + currentProgram.getName(),
+ TableSelectionDialog<FunctionRowObject> diag =
+ new TableSelectionDialog<>("Select Functions: " + currentProgram.getName(),
model, true);
tool.showDialog(diag);
List<FunctionRowObject> rows = diag.getSelectionItems();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/test/TestEnv.java b/Ghidra/Features/Base/src/main/java/ghidra/test/TestEnv.java
index 45282934de..5e0d2b2982 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/test/TestEnv.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/test/TestEnv.java
@@ -289,21 +289,21 @@ public class TestEnv {
}
/**
- * Adds and returns the plugin to this env's tool for the given class.
+ * Adds and returns the plugin to this env's tool for the given class.
*
- * <P>If you have not created a tool using this env, then the default
+ * <P>If you have not created a tool using this env, then the default
* tool from {@link #lazyTool()} is used. If you have launched a tool, then that tool
* is used. In the following example, the given plugin is added to the default tool:
* <pre>
* TestEnv env = new TestEnv();
* env.launchDefaultTool();
* FooPlugin foo = env.addPlugin(FooPlugin.class);
- * </pre>
+ * </pre>
*
*
* @param c the plugin class
* @return the plugin instance
- * @throws PluginException if there is an exception adding the given tool
+ * @throws PluginException if there is an exception adding the given tool
*/
public <T extends Plugin> T addPlugin(Class<T> c) throws PluginException {
PluginTool defaultTool = lazyTool();
@@ -312,10 +312,10 @@ public class TestEnv {
}
/**
- * Shows any previously created tool, creating a simple empty tool if not tool has yet
- * been created.
+ * Shows any previously created tool, creating a simple empty tool if not tool has yet
+ * been created.
*
- * <P>This method is considered sub-standard and users should prefer instead
+ * <P>This method is considered sub-standard and users should prefer instead
* {@link #launchDefaultTool()} or {@link #launchDefaultTool(Program)}.
*
* @return the newly shown tool
@@ -325,10 +325,10 @@ public class TestEnv {
}
/**
- * Shows any previously created tool, creating a simple empty tool if not tool has yet
+ * Shows any previously created tool, creating a simple empty tool if not tool has yet
* been created. The given program will be opened in the tool.
*
- * <P>This method is considered sub-standard and users should prefer instead
+ * <P>This method is considered sub-standard and users should prefer instead
* {@link #launchDefaultTool()} or {@link #launchDefaultTool(Program)}.
*
* @param p the program
@@ -403,11 +403,11 @@ public class TestEnv {
}
private static void installDefaultTool(GhidraProject gp) {
- //
- // Unusual Code Alert: The default tool is not always found in the testing environment,
+ //
+ // Unusual Code Alert: The default tool is not always found in the testing environment,
// depending upon where the test lives. This code maps the test tool to that tool name
// so that tests will have the default tool as needed.
- //
+ //
Project project = gp.getProject();
ToolChest toolChest = project.getLocalToolChest();
ToolTemplate template = getToolTemplate(AbstractGenericTest.DEFAULT_TEST_TOOL_NAME);
@@ -430,7 +430,7 @@ public class TestEnv {
tool.addPlugin(ProgramManagerPlugin.class.getName());
}
catch (PluginException e) {
- e.printStackTrace();
+ Msg.error(TestEnv.class, "Problem initializing test tool", e);
}
}, true);
@@ -565,7 +565,7 @@ public class TestEnv {
script = scriptProvider.getScriptInstance(resourceFile, writer);
}
catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
- e.printStackTrace();
+ Msg.error(TestEnv.class, "Problem creating script", e);
}
if (script == null) {
@@ -1152,7 +1152,7 @@ public class TestEnv {
private void disposeAllSwingUpdateManagers() {
//
- // Cleanup all statically tracked SwingUpdateManagers. If we do not do this, then as
+ // Cleanup all statically tracked SwingUpdateManagers. If we do not do this, then as
// tools are launched, the number of tracked managers increases, as not all clients of
// the managers will dispose the managers.
//
diff --git a/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/functioncompare/CompareFunctionsSlowTest.java b/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/functioncompare/CompareFunctionsSlowTest.java
index 45313c0e52..c66f6f9cb8 100644
--- a/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/functioncompare/CompareFunctionsSlowTest.java
+++ b/Ghidra/Features/Base/src/test/java/ghidra/app/plugin/core/functioncompare/CompareFunctionsSlowTest.java
@@ -27,7 +27,7 @@ import org.junit.*;
import docking.ActionContext;
import docking.action.DockingActionIf;
-import docking.widgets.dialogs.TableChooserDialog;
+import docking.widgets.dialogs.TableSelectionDialog;
import docking.widgets.table.GFilterTable;
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
import ghidra.app.plugin.core.function.FunctionPlugin;
@@ -43,7 +43,7 @@ import ghidra.test.AbstractGhidraHeadedIntegrationTest;
import ghidra.test.TestEnv;
/**
- * Tests for the {@link FunctionComparisonPlugin function comparison plugin}
+ * Tests for the {@link FunctionComparisonPlugin function comparison plugin}
* that involve the GUI
*/
public class CompareFunctionsSlowTest extends AbstractGhidraHeadedIntegrationTest {
@@ -182,8 +182,7 @@ public class CompareFunctionsSlowTest extends AbstractGhidraHeadedIntegrationTes
Set<Function> functions = CompareFunctionsTestUtility.getFunctionsAsSet(foo);
provider = compareFunctions(functions);
- // Must do this or there will be no "active" provider in the actions
- // initiated below
+ // Must do this or there will be no "active" provider in the actions initiated below
clickComponentProvider(provider);
assertEquals(provider.getModel().getSourceFunctions().size(), 1);
@@ -192,11 +191,12 @@ public class CompareFunctionsSlowTest extends AbstractGhidraHeadedIntegrationTes
DockingActionIf openTableAction = getAction(plugin, "Add Functions To Comparison");
performAction(openTableAction, false);
- TableChooserDialog<FunctionTableModel> chooser =
- waitForDialogComponent(TableChooserDialog.class);
+ TableSelectionDialog<FunctionTableModel> chooser =
+ waitForDialogComponent(TableSelectionDialog.class);
GFilterTable<FunctionRowObject> table =
(GFilterTable<FunctionRowObject>) getInstanceField("gFilterTable", chooser);
- assertEquals(table.getModel().getRowCount(), 2);
+
+ waitForCondition(() -> table.getModel().getRowCount() == 2);
clickTableCell(table.getTable(), 1, 0, 1);
pressButtonByText(chooser, "OK");
@@ -246,7 +246,7 @@ public class CompareFunctionsSlowTest extends AbstractGhidraHeadedIntegrationTes
builder.createMemory(".text", "0x1001000", 0x6600);
builder.setProperty(Program.DATE_CREATED, new Date(100000000)); // arbitrary, but consistent
- // functions
+ // functions
DataType dt = new ByteDataType();
Parameter p = new ParameterImpl(null, dt, builder.getProgram());
foo = builder.createEmptyFunction("Foo", "10018cf", 10, null, p);
@@ -264,7 +264,7 @@ public class CompareFunctionsSlowTest extends AbstractGhidraHeadedIntegrationTes
builder.createMemory(".text", "0x1001000", 0x6600);
builder.setProperty(Program.DATE_CREATED, new Date(100000000)); // arbitrary, but consistent
- // functions
+ // functions
DataType dt = new ByteDataType();
Parameter p = new ParameterImpl(null, dt, builder.getProgram());
bar = builder.createEmptyFunction("Bar", "10018cf", 10, null, p);
diff --git a/Ghidra/Framework/Generic/src/main/java/generic/test/AbstractGenericTest.java b/Ghidra/Framework/Generic/src/main/java/generic/test/AbstractGenericTest.java
index de7beb67e8..d148103b4b 100644
--- a/Ghidra/Framework/Generic/src/main/java/generic/test/AbstractGenericTest.java
+++ b/Ghidra/Framework/Generic/src/main/java/generic/test/AbstractGenericTest.java
@@ -286,7 +286,7 @@ public abstract class AbstractGenericTest extends AbstractGTest {
return new File(uri);
}
catch (URISyntaxException e) {
- e.printStackTrace();
+ Msg.error(this, "Unable to convert URL to URI", e);
}
return null;
}
diff --git a/gradle/javaTestProject.gradle b/gradle/javaTestProject.gradle
index d2fb80849e..eb29dba044 100644
--- a/gradle/javaTestProject.gradle
+++ b/gradle/javaTestProject.gradle
@@ -159,7 +159,7 @@ def initTestJVM(Task task, String rootDirName) {
task.jvmArgs '-DupgradeProgramErrorMessage=' + upgradeProgramErrorMessage,
'-DupgradeTimeErrorMessage=' + upgradeTimeErrorMessage,
- '-Dlog4j.configuration=' + logPropertiesUrl,
+ '-Dlog4j.configurationFile=' + logPropertiesUrl,
'-Dghidra.test.property.batch.mode=true',
'-Dghidra.test.property.parallel.mode=' + parallelMode,
'-Dghidra.test.property.output.dir=' + testOutputDir,
diff --git a/gradle/root/test.gradle b/gradle/root/test.gradle
index cd50d17fb6..641b721b72 100644
--- a/gradle/root/test.gradle
+++ b/gradle/root/test.gradle
@@ -327,7 +327,7 @@ def initTestJVM(Task task, String rootDirName) {
task.jvmArgs '-DupgradeProgramErrorMessage=' + upgradeProgramErrorMessage,
'-DupgradeTimeErrorMessage=' + upgradeTimeErrorMessage,
- '-Dlog4j.configuration=' + logPropertiesUrl,
+ '-Dlog4j.configurationFile=' + logPropertiesUrl,
'-Dghidra.test.property.batch.mode=true',
'-Dghidra.test.property.parallel.mode=' + parallelMode,
'-Dghidra.test.property.output.dir=' + testOutputDir,