Package ghidra.test
Class TestProgramManager
- java.lang.Object
-
- ghidra.test.TestProgramManager
-
public class TestProgramManager extends java.lang.Object
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
Constructors Constructor Description TestProgramManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Program p)
void
addOpenProgram(Program program)
DomainFile
addProgramToProject(DomainFolder folder, java.lang.String programName)
Copies the specified program zip file to the JUnit test project's folder.DomainFile
addProgramToProject(Project project, java.lang.String programName)
Copies the specified program zip file to the JUnit test project's root folder.void
disposeOpenPrograms()
static java.io.File
getDbTestDir()
java.util.Set<Program>
getOpenPrograms()
ProgramDB
getProgram(java.lang.String progName)
Open a read-only test program from the test data directory.boolean
isProgramCached(java.lang.String name)
Determine if the specified program already exists with the program cachevoid
markAllProgramsAsUnchanged()
void
release(Program program)
void
removeAllConsumersExcept(Program p, java.lang.Object consumer)
void
removeFromProgramCache(java.lang.String name)
Remove specified program from cachevoid
saveToCache(java.lang.String progName, ProgramDB program, boolean replace, TaskMonitor monitor)
Save a program to the cached program store.static void
setDbTestDir(java.io.File newDbTestDir)
-
-
-
Method Detail
-
add
public void add(Program p)
-
getProgram
public ProgramDB getProgram(java.lang.String progName)
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
public java.util.Set<Program> getOpenPrograms()
-
addOpenProgram
public void addOpenProgram(Program program)
-
release
public void release(Program program)
-
saveToCache
public void saveToCache(java.lang.String progName, ProgramDB program, boolean replace, TaskMonitor monitor) throws java.io.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:
DuplicateNameException
- if already cachedjava.io.IOException
CancelledException
-
isProgramCached
public boolean isProgramCached(java.lang.String name)
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
public void removeFromProgramCache(java.lang.String name)
Remove specified program from cache- Parameters:
name
- the program name
-
disposeOpenPrograms
public void disposeOpenPrograms()
-
markAllProgramsAsUnchanged
public void markAllProgramsAsUnchanged()
-
removeAllConsumersExcept
public void removeAllConsumersExcept(Program p, java.lang.Object consumer)
-
addProgramToProject
public DomainFile addProgramToProject(Project project, java.lang.String programName) throws java.io.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.- Throws:
java.io.FileNotFoundException
-
addProgramToProject
public DomainFile addProgramToProject(DomainFolder folder, java.lang.String programName) throws java.io.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.- Throws:
java.io.FileNotFoundException
-
setDbTestDir
public static void setDbTestDir(java.io.File newDbTestDir)
-
getDbTestDir
public static java.io.File getDbTestDir()
-
-