Package ghidra.test
Class TestProgramManager
java.lang.Object
ghidra.test.TestProgramManager
A class to handle locating, opening and caching (within a JVM) programs in the test
environment. (This code was formerly inside of TestEnv.)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addOpenProgram
(Program program) addProgramToProject
(DomainFolder folder, String programName) Copies the specified program zip file to the JUnit test project's folder.addProgramToProject
(Project project, String programName) Copies the specified program zip file to the JUnit test project's root folder.static void
void
static File
getProgram
(String progName) Open a read-only test program from the test data directory.boolean
isProgramCached
(String name) Determine if the specified program already exists with the program cachevoid
void
void
removeAllConsumersExcept
(Program p, Object consumer) void
removeFromProgramCache
(String name) Remove specified program from cachevoid
saveToCache
(String progName, ProgramDB program, boolean replace, TaskMonitor monitor) Save a program to the cached program store.static void
setDbTestDir
(File newDbTestDir)
-
Constructor Details
-
TestProgramManager
public TestProgramManager()
-
-
Method Details
-
add
-
getProgram
Open a read-only test program from the test data directory. This program must be released prior to disposing this test environment. NOTE: Some tests rely on this method returning null when file does not yet exist within the resource area (e.g., test binaries for P-Code Tests)- Parameters:
progName
- name of program database within the test data directory.- Returns:
- program or null if program file not found
-
getOpenPrograms
-
addOpenProgram
-
release
-
saveToCache
public void saveToCache(String progName, ProgramDB program, boolean replace, TaskMonitor monitor) throws IOException, DuplicateNameException, CancelledException Save a program to the cached program store. A SaveAs will be performed on the program to its cached storage location.- Parameters:
progName
- program nameprogram
- program objectreplace
- if true any existing cached database with the same name will be replacedmonitor
- task monitor- Throws:
IOException
- if the database cannot be createdDuplicateNameException
- if already cachedCancelledException
- if the save operation is cancelled
-
isProgramCached
Determine if the specified program already exists with the program cache- Parameters:
name
- the program name- Returns:
- true if the specified program already exists with the program cache
-
removeFromProgramCache
Remove specified program from cache- Parameters:
name
- the program name
-
disposeOpenPrograms
public void disposeOpenPrograms() -
markAllProgramsAsUnchanged
public void markAllProgramsAsUnchanged() -
removeAllConsumersExcept
-
addProgramToProject
public DomainFile addProgramToProject(Project project, String programName) throws FileNotFoundException Copies the specified program zip file to the JUnit test project's root folder. This means that the program will appear in the FrontEndTool as part of the project. That is the only reason to use this method vice openProgram().- Parameters:
project
- the project into which the file will be restoredprogramName
- the name of the program zip file without the ".gzf" extension- Returns:
- the file
- Throws:
FileNotFoundException
- if the file cannot be found
-
addProgramToProject
public DomainFile addProgramToProject(DomainFolder folder, String programName) throws FileNotFoundException Copies the specified program zip file to the JUnit test project's folder. This means that the program will appear in the FrontEndTool as part of the project. That is the only reason to use this method vice openProgram().- Parameters:
folder
- the folder into which the domain file will be insertedprogramName
- the name of the program zip file without the ".gzf" extension.- Returns:
- the file
- Throws:
FileNotFoundException
- if the file cannot be found
-
setDbTestDir
-
getDbTestDir
-
cleanDbTestDir
public static void cleanDbTestDir()
-