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;
|
||||
}
|
||||
|
||||
protected DataType getDataType(Composite c, int index) {
|
||||
DataTypeComponent dtc = c.getComponent(index);
|
||||
return (dtc != null) ? dtc.getDataType() : null;
|
||||
}
|
||||
|
||||
protected DataType getDataType(int index) {
|
||||
DataTypeComponent dtc = getComponent(index);
|
||||
return (dtc != null) ? dtc.getDataType() : null;
|
||||
|
|
|
@ -486,15 +486,17 @@ public class StructureEditorNotifiedTest extends AbstractStructureEditorTest {
|
|||
|
||||
@Test
|
||||
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);
|
||||
DataType undef = DataType.DEFAULT;
|
||||
|
||||
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(
|
||||
() -> complexStructure.getDataTypeManager().remove(simpleUnion, TaskMonitor.DUMMY));
|
||||
|
@ -521,9 +523,8 @@ public class StructureEditorNotifiedTest extends AbstractStructureEditorTest {
|
|||
waitForSwing();
|
||||
assertTrue(simpleStructure.isEquivalent(getDataType(0)));
|
||||
|
||||
runSwing(() -> simpleStructure.getDataTypeManager()
|
||||
.remove(
|
||||
simpleStructure, TaskMonitor.DUMMY));
|
||||
runSwing(
|
||||
() -> simpleStructure.getDataTypeManager().remove(simpleStructure, TaskMonitor.DUMMY));
|
||||
waitForSwing();
|
||||
assertEquals(29, model.getNumComponents());// becomes undefined bytes
|
||||
}
|
||||
|
@ -581,18 +582,21 @@ public class StructureEditorNotifiedTest extends AbstractStructureEditorTest {
|
|||
|
||||
@Test
|
||||
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);
|
||||
|
||||
int numComps = model.getNumComponents();
|
||||
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(29, complexStructure.getComponent(19).getDataType().getLength());
|
||||
assertEquals(24, complexStructure.getComponent(20).getDataType().getLength());
|
||||
|
|
|
@ -502,8 +502,9 @@ public class StructureEditorProviderTest extends AbstractStructureEditorTest {
|
|||
@Test
|
||||
public void testCloseEditorProviderAndSave() throws Exception {
|
||||
Window dialog;
|
||||
DataType oldDt = complexStructure.clone(null);
|
||||
|
||||
init(complexStructure, pgmTestCat, false);
|
||||
DataType oldDt = model.viewComposite.clone(null);
|
||||
|
||||
// Change the structure
|
||||
runSwingLater(() -> {
|
||||
|
@ -538,8 +539,9 @@ public class StructureEditorProviderTest extends AbstractStructureEditorTest {
|
|||
@Test
|
||||
public void testCloseEditorAndNoSave() throws Exception {
|
||||
|
||||
DataType oldDt = complexStructure.clone(null);
|
||||
|
||||
init(complexStructure, pgmTestCat, false);
|
||||
DataType oldDt = model.viewComposite.clone(null);
|
||||
|
||||
// Change the structure
|
||||
runSwing(() -> {
|
||||
|
|
|
@ -779,15 +779,18 @@ public class UnionEditorActions1Test extends AbstractUnionEditorTest {
|
|||
|
||||
@Test
|
||||
public void testApplyNameChange() throws Exception {
|
||||
|
||||
DataType viewCopy = complexUnion.clone(null);
|
||||
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
|
||||
model.setName("FooBarUnion");
|
||||
DataType viewCopy = model.viewComposite.clone(null);
|
||||
|
||||
assertTrue(complexUnion.isEquivalent(model.viewComposite));
|
||||
assertTrue(viewCopy.isEquivalent(complexUnion));
|
||||
|
||||
assertEquals("FooBarUnion", model.getCompositeName());
|
||||
assertEquals("complexUnion", complexUnion.getName());
|
||||
assertTrue(viewCopy.isEquivalent(model.viewComposite));
|
||||
|
||||
invoke(applyAction);
|
||||
assertTrue(viewCopy.isEquivalent(complexUnion));
|
||||
assertTrue(viewCopy.isEquivalent(model.viewComposite));
|
||||
|
|
|
@ -200,8 +200,9 @@ public class UnionEditorProviderTest extends AbstractUnionEditorTest {
|
|||
@Test
|
||||
public void testCloseEditorProviderAndSave() throws Exception {
|
||||
Window dialog;
|
||||
DataType oldDt = complexUnion.clone(null);
|
||||
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
DataType oldDt = model.viewComposite.clone(null);
|
||||
|
||||
// Change the union.
|
||||
Swing.runLater(() -> {
|
||||
|
@ -236,8 +237,9 @@ public class UnionEditorProviderTest extends AbstractUnionEditorTest {
|
|||
@Test
|
||||
public void testCloseEditorAndNoSave() throws Exception {
|
||||
Window dialog;
|
||||
DataType oldDt = complexUnion.clone(null);
|
||||
|
||||
init(complexUnion, pgmTestCat, false);
|
||||
DataType oldDt = model.viewComposite.clone(null);
|
||||
|
||||
// Change the union.
|
||||
Swing.runLater(() -> {
|
||||
|
|
|
@ -1243,15 +1243,15 @@ abstract public class DataTypeManagerDB implements DataTypeManager {
|
|||
sourceArchive.getArchiveType() == ArchiveType.BUILT_IN) {
|
||||
resolvedDataType = resolveBuiltIn(dataType);
|
||||
}
|
||||
else if (sourceArchive == null || dataType.getUniversalID() == null ||
|
||||
sourceArchive.getArchiveType() == ArchiveType.TEMPORARY) {
|
||||
else if (sourceArchive == null || dataType.getUniversalID() == null) {
|
||||
// if the dataType has no source or it has no ID (datatypes with no ID are
|
||||
// always local i.e. pointers)
|
||||
resolvedDataType = resolveDataTypeNoSource(dataType);
|
||||
}
|
||||
else if (!sourceArchive.getSourceArchiveID().equals(getUniversalID()) &&
|
||||
sourceArchive.getArchiveType() == ArchiveType.PROGRAM) {
|
||||
// dataTypes from a different program don't carry over their identity.
|
||||
(sourceArchive.getArchiveType() == ArchiveType.PROGRAM ||
|
||||
sourceArchive.getArchiveType() == ArchiveType.TEMPORARY)) {
|
||||
// dataTypes from a program or temporary archive don't carry over their identity
|
||||
resolvedDataType = resolveDataTypeNoSource(dataType);
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue