diff --git a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/url/ProjectExperimentsTest.java b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/url/ProjectExperimentsTest.java index adae9bb769..26d6a7ccb5 100644 --- a/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/url/ProjectExperimentsTest.java +++ b/Ghidra/Debug/Debugger/src/test/java/ghidra/app/plugin/core/debug/service/url/ProjectExperimentsTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -185,7 +185,7 @@ public class ProjectExperimentsTest extends AbstractGhidraHeadedIntegrationTest ProjectData data = env.getProject().getProjectData(); data.addDomainFolderChangeListener(rdfl); - ToyProgramBuilder b = new ToyProgramBuilder("test", true); + ToyProgramBuilder b = new ToyProgramBuilder(); Program program = b.getProgram(); data.getRootFolder().createFile(program.getName(), program, new ConsoleTaskMonitor()); @@ -201,7 +201,7 @@ public class ProjectExperimentsTest extends AbstractGhidraHeadedIntegrationTest ProjectData data = env.getProject().getProjectData(); data.addDomainFolderChangeListener(rdfl); - ToyProgramBuilder b = new ToyProgramBuilder("test", true); + ToyProgramBuilder b = new ToyProgramBuilder(); Program program = b.getProgram(); DomainFolder myFolder = data.getRootFolder().createFolder("MyFolder"); DomainFile file = myFolder.createFile(program.getName(), program, new ConsoleTaskMonitor()); @@ -223,7 +223,7 @@ public class ProjectExperimentsTest extends AbstractGhidraHeadedIntegrationTest ProjectData data = env.getProject().getProjectData(); data.addDomainFolderChangeListener(rdfl); - ToyProgramBuilder b = new ToyProgramBuilder("test", true); + ToyProgramBuilder b = new ToyProgramBuilder(); Program program = b.getProgram(); DomainFolder myFolder = data.getRootFolder().createFolder("MyFolder"); myFolder.createFile(program.getName(), program, new ConsoleTaskMonitor()); diff --git a/Ghidra/Features/Base/src/main/java/ghidra/program/database/ProgramBuilder.java b/Ghidra/Features/Base/src/main/java/ghidra/program/database/ProgramBuilder.java index a52fd7b2d3..5394825d9f 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/program/database/ProgramBuilder.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/program/database/ProgramBuilder.java @@ -51,6 +51,7 @@ import ghidra.program.model.util.*; import ghidra.program.util.DefaultLanguageService; import ghidra.program.util.GhidraProgramUtilities; import ghidra.test.AbstractGhidraHeadedIntegrationTest; +import ghidra.test.TestEnv; import ghidra.util.*; import ghidra.util.exception.*; import ghidra.util.task.TaskMonitor; @@ -59,6 +60,8 @@ import utility.function.ExceptionalCallback; // TODO: Move this class into a different package (i.e., ghidra.test.program) public class ProgramBuilder { + private static Set allBuilders = new HashSet<>(); + public static final String _ARM = "ARM:LE:32:v7"; public static final String _AARCH64 = "AARCH64:LE:64:v8A"; public static final String _X86 = "x86:LE:32:default"; @@ -138,6 +141,9 @@ public class ProgramBuilder { CompilerSpec compilerSpec = compilerSpecID == null ? language.getDefaultCompilerSpec() : language.getCompilerSpecByID(new CompilerSpecID(compilerSpecID)); program = new ProgramDB(name, language, compilerSpec, consumer == null ? this : consumer); + + allBuilders.add(this); + setAnalyzed(); program.setTemporary(true); // ignore changes } @@ -151,6 +157,9 @@ public class ProgramBuilder { public ProgramBuilder(String name, Language language) throws Exception { CompilerSpec compilerSpec = language.getDefaultCompilerSpec(); program = new ProgramDB(name, language, compilerSpec, this); + + allBuilders.add(this); + setAnalyzed(); program.setTemporary(true); // ignore changes } @@ -214,7 +223,19 @@ public class ProgramBuilder { return addr; } + /** + * A methods called by {@link TestEnv} to cleanup all resources. + */ + public static void disposeAllBuilders() { + HashSet set = new HashSet<>(allBuilders); + allBuilders.clear(); + for (ProgramBuilder builder : set) { + builder.dispose(); + } + } + public void dispose() { + allBuilders.remove(this); if (program.isUsedBy(this)) { // Make sure any buffered events are processed before we release. This fixes a timing diff --git a/Ghidra/Features/Base/src/main/java/ghidra/test/ProjectTestUtils.java b/Ghidra/Features/Base/src/main/java/ghidra/test/ProjectTestUtils.java index 74fea9c2c1..86970bb1d6 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/test/ProjectTestUtils.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/test/ProjectTestUtils.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -145,6 +145,10 @@ public class ProjectTestUtils { File secondLockFile = new File(lockFile.getAbsolutePath() + "~"); if (secondLockFile.exists()) { deleted = secondLockFile.delete(); + if (!deleted) { + Msg.warn(ProjectTestUtils.class, "Unable to delete the second lock file: " + secondLockFile); + } + } return deleted; 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 c976fca608..8099332624 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/test/TestEnv.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/test/TestEnv.java @@ -50,6 +50,7 @@ import ghidra.framework.plugintool.PluginTool; import ghidra.framework.plugintool.util.PluginException; import ghidra.framework.project.DefaultProjectManager; import ghidra.framework.protocol.ghidra.GhidraURL; +import ghidra.program.database.ProgramBuilder; import ghidra.program.database.ProgramDB; import ghidra.program.model.data.FileDataTypeManager; import ghidra.program.model.lang.*; @@ -1075,6 +1076,8 @@ public class TestEnv { privateWaitForSwingRunnables(); programManager.disposeOpenPrograms(); + ProgramBuilder.disposeAllBuilders(); + if (gp.getProject() == null) { throw new IllegalStateException("The TestEnv's GhidraProject has already been closed!"); } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/test/ToyProgramBuilder.java b/Ghidra/Features/Base/src/main/java/ghidra/test/ToyProgramBuilder.java index c370d82a95..6f0e7b8d89 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/test/ToyProgramBuilder.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/test/ToyProgramBuilder.java @@ -34,18 +34,11 @@ public class ToyProgramBuilder extends ProgramBuilder { private List
definedInstrAddresses; /** - * Construct toy program builder using specified toy language - * @param name program name - * @param languageName toy language ID (note: only builder variant supports all instructions) - * @param consumer program consumer (if null this builder will be used as consumer and must be disposed to release program) - * @throws Exception + * Default toy program using the default big endian language. + * @throws Exception if there are any exceptions */ - public ToyProgramBuilder(String name, String languageName, Object consumer) throws Exception { - super(name, checkLanguageName(languageName), consumer); - Program program = getProgram(); - addrFactory = program.getAddressFactory(); - defaultSpace = addrFactory.getDefaultAddressSpace(); - definedInstrAddresses = new ArrayList<>(); + public ToyProgramBuilder() throws Exception { + this("TestProgram", true); } /** @@ -53,7 +46,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * This builder will be the program consumer and must be disposed * @param name program name * @param bigEndian language endianness - * @throws Exception + * @throws Exception if there are any exceptions */ public ToyProgramBuilder(String name, boolean bigEndian) throws Exception { this(name, bigEndian, false, null); @@ -64,8 +57,9 @@ public class ToyProgramBuilder extends ProgramBuilder { * This builder will be the program consumer and must be disposed * @param name program name * @param bigEndian language endianness - * @param consumer program consumer (if null this builder will be used as consumer and must be disposed to release program) - * @throws Exception + * @param consumer program consumer (if null this builder will be used as consumer and must be + * disposed to release program) + * @throws Exception if there are any exceptions */ public ToyProgramBuilder(String name, boolean bigEndian, Object consumer) throws Exception { this(name, bigEndian, false, consumer); @@ -76,8 +70,10 @@ public class ToyProgramBuilder extends ProgramBuilder { * This builder will be the program consumer and must be disposed * @param name program name * @param bigEndian language endianness - * @param consumer program consumer (if null this builder will be used as consumer and must be disposed to release program) - * @throws Exception + * @param wordAligned true if word aligned + * @param consumer program consumer (if null this builder will be used as consumer and must be + * disposed to release program) + * @throws Exception if there are any exceptions */ public ToyProgramBuilder(String name, boolean bigEndian, boolean wordAligned, Object consumer) throws Exception { @@ -95,13 +91,6 @@ public class ToyProgramBuilder extends ProgramBuilder { return bigEndian ? TOY_LANGUAGE_ID_BE : TOY_LANGUAGE_ID_LE; } - private static String checkLanguageName(String languageName) { - if (!languageName.startsWith(_TOY_LANGUAGE_PREFIX)) { - throw new IllegalArgumentException("Toy language required"); - } - return languageName; - } - /** * Get address in default ram space * @param offset address offset @@ -190,7 +179,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add NOP instruction bytes of specified byte length * @param offset instruction address offset * @param length length of NOP instruction in bytes - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesNOP(long offset, int length) throws MemoryAccessException { addBytesNOP(toHex(offset), length); @@ -200,7 +189,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add NOP instruction bytes of specified byte length * @param addr instruction address * @param length length of NOP instruction in bytes - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesNOP(String addr, int length) throws MemoryAccessException { if (length == 1) { @@ -224,7 +213,7 @@ public class ToyProgramBuilder extends ProgramBuilder { /** * Add simple fall-through (consumes 2-bytes) * @param offset instruction address offset - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesFallthrough(long offset) throws MemoryAccessException { addBytesFallthrough(toHex(offset)); @@ -233,7 +222,7 @@ public class ToyProgramBuilder extends ProgramBuilder { /** * Add simple fall-through (consumes 2-bytes) * @param addr instruction address - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesFallthrough(String addr) throws MemoryAccessException { addInstructionWords(addr(addr), (short) 0xd100); // or r0,r0,r0 @@ -244,7 +233,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * @param offset instruction address offset * @param srcRegIndex source register index (0..15) * @param destRegIndex destination register index (contained indirect memory address) (0..15) - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesStore(long offset, int srcRegIndex, int destRegIndex) throws MemoryAccessException { @@ -256,7 +245,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * @param addr instruction address * @param srcRegIndex source register index (0..15) * @param destRegIndex destination register index (contained indirect memory address) (0..15) - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesStore(String addr, int srcRegIndex, int destRegIndex) throws MemoryAccessException { @@ -269,7 +258,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * @param offset instruction address offset * @param srcRegIndex source register index (contained indirect memory address) (0..15) * @param destRegIndex destination register index (0..15) - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesLoad(long offset, int srcRegIndex, int destRegIndex) throws MemoryAccessException { @@ -281,7 +270,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * @param addr instruction address * @param srcRegIndex source register index (contained indirect memory address) (0..15) * @param destRegIndex destination register index (0..15) - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesLoad(String addr, int srcRegIndex, int destRegIndex) throws MemoryAccessException { @@ -293,7 +282,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add move immediate instruction (consumes 2-bytes) * @param offset instruction offset * @param imm immediate byte value - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesMoveImmediate(long offset, short imm) throws MemoryAccessException { addBytesMoveImmediate(toHex(offset), imm); @@ -303,7 +292,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add move immediate instruction (consumes 2-bytes) * @param addr instruction address * @param imm immediate byte value - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesMoveImmediate(String addr, short imm) throws MemoryAccessException { addInstructionWords(addr(addr), (short) ((imm & 0x700) << 4 | (imm & 0xff))); // imm r0,# @@ -313,7 +302,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add simple fall-through which sets noflow context value on next instruction (consumes 2-bytes) * @param offset instruction address offset * @param ctxVal context value (0-15) - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesFallthroughSetNoFlowContext(long offset, int ctxVal) throws MemoryAccessException { @@ -324,7 +313,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add simple fall-through which sets noflow context value on next instruction (consumes 2-bytes) * @param addr instruction address * @param ctxVal context value (0-15) - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesFallthroughSetNoFlowContext(String addr, int ctxVal) throws MemoryAccessException { @@ -336,7 +325,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * @param offset instruction address offset * @param ctxVal context value (0-15) * @param target context target address offset - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesFallthroughSetNoFlowContext(long offset, int ctxVal, long target) throws MemoryAccessException { @@ -348,7 +337,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * @param addr instruction address * @param ctxVal context value (0-15) * @param targetAddr context target address - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesFallthroughSetNoFlowContext(String addr, int ctxVal, String targetAddr) throws MemoryAccessException { @@ -362,7 +351,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add simple fall-through which sets flowing context value on next instruction (consumes 2-bytes) * @param offset instruction address offset * @param ctxVal context value (0-15) - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesFallthroughSetFlowContext(long offset, int ctxVal) throws MemoryAccessException { @@ -373,7 +362,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add simple fall-through which sets flowing context value on next instruction (consumes 2-bytes) * @param addr instruction address * @param ctxVal context value (0-15) - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesFallthroughSetFlowContext(String addr, int ctxVal) throws MemoryAccessException { @@ -384,7 +373,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add call (consumes 2-bytes) * @param offset instruction address offset * @param dest call destination offset - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesCall(long offset, long dest) throws MemoryAccessException { addBytesCall(toHex(offset), toHex(dest)); @@ -394,7 +383,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add call (consumes 2-bytes) * @param offset instruction address offset * @param dest call destination offset - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesCall(String offset, long dest) throws MemoryAccessException { addBytesCall(offset, toHex(dest)); @@ -404,7 +393,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add call (consumes 2-bytes) * @param addr instruction address * @param destAddr call destination address - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesCall(String addr, String destAddr) throws MemoryAccessException { Address address = addr(addr); @@ -417,7 +406,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add call w/ delayslot (consumes 4-bytes) * @param offset instruction address offset * @param dest call destination offset - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesCallWithDelaySlot(long offset, long dest) throws MemoryAccessException { addBytesCallWithDelaySlot(toHex(offset), toHex(dest)); @@ -427,7 +416,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add call w/ delayslot (consumes 4-bytes) * @param addr instruction address * @param destAddr call destination address - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesCallWithDelaySlot(String addr, String destAddr) throws MemoryAccessException { @@ -441,7 +430,7 @@ public class ToyProgramBuilder extends ProgramBuilder { /** * Add terminal/return (consumes 2-bytes) * @param offset instruction address offset - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesReturn(long offset) throws MemoryAccessException { addBytesReturn(toHex(offset)); @@ -450,7 +439,7 @@ public class ToyProgramBuilder extends ProgramBuilder { /** * Add terminal/return (consumes 2-bytes) * @param addr instruction address - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesReturn(String addr) throws MemoryAccessException { addInstructionWords(addr(addr), (short) 0xf400); // ret @@ -460,7 +449,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add branch (consumes 2-bytes) * @param offset address offset * @param dest call destination offset - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesBranch(long offset, long dest) throws MemoryAccessException { addBytesBranch(toHex(offset), toHex(dest)); @@ -470,7 +459,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add branch (consumes 2-bytes) * @param addr instruction address offset * @param destAddr call destination address - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesBranch(String addr, String destAddr) throws MemoryAccessException { Address address = addr(addr); @@ -483,7 +472,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add branch (consumes 2-bytes) * @param offset instruction address offset * @param dest call destination offset - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesBranchConditional(long offset, long dest) throws MemoryAccessException { addBytesBranchConditional(toHex(offset), toHex(dest)); @@ -493,7 +482,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add branch (consumes 2-bytes) * @param addr instruction address * @param destAddr call destination address - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesBranchConditional(String addr, String destAddr) throws MemoryAccessException { @@ -506,7 +495,7 @@ public class ToyProgramBuilder extends ProgramBuilder { /** * Add conditional skip (consumes 2-bytes) * @param offset instruction address offset - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesSkipConditional(long offset) throws MemoryAccessException { addBytesSkipConditional(toHex(offset)); @@ -515,7 +504,7 @@ public class ToyProgramBuilder extends ProgramBuilder { /** * Add conditional skip (consumes 2-bytes) * @param addr instruction address - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesSkipConditional(String addr) throws MemoryAccessException { Address address = addr(addr); @@ -526,7 +515,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add branch w/ delay slot (consumes 4-bytes) * @param offset instruction address offset * @param dest call destination offset - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesBranchWithDelaySlot(long offset, long dest) throws MemoryAccessException { addBytesBranchWithDelaySlot(toHex(offset), toHex(dest)); @@ -536,7 +525,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add branch w/ delay slot (consumes 4-bytes) * @param addr instruction address * @param destAddr call destination address - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesBranchWithDelaySlot(String addr, String destAddr) throws MemoryAccessException { @@ -551,7 +540,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add COP instruction for exercising nfctx context (consumes 2-bytes). Location will not be added to * defined instruction address list. * @param offset instruction address offset - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesCopInstruction(long offset) throws MemoryAccessException { addBytesCopInstruction(toHex(offset)); @@ -561,7 +550,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add COP instruction for exercising nfctx context (consumes 2-bytes). Location will not be added to * defined instruction address list. * @param addr instruction address - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesCopInstruction(String addr) throws MemoryAccessException { addInstructionWords(addr(addr), (short) 0xda00); @@ -571,7 +560,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add BAD instruction (consumes 2-bytes). Location will not be added to * defined instruction address list. * @param offset bad instruction address offset - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesBadInstruction(long offset) throws MemoryAccessException { addBytesBadInstruction(toHex(offset)); @@ -581,7 +570,7 @@ public class ToyProgramBuilder extends ProgramBuilder { * Add BAD instruction (consumes 2-bytes). Location will not be added to * defined instruction address list. * @param addr bad instruction address - * @throws MemoryAccessException + * @throws MemoryAccessException shouldn't happen */ public void addBytesBadInstruction(String addr) throws MemoryAccessException { // do not add to definedInstrAddresses diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/data/DataReferencesTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/data/DataReferencesTest.java index ef14e881bb..ee10a2a662 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/data/DataReferencesTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/data/DataReferencesTest.java @@ -48,10 +48,6 @@ public class DataReferencesTest extends AbstractGhidraHeadedIntegrationTest { private TestEnv env; private PluginTool tool; - /** - * Sets up the fixture, for example, open a network connection. - * This method is called before a test is executed. - */ @Before public void setUp() throws Exception { env = new TestEnv(); @@ -81,7 +77,6 @@ public class DataReferencesTest extends AbstractGhidraHeadedIntegrationTest { @After public void tearDown() { - env.release(program); env.dispose(); } diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/AbstractCreateArchiveTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/AbstractCreateArchiveTest.java index c5cb669cf7..7d62186b67 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/AbstractCreateArchiveTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/AbstractCreateArchiveTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -39,8 +39,7 @@ import ghidra.program.database.ProgramDB; import ghidra.program.model.data.*; import ghidra.program.model.data.StandAloneDataTypeManager.LanguageUpdateOption; import ghidra.program.model.lang.*; -import ghidra.test.AbstractGhidraHeadedIntegrationTest; -import ghidra.test.TestEnv; +import ghidra.test.*; import ghidra.util.InvalidNameException; import ghidra.util.Msg; import ghidra.util.task.TaskMonitor; @@ -57,7 +56,7 @@ public abstract class AbstractCreateArchiveTest extends AbstractGhidraHeadedInte protected TreeModelModCounter treeModelModListener; protected ProgramDB buildProgram() throws Exception { - ProgramBuilder builder = new ProgramBuilder("notepad", ProgramBuilder._TOY, this); + ProgramBuilder builder = new ToyProgramBuilder(); builder.createMemory(".text", "0x1001000", 0x6600); builder.createMemory(".data", "0x1008000", 0x600); @@ -242,7 +241,6 @@ public abstract class AbstractCreateArchiveTest extends AbstractGhidraHeadedInte // this handles the save changes dialog and potential analysis dialogs closeAllWindows(); - env.release(program); env.dispose(); } diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/ArchiveRemappedHeadedTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/ArchiveRemappedHeadedTest.java index ef27f17e81..0dc54260ae 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/ArchiveRemappedHeadedTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/ArchiveRemappedHeadedTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,8 @@ import docking.action.DockingActionIf; import docking.widgets.tree.GTreeNode; import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin; import ghidra.app.plugin.core.datamgr.actions.UpdateSourceArchiveNamesAction; -import ghidra.app.plugin.core.datamgr.archive.*; +import ghidra.app.plugin.core.datamgr.archive.Archive; +import ghidra.app.plugin.core.datamgr.archive.DataTypeManagerHandler; import ghidra.app.plugin.core.datamgr.tree.*; import ghidra.app.services.DataTypeManagerService; import ghidra.app.services.ProgramManager; @@ -35,8 +36,7 @@ import ghidra.framework.plugintool.PluginTool; import ghidra.program.database.ProgramBuilder; import ghidra.program.database.ProgramDB; import ghidra.program.model.data.*; -import ghidra.test.AbstractGhidraHeadedIntegrationTest; -import ghidra.test.TestEnv; +import ghidra.test.*; import ghidra.util.task.TaskMonitor; import utilities.util.FileUtilities; @@ -111,7 +111,7 @@ public class ArchiveRemappedHeadedTest extends AbstractGhidraHeadedIntegrationTe } private ProgramDB buildProgram() throws Exception { - ProgramBuilder builder = new ProgramBuilder("notepad", ProgramBuilder._TOY, this); + ProgramBuilder builder = new ToyProgramBuilder(); return builder.getProgram(); } diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/ArchiveRemappedHeadlessTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/ArchiveRemappedHeadlessTest.java index d1205c6a3e..99a8d60ec0 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/ArchiveRemappedHeadlessTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/ArchiveRemappedHeadlessTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,6 +29,7 @@ import ghidra.program.database.ProgramBuilder; import ghidra.program.database.ProgramDB; import ghidra.program.model.data.DataTypeManager; import ghidra.test.AbstractGhidraHeadlessIntegrationTest; +import ghidra.test.ToyProgramBuilder; import ghidra.util.task.TaskMonitor; import utilities.util.FileUtilities; @@ -67,7 +68,7 @@ public class ArchiveRemappedHeadlessTest extends AbstractGhidraHeadlessIntegrati } private ProgramDB buildProgram() throws Exception { - ProgramBuilder builder = new ProgramBuilder("notepad", ProgramBuilder._TOY, this); + ProgramBuilder builder = new ToyProgramBuilder(); return builder.getProgram(); } diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/CreateArchive1Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/CreateArchive1Test.java index 6447169bab..6217db7569 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/CreateArchive1Test.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/CreateArchive1Test.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -164,7 +164,7 @@ public class CreateArchive1Test extends AbstractCreateArchiveTest { // verify that the archive was saved by opening it again and checking it has the right stuff. // create file to cause a name collision - File file = writeTempFile("MyArchive.gdt"); + writeTempFile("MyArchive.gdt"); int insertedCount = getTreeModelInsertedNodeCount(); Msg.trace(this, testName.getMethodName() + ":NODE COUNT: " + insertedCount); @@ -258,7 +258,7 @@ public class CreateArchive1Test extends AbstractCreateArchiveTest { // verify that the archive did not get saved to that name. // create file to cause a name collision - File file = writeTempFile("MyArchive.gdt"); + writeTempFile("MyArchive.gdt"); createNewArchive("MyArchive.gdt", false); diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/editor/EnumEditor1Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/editor/EnumEditor1Test.java index 5dafb35c15..663e65d5df 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/editor/EnumEditor1Test.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/editor/EnumEditor1Test.java @@ -60,7 +60,7 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest { tool.addPlugin(DataTypeManagerPlugin.class.getName()); plugin = getPlugin(tool, DataTypeManagerPlugin.class); - ToyProgramBuilder builder = new ToyProgramBuilder("notepad", true); + ToyProgramBuilder builder = new ToyProgramBuilder(); builder.addCategory(new CategoryPath(CategoryPath.ROOT, "Category1")); program = builder.getProgram(); @@ -620,7 +620,7 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest { Enum enummDt = createRedGreenBlueEnum(); DataTypeManager dtm = program.getListing().getDataTypeManager(); - enummDt = (Enum) enummDt.clone(dtm); + enummDt = enummDt.clone(dtm); edit(enummDt); @@ -641,7 +641,7 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest { Enum enummDt = createRedGreenBlueEnum(); DataTypeManager dtm = program.getListing().getDataTypeManager(); - enummDt = (Enum) enummDt.clone(dtm); + enummDt = enummDt.clone(dtm); edit(enummDt); @@ -695,7 +695,7 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest { Enum enummDt = createRedGreenBlueEnum(); DataTypeManager dtm = program.getListing().getDataTypeManager(); - enummDt = (Enum) enummDt.clone(dtm); + enummDt = enummDt.clone(dtm); edit(enummDt); @@ -1204,7 +1204,7 @@ public class EnumEditor1Test extends AbstractGhidraHeadedIntegrationTest { private JTextField getTextField(Container container, String name) { Component[] c = container.getComponents(); for (Component element : c) { - if ((element instanceof JTextField) && ((JTextField) element).getName().equals(name)) { + if ((element instanceof JTextField) && element.getName().equals(name)) { return (JTextField) element; } if (element instanceof Container) { diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/editor/EnumEditor2Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/editor/EnumEditor2Test.java index 1b466e7bda..0ab514cca6 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/editor/EnumEditor2Test.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/editor/EnumEditor2Test.java @@ -47,7 +47,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest { @Before public void setUp() throws Exception { - ToyProgramBuilder builder = new ToyProgramBuilder("notepad", true); + ToyProgramBuilder builder = new ToyProgramBuilder(); builder.addCategory(new CategoryPath(CategoryPath.ROOT, "Category1")); program = builder.getProgram(); @@ -804,7 +804,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest { private JTextField getTextField(Container container, String name) { Component[] c = container.getComponents(); for (Component element : c) { - if ((element instanceof JTextField) && ((JTextField) element).getName().equals(name)) { + if ((element instanceof JTextField) && element.getName().equals(name)) { return (JTextField) element; } if (element instanceof Container) { @@ -880,7 +880,7 @@ public class EnumEditor2Test extends AbstractGhidraHeadedIntegrationTest { Component[] c = container.getComponents(); for (Component element : c) { if (element instanceof JLabel) { - if (name.equals(((JLabel) element).getName())) { + if (name.equals(element.getName())) { return ((JLabel) element).getText(); } } diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/navigation/GoToAddressLabelPluginWithNamespaceTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/navigation/GoToAddressLabelPluginWithNamespaceTest.java index 3c7993cc6b..4fd657b5ae 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/navigation/GoToAddressLabelPluginWithNamespaceTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/navigation/GoToAddressLabelPluginWithNamespaceTest.java @@ -185,7 +185,7 @@ public class GoToAddressLabelPluginWithNamespaceTest extends AbstractGhidraHeade } private void buildProgram() throws Exception { - ToyProgramBuilder builder = new ToyProgramBuilder("Test", false); + ToyProgramBuilder builder = new ToyProgramBuilder(); builder.createMemory("Block1", "0x1000", 1000); diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/LabelFieldFactoryTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/LabelFieldFactoryTest.java index 0d7536f1cd..33fee42dad 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/LabelFieldFactoryTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/LabelFieldFactoryTest.java @@ -60,7 +60,7 @@ public class LabelFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest { } private ProgramDB buildProgram() throws Exception { - ToyProgramBuilder builder = new ToyProgramBuilder("notepad", true); + ToyProgramBuilder builder = new ToyProgramBuilder(); builder.createMemory(".text", "1001000", 0x4000); builder.addBytesNOP("1002000", 6); diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/PlateFieldFactoryTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/PlateFieldFactoryTest.java index 69d01f6de5..04ff878530 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/PlateFieldFactoryTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/PlateFieldFactoryTest.java @@ -75,7 +75,7 @@ public class PlateFieldFactoryTest extends AbstractGhidraHeadedIntegrationTest { } private ProgramDB buildProgram() throws Exception { - ToyProgramBuilder builder = new ToyProgramBuilder("notepad", true); + ToyProgramBuilder builder = new ToyProgramBuilder(); builder.createMemory(".text", "0x1001000", 0x6600); builder.createEntryPoint("0x1001100", "entry"); diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/PostCommentFieldFactoryTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/PostCommentFieldFactoryTest.java index d0a685590f..66ec79ce99 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/PostCommentFieldFactoryTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/PostCommentFieldFactoryTest.java @@ -58,7 +58,7 @@ public class PostCommentFieldFactoryTest extends AbstractGhidraHeadedIntegration } private ProgramDB buildProgram() throws Exception { - ToyProgramBuilder builder = new ToyProgramBuilder("notepad", true); + ToyProgramBuilder builder = new ToyProgramBuilder(); builder.createMemory(".text", "0x1001000", 0x10000); builder.createEmptyFunction(null, "1001000", 1000, null); diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/PreCommentFieldFactoryTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/PreCommentFieldFactoryTest.java index 1503faa679..0447d38951 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/PreCommentFieldFactoryTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/PreCommentFieldFactoryTest.java @@ -61,7 +61,7 @@ public class PreCommentFieldFactoryTest extends AbstractGhidraHeadedIntegrationT } private ProgramDB buildProgram() throws Exception { - ToyProgramBuilder builder = new ToyProgramBuilder("notepad", true); + ToyProgramBuilder builder = new ToyProgramBuilder(); builder.createMemory(".text", "0x1001000", 0x6600); builder.createEmptyFunction(null, "1001000", 1000, null); builder.createReturnInstruction("1001000"); diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/RegisterFieldFactoryTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/RegisterFieldFactoryTest.java index c97a4e6a9c..0ff6f619ab 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/RegisterFieldFactoryTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/util/viewer/field/RegisterFieldFactoryTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,10 +40,6 @@ public class RegisterFieldFactoryTest extends AbstractGhidraHeadedIntegrationTes private CodeBrowserPlugin cb; private Program program; - public RegisterFieldFactoryTest() { - super(); - } - @Before public void setUp() throws Exception { @@ -57,7 +53,7 @@ public class RegisterFieldFactoryTest extends AbstractGhidraHeadedIntegrationTes } private ProgramDB buildProgram() throws Exception { - ToyProgramBuilder builder = new ToyProgramBuilder("notepad", true); + ToyProgramBuilder builder = new ToyProgramBuilder(); builder.createMemory(".text", "0x1001000", 0x6600); builder.createEmptyFunction(null, "1001000", 40, null); builder.createReturnInstruction("1001000"); @@ -115,7 +111,7 @@ public class RegisterFieldFactoryTest extends AbstractGhidraHeadedIntegrationTes if (reg.isProcessorContext() || reg.hasChildren()) { continue; } - nonContextRegs.add(reg); + nonContextRegs.add(reg); } return nonContextRegs; } diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/framework/project/AddViewToProjectTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/framework/project/AddViewToProjectTest.java index 3cea12ad16..fb4ad6c1a0 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/framework/project/AddViewToProjectTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/framework/project/AddViewToProjectTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -101,7 +101,7 @@ public class AddViewToProjectTest extends AbstractGhidraHeadlessIntegrationTest // make sure we have projects to use as the project view... Project project = ProjectTestUtils.getProject(DIRECTORY_NAME, PROJECT_VIEW1); try { - ToyProgramBuilder builder = new ToyProgramBuilder("Test", true); + ToyProgramBuilder builder = new ToyProgramBuilder(); DomainFolder rootFolder = project.getProjectData().getRootFolder(); rootFolder.createFile("Test", builder.getProgram(), TaskMonitor.DUMMY); builder.dispose(); diff --git a/Ghidra/Features/Base/src/test/java/ghidra/features/base/replace/SearchAndReplaceDialogTest.java b/Ghidra/Features/Base/src/test/java/ghidra/features/base/replace/SearchAndReplaceDialogTest.java index 8a596a6f89..b34b9b0a4a 100644 --- a/Ghidra/Features/Base/src/test/java/ghidra/features/base/replace/SearchAndReplaceDialogTest.java +++ b/Ghidra/Features/Base/src/test/java/ghidra/features/base/replace/SearchAndReplaceDialogTest.java @@ -48,7 +48,7 @@ public class SearchAndReplaceDialogTest extends AbstractGhidraHeadedIntegrationT SearchAndReplacePlugin plugin = getPlugin(tool, SearchAndReplacePlugin.class); - ToyProgramBuilder builder = new ToyProgramBuilder("Test", true); + ToyProgramBuilder builder = new ToyProgramBuilder(); builder.createLabel("0x100", "myFooLabel"); builder.createLabel("0x200", "myBarLabel"); program = builder.getProgram(); diff --git a/Ghidra/Features/Base/src/test/java/ghidra/program/util/DefinedDataIteratorTest.java b/Ghidra/Features/Base/src/test/java/ghidra/program/util/DefinedDataIteratorTest.java index 7169507691..94ca9ba0c4 100644 --- a/Ghidra/Features/Base/src/test/java/ghidra/program/util/DefinedDataIteratorTest.java +++ b/Ghidra/Features/Base/src/test/java/ghidra/program/util/DefinedDataIteratorTest.java @@ -49,7 +49,7 @@ public class DefinedDataIteratorTest extends AbstractGhidraHeadlessIntegrationTe @Before public void setUp() throws Exception { - builder = new ToyProgramBuilder("DefinedDataIteratorTests", false); + builder = new ToyProgramBuilder(); program = builder.getProgram(); dtm = program.getDataTypeManager(); @@ -80,8 +80,8 @@ public class DefinedDataIteratorTest extends AbstractGhidraHeadlessIntegrationTe builder.createString("0x10", "test1", StandardCharsets.UTF_8, true, stringDT); builder.applyFixedLengthDataType("0x100", struct1DT, struct1DT.getLength()); - List list = CollectionUtils.asList((Iterable) - DefinedDataIterator.byDataType(program, dt -> dt instanceof IntegerDataType)); + List list = CollectionUtils.asList((Iterable) DefinedDataIterator + .byDataType(program, dt -> dt instanceof IntegerDataType)); assertTrue(list.get(0).getAddress().getOffset() == 0x0); assertTrue(list.get(1).getAddress().getOffset() == 0x100); @@ -137,8 +137,8 @@ public class DefinedDataIteratorTest extends AbstractGhidraHeadlessIntegrationTe builder.applyFixedLengthDataType("0x20", intDT, intTD.getLength()); // iterating by data type ignores typedefs, so we should get all 3 ints - List list = CollectionUtils.asList((Iterable) - DefinedDataIterator.byDataType(program, dt -> dt instanceof IntegerDataType)); + List list = CollectionUtils.asList((Iterable) DefinedDataIterator + .byDataType(program, dt -> dt instanceof IntegerDataType)); assertEquals(3, list.size()); diff --git a/Ghidra/Features/Base/src/test/java/ghidra/program/util/DefinedStringIteratorTest.java b/Ghidra/Features/Base/src/test/java/ghidra/program/util/DefinedStringIteratorTest.java index 531d028898..c98b9e96ce 100644 --- a/Ghidra/Features/Base/src/test/java/ghidra/program/util/DefinedStringIteratorTest.java +++ b/Ghidra/Features/Base/src/test/java/ghidra/program/util/DefinedStringIteratorTest.java @@ -49,7 +49,7 @@ public class DefinedStringIteratorTest extends AbstractGhidraHeadlessIntegration @Before public void setUp() throws Exception { - builder = new ToyProgramBuilder("DefinedStringIteratorTests", false); + builder = new ToyProgramBuilder(); program = builder.getProgram(); dtm = program.getDataTypeManager(); diff --git a/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/DecompilerTest.java b/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/DecompilerTest.java index 1044a1a4e8..5929ee6e97 100644 --- a/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/DecompilerTest.java +++ b/Ghidra/Features/Decompiler/src/test.slow/java/ghidra/app/plugin/core/decompile/DecompilerTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,7 +32,7 @@ public class DecompilerTest extends AbstractGhidraHeadedIntegrationTest { @Before public void setUp() throws Exception { - ToyProgramBuilder builder = new ToyProgramBuilder("notepad_decompiler", true); + ToyProgramBuilder builder = new ToyProgramBuilder(); builder.createMemory("test", "0x0", 2); builder.addBytesReturn(0x0); builder.createFunction("0x0"); diff --git a/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/VTMatchApplyFunctionSignatureTest.java b/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/VTMatchApplyFunctionSignatureTest.java index 3cd2e27172..f25a744353 100644 --- a/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/VTMatchApplyFunctionSignatureTest.java +++ b/Ghidra/Features/VersionTracking/src/test.slow/java/ghidra/feature/vt/api/VTMatchApplyFunctionSignatureTest.java @@ -222,7 +222,6 @@ public class VTMatchApplyFunctionSignatureTest extends AbstractGhidraHeadedInteg f2.setSignatureSource(SourceType.ANALYSIS); }); - p.addConsumer(this); return p; } finally { @@ -240,7 +239,6 @@ public class VTMatchApplyFunctionSignatureTest extends AbstractGhidraHeadedInteg builder.createEmptyFunction(null, "0x10938", 0x10, DataType.DEFAULT); - p.addConsumer(this); return p; } finally { diff --git a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/framework/main/LaunchUrlInToolTest.java b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/framework/main/LaunchUrlInToolTest.java index 13a7d86b66..1c2ecba261 100644 --- a/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/framework/main/LaunchUrlInToolTest.java +++ b/Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/framework/main/LaunchUrlInToolTest.java @@ -15,32 +15,47 @@ */ package ghidra.framework.main; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.io.File; import java.net.URL; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; -import org.junit.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; import docking.DialogComponentProvider; import docking.test.AbstractDockingTest; import ghidra.app.services.CodeViewerService; import ghidra.app.services.ProgramManager; import ghidra.framework.data.DomainFileProxy; -import ghidra.framework.model.*; +import ghidra.framework.model.DomainFolder; +import ghidra.framework.model.Project; +import ghidra.framework.model.ProjectLocator; +import ghidra.framework.model.ToolAssociationInfo; +import ghidra.framework.model.ToolServices; +import ghidra.framework.model.ToolTemplate; import ghidra.framework.plugintool.PluginTool; import ghidra.framework.protocol.ghidra.GhidraURL; import ghidra.framework.protocol.ghidra.Handler; -import ghidra.program.database.*; +import ghidra.program.database.ProgramContentHandler; +import ghidra.program.database.ProgramDB; import ghidra.program.model.address.Address; import ghidra.program.model.address.AddressSpace; import ghidra.program.model.listing.Program; -import ghidra.program.model.symbol.*; +import ghidra.program.model.symbol.Namespace; +import ghidra.program.model.symbol.SourceType; +import ghidra.program.model.symbol.SymbolTable; import ghidra.program.util.ProgramLocation; import ghidra.server.remote.ServerTestUtil; -import ghidra.test.*; +import ghidra.test.AbstractGhidraHeadedIntegrationTest; +import ghidra.test.TestEnv; +import ghidra.test.ToyProgramBuilder; import ghidra.util.exception.AssertException; import ghidra.util.task.TaskMonitor; import utilities.util.FileUtilities; @@ -72,6 +87,7 @@ public class LaunchUrlInToolTest extends AbstractGhidraHeadedIntegrationTest { env.getFrontEndTool(); program = (ProgramDB) buildProgram(); + Project project = env.getProject(); DomainFolder rootFolder = project.getProjectData().getRootFolder(); rootFolder.createFile("Test", program, TaskMonitor.DUMMY); @@ -84,7 +100,7 @@ public class LaunchUrlInToolTest extends AbstractGhidraHeadedIntegrationTest { } private Program buildProgram() throws Exception { - ToyProgramBuilder builder = new ToyProgramBuilder(FILENAME, true, ProgramBuilder._TOY); + ToyProgramBuilder builder = new ToyProgramBuilder(FILENAME, true); builder.createMemory("test1", "0x1001000", 0xb000); builder.addBytesFallthrough("0x1001010"); builder.addBytesFallthrough("0x1001020"); diff --git a/Ghidra/Test/IntegrationTest/src/test/java/ghidra/graph/program/AbstractBlockGraphTest.java b/Ghidra/Test/IntegrationTest/src/test/java/ghidra/graph/program/AbstractBlockGraphTest.java index 064f8cfe94..1e031ccb89 100644 --- a/Ghidra/Test/IntegrationTest/src/test/java/ghidra/graph/program/AbstractBlockGraphTest.java +++ b/Ghidra/Test/IntegrationTest/src/test/java/ghidra/graph/program/AbstractBlockGraphTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -76,7 +76,7 @@ public class AbstractBlockGraphTest extends AbstractGhidraHeadedIntegrationTest protected void openProgram() throws Exception { - builder = new ToyProgramBuilder("sample", true); + builder = new ToyProgramBuilder(); builder.createMemory("caller", "0x01002200", 8); builder.createMemory("simple", "0x01002239", 8); builder.createMemory("not_graphed", "0x01002300", 8); diff --git a/Ghidra/Test/IntegrationTest/src/test/java/ghidra/graph/program/AbstractDataReferenceGraphTest.java b/Ghidra/Test/IntegrationTest/src/test/java/ghidra/graph/program/AbstractDataReferenceGraphTest.java index 54bf33db2b..e981d7caba 100644 --- a/Ghidra/Test/IntegrationTest/src/test/java/ghidra/graph/program/AbstractDataReferenceGraphTest.java +++ b/Ghidra/Test/IntegrationTest/src/test/java/ghidra/graph/program/AbstractDataReferenceGraphTest.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -74,7 +74,7 @@ public class AbstractDataReferenceGraphTest extends AbstractGhidraHeadedIntegrat protected void openProgram() throws Exception { - builder = new ToyProgramBuilder("sample", true); + builder = new ToyProgramBuilder(); builder.createMemory("data", "0x01000000", 64); builder.createMemory("caller", "0x01002200", 8);