Ghidra is a software reverse engineering (SRE) framework
Corrected test failures
ghidra1077902d99af0
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions1Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions1Test.javaindex 6b615b4478..9b1235f934 100644--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions1Test.java+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions1Test.java@@ -20,6 +20,7 @@ import static org.junit.Assert.*;import org.junit.Test;import ghidra.program.model.data.*;+import ghidra.util.exception.UsrException;public class StructureEditorLockedActions1Test extends AbstractStructureEditorLockedActionsTest {@@ -43,8 +44,14 @@ public class StructureEditorLockedActions1Test extends AbstractStructureEditorLo@Testpublic void testArrayOnSelectionExtraUndefineds() throws Exception {init(simpleStructure, pgmBbCat);- model.clearComponents(new int[] { 4, 5 });-+ runSwing(() -> {+ try {+ model.clearComponents(new int[] { 4, 5 });+ }+ catch (UsrException e) {+ failWithException("Unexpected error", e);+ }+ });setSelection(new int[] { 3, 4, 5, 6, 7, 8, 9, 10 });// starts with DWordDataType dt3 = getDataType(3);DataType dt11 = getDataType(11);@@ -66,9 +73,15 @@ public class StructureEditorLockedActions1Test extends AbstractStructureEditorLo@Testpublic void testClearAction() throws Exception {init(complexStructure, pgmTestCat);- model.setComponentName(2, "comp2");- model.setComponentComment(2, "comment 2");-+ runSwing(() -> {+ try {+ model.setComponentName(2, "comp2");+ model.setComponentComment(2, "comment 2");+ }+ catch (UsrException e) {+ failWithException("Unexpected error", e);+ }+ });int num = getModel().getNumComponents();// Duplicate Word@@ -89,8 +102,14 @@ public class StructureEditorLockedActions1Test extends AbstractStructureEditorLo@Testpublic void testCreateCycleOnPointer() throws Exception {init(simpleStructure, pgmBbCat);- model.clearComponents(new int[] { 2, 3 });-+ runSwing(() -> {+ try {+ model.clearComponents(new int[] { 2, 3 });+ }+ catch (UsrException e) {+ failWithException("Unexpected error", e);+ }+ });setSelection(new int[] { 1 });invoke(pointerAction);CycleGroupAction cycleByte = getCycleGroup(new ByteDataType());@@ -117,8 +136,9 @@ public class StructureEditorLockedActions1Test extends AbstractStructureEditorLo@Testpublic void testCreatePointerOnUndefined() throws Exception {init(simpleStructure, pgmBbCat);- model.clearComponent(3);-+ runSwing(() -> {+ model.clearComponent(3);+ });setSelection(new int[] { 3 });invoke(pointerAction);assertEquals("pointer", getDataType(3).getDisplayName());diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions2Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions2Test.javaindex 82789edaa3..b2ddbda7f1 100644--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions2Test.java+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions2Test.java@@ -29,8 +29,9 @@ public class StructureEditorLockedActions2Test extends AbstractStructureEditorLo@Testpublic void testCycleGroupByteSomeRoom() throws Exception {init(complexStructure, pgmTestCat);- getModel().clearComponents(new int[] { 2, 3 });// clear 6 bytes-+ runSwing(() -> {+ getModel().clearComponents(new int[] { 2, 3 });// clear 6 bytes+ });DataType dt8 = getDataType(8);int dt8Len = getLength(8);int num = getModel().getNumComponents();@@ -87,8 +88,9 @@ public class StructureEditorLockedActions2Test extends AbstractStructureEditorLo@Testpublic void testCycleGroupFloatLotsOfRoom() throws Exception {init(complexStructure, pgmTestCat);- getModel().clearComponents(new int[] { 2, 3, 4 });// clear 14 bytes-+ runSwing(() -> {+ getModel().clearComponents(new int[] { 2, 3, 4 });// clear 14 bytes+ });DataType dt16 = getDataType(16);int dt16Len = getLength(16);int num = getModel().getNumComponents();diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions4Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions4Test.javaindex 420707a960..2b1ceeb8ff 100644--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions4Test.java+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedActions4Test.java@@ -28,8 +28,9 @@ public class StructureEditorLockedActions4Test extends AbstractStructureEditorLopublic void testArrayBeforeUndefineds() throws Exception {init(simpleStructure, pgmBbCat);NumberInputDialog dialog;- model.clearComponents(new int[] { 2, 3 });-+ runSwing(() -> {+ getModel().clearComponents(new int[] { 2, 3 });+ });setSelection(new int[] { 1 });DataType dt1 = getDataType(1);DataType dt8 = getDataType(8);@@ -86,8 +87,9 @@ public class StructureEditorLockedActions4Test extends AbstractStructureEditorLopublic void testCycleGroupAsciiLotsOfRoom() throws Exception {init(complexStructure, pgmTestCat);NumberInputDialog dialog;- getModel().clearComponents(new int[] { 2, 3, 4 });// clear 14 bytes-+ runSwing(() -> {+ getModel().clearComponents(new int[] { 2, 3, 4 });// clear 14 bytes+ });DataType dt16 = getDataType(16);int dt16Len = getLength(16);int num = getModel().getNumComponents();@@ -156,8 +158,9 @@ public class StructureEditorLockedActions4Test extends AbstractStructureEditorLopublic void testCycleGroupAsciiSomeRoom() throws Exception {init(complexStructure, pgmTestCat);NumberInputDialog dialog;- getModel().clearComponents(new int[] { 2, 3 });// clear 6 bytes-+ runSwing(() -> {+ getModel().clearComponents(new int[] { 2, 3 });// clear 6 bytes+ });DataType dt8 = getDataType(8);int dt8Len = getLength(8);int num = getModel().getNumComponents();diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedDnDTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedDnDTest.javaindex bcea7bd47d..69f753f223 100644--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedDnDTest.java+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedDnDTest.java@@ -55,8 +55,9 @@ public class StructureEditorLockedDnDTest extends AbstractStructureEditorTest {public void testDragNDropConsumeAll() throws Exception {init(simpleStructure, pgmBbCat);DataType dt;- model.clearComponents(new int[] { 1, 2, 3 });-+ runSwing(() -> {+ getModel().clearComponents(new int[] { 1, 2, 3 });+ });assertEquals(12, model.getNumComponents());assertEquals(29, model.getLength());diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions3Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions3Test.javaindex 829939ca6d..d0f4d20007 100644--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions3Test.java+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions3Test.java@@ -35,9 +35,9 @@ public class StructureEditorUnlockedActions3Testpublic void testDuplicateMultipleAction() throws Exception {NumberInputDialog dialog;init(complexStructure, pgmTestCat);-- model.clearComponent(3);-+ runSwing(() -> {+ model.clearComponent(3);+ });int num = model.getNumComponents();setSelection(new int[] { 2 });@@ -203,7 +203,9 @@ public class StructureEditorUnlockedActions3Testinit(complexStructure, pgmTestCat);String desc = "This is a sample description.";- model.setDescription(desc);+ runSwing(() -> {+ model.setDescription(desc);+ });DataType viewCopy = model.viewComposite.clone(null);assertEquals(desc, model.getDescription());diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions4Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions4Test.javaindex f2bd00c1d8..0d42d6713c 100644--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions4Test.java+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions4Test.java@@ -25,6 +25,8 @@ import org.junit.Test;import docking.widgets.dialogs.NumberInputDialog;import ghidra.program.model.data.*;+import ghidra.util.InvalidNameException;+import ghidra.util.exception.*;public class StructureEditorUnlockedActions4Testextends AbstractStructureEditorUnlockedActionsTest {@@ -61,7 +63,9 @@ public class StructureEditorUnlockedActions4Testpublic void testArrayOnVarDt() throws Exception {init(complexStructure, pgmTestCat);NumberInputDialog dialog;- model.clearComponent(6);+ runSwing(() -> {+ model.clearComponent(6);+ });int num = model.getNumComponents();setSelection(new int[] { 5 });@@ -100,10 +104,24 @@ public class StructureEditorUnlockedActions4Test@Testpublic void testDuplicateAction() throws Exception {init(complexStructure, pgmTestCat);-- model.setComponentName(1, "comp1");- model.setComponentComment(1, "comment 1");- model.clearComponent(2);+ runSwing(() -> {+ try {+ model.setComponentName(1, "comp1");+ model.setComponentComment(1, "comment 1");+ model.clearComponent(2);+ }+ catch (InvalidInputException e) {+ failWithException("Unexpected error", e);+ }+ catch (InvalidNameException e) {+ // TODO Auto-generated catch block+ e.printStackTrace();+ }+ catch (DuplicateNameException e) {+ // TODO Auto-generated catch block+ e.printStackTrace();+ }+ });int len = model.getLength();int num = model.getNumComponents();@@ -234,8 +252,15 @@ public class StructureEditorUnlockedActions4Testinit(complexStructure, pgmTestCat);setSelection(new int[] { 3, 4 });- model.clearSelectedComponents();- model.deleteSelectedComponents();+ runSwing(() -> {+ try {+ model.clearSelectedComponents();+ model.deleteSelectedComponents();+ }+ catch (UsrException e) {+ failWithException("Unexpected error", e);+ }+ });DataType viewCopy = model.viewComposite.clone(null);assertTrue(!complexStructure.isEquivalent(model.viewComposite));diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions5Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions5Test.javaindex f481d683e0..de327790b1 100644--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions5Test.java+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions5Test.java@@ -29,6 +29,7 @@ import org.junit.Test;import docking.widgets.dialogs.NumberInputDialog;import ghidra.program.model.data.*;import ghidra.util.exception.DuplicateNameException;+import ghidra.util.exception.UsrException;public class StructureEditorUnlockedActions5Testextends AbstractStructureEditorUnlockedActionsTest {@@ -49,8 +50,14 @@ public class StructureEditorUnlockedActions5Test@Testpublic void testApplyNameChange() throws Exception {init(complexStructure, pgmTestCat);-- model.setName("FooBarStructure");+ runSwing(() -> {+ try {+ model.setName("FooBarStructure");+ }+ catch (UsrException e) {+ failWithException("Unexpected error", e);+ }+ });DataType viewCopy = model.viewComposite.clone(null);assertEquals("FooBarStructure", model.getCompositeName());diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions6Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions6Test.javaindex 7cfc74569e..7f9609cdc4 100644--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions6Test.java+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedActions6Test.java@@ -33,7 +33,9 @@ public class StructureEditorUnlockedActions6Testpublic void testArrayOnArray() throws Exception {init(complexStructure, pgmTestCat);NumberInputDialog dialog;- model.clearComponent(16);+ runSwing(() -> {+ model.clearComponent(16);+ });int num = model.getNumComponents();setSelection(new int[] { 15 });@@ -58,7 +60,9 @@ public class StructureEditorUnlockedActions6Testpublic void testArrayOnFixedDt() throws Exception {init(simpleStructure, pgmBbCat);NumberInputDialog dialog;- model.clearComponents(new int[] { 4, 5, 6 });+ runSwing(() -> {+ getModel().clearComponents(new int[] { 4, 5, 6 });+ });int num = model.getNumComponents();setSelection(new int[] { 3 });diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/data/AbstractDataActionTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/data/AbstractDataActionTest.javaindex a8c38ab08d..8944f97b2c 100644--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/data/AbstractDataActionTest.java+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/data/AbstractDataActionTest.java@@ -999,7 +999,7 @@ public abstract class AbstractDataActionTest extends AbstractGhidraHeadedIntegra}String str = (new BigInteger(bytes)).toString(8).toUpperCase();if (padded) {- int digits = 3 * byteCnt;+ int digits = ((8 * byteCnt) + 2) / 3;for (int i = str.length(); i < digits; i++) {str = "0" + str;}