mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
GP-0 Corrected test failure fallout from GP-4682 datatype resolution
change related to temporary source archive
This commit is contained in:
parent
b86ad84c04
commit
3b6d5e43ce
6 changed files with 44 additions and 28 deletions
|
@ -372,6 +372,11 @@ public abstract class AbstractEditorTest extends AbstractGhidraHeadedIntegration
|
||||||
return (dtc != null) ? dtc.getLength() : -1;
|
return (dtc != null) ? dtc.getLength() : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected DataType getDataType(Composite c, int index) {
|
||||||
|
DataTypeComponent dtc = c.getComponent(index);
|
||||||
|
return (dtc != null) ? dtc.getDataType() : null;
|
||||||
|
}
|
||||||
|
|
||||||
protected DataType getDataType(int index) {
|
protected DataType getDataType(int index) {
|
||||||
DataTypeComponent dtc = getComponent(index);
|
DataTypeComponent dtc = getComponent(index);
|
||||||
return (dtc != null) ? dtc.getDataType() : null;
|
return (dtc != null) ? dtc.getDataType() : null;
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class StructureEditorNotifiedTest extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
programDTM.remove(complexStructure, TaskMonitor.DUMMY);
|
programDTM.remove(complexStructure, TaskMonitor.DUMMY);
|
||||||
programDTM.getCategory(pgmRootCat.getCategoryPath())
|
programDTM.getCategory(pgmRootCat.getCategoryPath())
|
||||||
.removeCategory("Temp", TaskMonitor.DUMMY);
|
.removeCategory("Temp", TaskMonitor.DUMMY);
|
||||||
|
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
|
|
||||||
|
@ -486,15 +486,17 @@ public class StructureEditorNotifiedTest extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testComponentDataTypeRemoved() {
|
public void testComponentDataTypeRemoved() {
|
||||||
|
|
||||||
|
// Get the data types we want to hold onto for comparison later
|
||||||
|
DataType dt3 = getDataType(complexStructure, 3);
|
||||||
|
DataType dt5 = getDataType(complexStructure, 5);
|
||||||
|
DataType dt8 = getDataType(complexStructure, 8);
|
||||||
|
DataType dt10 = getDataType(complexStructure, 10);
|
||||||
|
|
||||||
init(complexStructure, pgmTestCat);
|
init(complexStructure, pgmTestCat);
|
||||||
DataType undef = DataType.DEFAULT;
|
DataType undef = DataType.DEFAULT;
|
||||||
|
|
||||||
assertEquals(23, model.getNumComponents());
|
assertEquals(23, model.getNumComponents());
|
||||||
// Clone the data types we want to hold onto for comparison later, since reload can close the viewDTM.
|
|
||||||
DataType dt3 = getDataType(3).clone(programDTM);
|
|
||||||
DataType dt5 = getDataType(5).clone(programDTM);
|
|
||||||
DataType dt8 = getDataType(8).clone(programDTM);
|
|
||||||
DataType dt10 = getDataType(10).clone(programDTM);
|
|
||||||
|
|
||||||
runSwing(
|
runSwing(
|
||||||
() -> complexStructure.getDataTypeManager().remove(simpleUnion, TaskMonitor.DUMMY));
|
() -> complexStructure.getDataTypeManager().remove(simpleUnion, TaskMonitor.DUMMY));
|
||||||
|
@ -521,9 +523,8 @@ public class StructureEditorNotifiedTest extends AbstractStructureEditorTest {
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
assertTrue(simpleStructure.isEquivalent(getDataType(0)));
|
assertTrue(simpleStructure.isEquivalent(getDataType(0)));
|
||||||
|
|
||||||
runSwing(() -> simpleStructure.getDataTypeManager()
|
runSwing(
|
||||||
.remove(
|
() -> simpleStructure.getDataTypeManager().remove(simpleStructure, TaskMonitor.DUMMY));
|
||||||
simpleStructure, TaskMonitor.DUMMY));
|
|
||||||
waitForSwing();
|
waitForSwing();
|
||||||
assertEquals(29, model.getNumComponents());// becomes undefined bytes
|
assertEquals(29, model.getNumComponents());// becomes undefined bytes
|
||||||
}
|
}
|
||||||
|
@ -581,18 +582,21 @@ public class StructureEditorNotifiedTest extends AbstractStructureEditorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testComponentDataTypeReplaced() throws Exception {
|
public void testComponentDataTypeReplaced() throws Exception {
|
||||||
|
|
||||||
|
// Get the data types we want to hold onto for comparison later
|
||||||
|
DataType dt15 = getDataType(complexStructure, 15);
|
||||||
|
DataType dt16 = getDataType(complexStructure, 16);
|
||||||
|
DataType dt18 = getDataType(complexStructure, 18);
|
||||||
|
DataType dt19 = getDataType(complexStructure, 19);
|
||||||
|
DataType dt20 = getDataType(complexStructure, 20);
|
||||||
|
String dt21Name = getDataType(complexStructure, 21).getName();
|
||||||
|
DataType dt22 = getDataType(complexStructure, 22);
|
||||||
|
|
||||||
init(complexStructure, pgmTestCat);
|
init(complexStructure, pgmTestCat);
|
||||||
|
|
||||||
int numComps = model.getNumComponents();
|
int numComps = model.getNumComponents();
|
||||||
int len = model.getLength();
|
int len = model.getLength();
|
||||||
// Clone the data types we want to hold onto for comparison later, since reload can close the viewDTM.
|
|
||||||
DataType dt15 = getDataType(15).clone(programDTM);
|
|
||||||
DataType dt16 = getDataType(16).clone(programDTM);
|
|
||||||
DataType dt18 = getDataType(18).clone(programDTM);
|
|
||||||
DataType dt19 = getDataType(19).clone(programDTM);
|
|
||||||
DataType dt20 = getDataType(20).clone(programDTM);
|
|
||||||
String dt21Name = getDataType(21).getName();
|
|
||||||
DataType dt22 = getDataType(22).clone(programDTM);
|
|
||||||
assertEquals(87, complexStructure.getComponent(16).getDataType().getLength());
|
assertEquals(87, complexStructure.getComponent(16).getDataType().getLength());
|
||||||
assertEquals(29, complexStructure.getComponent(19).getDataType().getLength());
|
assertEquals(29, complexStructure.getComponent(19).getDataType().getLength());
|
||||||
assertEquals(24, complexStructure.getComponent(20).getDataType().getLength());
|
assertEquals(24, complexStructure.getComponent(20).getDataType().getLength());
|
||||||
|
|
|
@ -502,8 +502,9 @@ public class StructureEditorProviderTest extends AbstractStructureEditorTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCloseEditorProviderAndSave() throws Exception {
|
public void testCloseEditorProviderAndSave() throws Exception {
|
||||||
Window dialog;
|
Window dialog;
|
||||||
|
DataType oldDt = complexStructure.clone(null);
|
||||||
|
|
||||||
init(complexStructure, pgmTestCat, false);
|
init(complexStructure, pgmTestCat, false);
|
||||||
DataType oldDt = model.viewComposite.clone(null);
|
|
||||||
|
|
||||||
// Change the structure
|
// Change the structure
|
||||||
runSwingLater(() -> {
|
runSwingLater(() -> {
|
||||||
|
@ -538,8 +539,9 @@ public class StructureEditorProviderTest extends AbstractStructureEditorTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCloseEditorAndNoSave() throws Exception {
|
public void testCloseEditorAndNoSave() throws Exception {
|
||||||
|
|
||||||
|
DataType oldDt = complexStructure.clone(null);
|
||||||
|
|
||||||
init(complexStructure, pgmTestCat, false);
|
init(complexStructure, pgmTestCat, false);
|
||||||
DataType oldDt = model.viewComposite.clone(null);
|
|
||||||
|
|
||||||
// Change the structure
|
// Change the structure
|
||||||
runSwing(() -> {
|
runSwing(() -> {
|
||||||
|
|
|
@ -779,15 +779,18 @@ public class UnionEditorActions1Test extends AbstractUnionEditorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApplyNameChange() throws Exception {
|
public void testApplyNameChange() throws Exception {
|
||||||
|
|
||||||
|
DataType viewCopy = complexUnion.clone(null);
|
||||||
|
|
||||||
init(complexUnion, pgmTestCat, false);
|
init(complexUnion, pgmTestCat, false);
|
||||||
|
|
||||||
model.setName("FooBarUnion");
|
model.setName("FooBarUnion");
|
||||||
DataType viewCopy = model.viewComposite.clone(null);
|
|
||||||
|
|
||||||
assertTrue(complexUnion.isEquivalent(model.viewComposite));
|
assertTrue(viewCopy.isEquivalent(complexUnion));
|
||||||
|
|
||||||
assertEquals("FooBarUnion", model.getCompositeName());
|
assertEquals("FooBarUnion", model.getCompositeName());
|
||||||
assertEquals("complexUnion", complexUnion.getName());
|
assertEquals("complexUnion", complexUnion.getName());
|
||||||
assertTrue(viewCopy.isEquivalent(model.viewComposite));
|
|
||||||
invoke(applyAction);
|
invoke(applyAction);
|
||||||
assertTrue(viewCopy.isEquivalent(complexUnion));
|
assertTrue(viewCopy.isEquivalent(complexUnion));
|
||||||
assertTrue(viewCopy.isEquivalent(model.viewComposite));
|
assertTrue(viewCopy.isEquivalent(model.viewComposite));
|
||||||
|
|
|
@ -200,8 +200,9 @@ public class UnionEditorProviderTest extends AbstractUnionEditorTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCloseEditorProviderAndSave() throws Exception {
|
public void testCloseEditorProviderAndSave() throws Exception {
|
||||||
Window dialog;
|
Window dialog;
|
||||||
|
DataType oldDt = complexUnion.clone(null);
|
||||||
|
|
||||||
init(complexUnion, pgmTestCat, false);
|
init(complexUnion, pgmTestCat, false);
|
||||||
DataType oldDt = model.viewComposite.clone(null);
|
|
||||||
|
|
||||||
// Change the union.
|
// Change the union.
|
||||||
Swing.runLater(() -> {
|
Swing.runLater(() -> {
|
||||||
|
@ -236,8 +237,9 @@ public class UnionEditorProviderTest extends AbstractUnionEditorTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCloseEditorAndNoSave() throws Exception {
|
public void testCloseEditorAndNoSave() throws Exception {
|
||||||
Window dialog;
|
Window dialog;
|
||||||
|
DataType oldDt = complexUnion.clone(null);
|
||||||
|
|
||||||
init(complexUnion, pgmTestCat, false);
|
init(complexUnion, pgmTestCat, false);
|
||||||
DataType oldDt = model.viewComposite.clone(null);
|
|
||||||
|
|
||||||
// Change the union.
|
// Change the union.
|
||||||
Swing.runLater(() -> {
|
Swing.runLater(() -> {
|
||||||
|
|
|
@ -1243,15 +1243,15 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
||||||
sourceArchive.getArchiveType() == ArchiveType.BUILT_IN) {
|
sourceArchive.getArchiveType() == ArchiveType.BUILT_IN) {
|
||||||
resolvedDataType = resolveBuiltIn(dataType);
|
resolvedDataType = resolveBuiltIn(dataType);
|
||||||
}
|
}
|
||||||
else if (sourceArchive == null || dataType.getUniversalID() == null ||
|
else if (sourceArchive == null || dataType.getUniversalID() == null) {
|
||||||
sourceArchive.getArchiveType() == ArchiveType.TEMPORARY) {
|
|
||||||
// if the dataType has no source or it has no ID (datatypes with no ID are
|
// if the dataType has no source or it has no ID (datatypes with no ID are
|
||||||
// always local i.e. pointers)
|
// always local i.e. pointers)
|
||||||
resolvedDataType = resolveDataTypeNoSource(dataType);
|
resolvedDataType = resolveDataTypeNoSource(dataType);
|
||||||
}
|
}
|
||||||
else if (!sourceArchive.getSourceArchiveID().equals(getUniversalID()) &&
|
else if (!sourceArchive.getSourceArchiveID().equals(getUniversalID()) &&
|
||||||
sourceArchive.getArchiveType() == ArchiveType.PROGRAM) {
|
(sourceArchive.getArchiveType() == ArchiveType.PROGRAM ||
|
||||||
// dataTypes from a different program don't carry over their identity.
|
sourceArchive.getArchiveType() == ArchiveType.TEMPORARY)) {
|
||||||
|
// dataTypes from a program or temporary archive don't carry over their identity
|
||||||
resolvedDataType = resolveDataTypeNoSource(dataType);
|
resolvedDataType = resolveDataTypeNoSource(dataType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue