Package ghidra.test
Class ProjectTestUtils
java.lang.Object
ghidra.test.ProjectTestUtils
Ghidra framework and program test utilities
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic DomainFile
createProgramFile
(Project proj, String progName, Language language, CompilerSpec compilerSpec, DomainFolder folder) Create an empty program file within the specified project folder.static boolean
deleteProject
(String directory, String name) Remove entire project.static boolean
deleteTool
(Project project, String toolName) Remove the specified tool if it exists.static Project
getProject
(String directory, String name) Open the project for the given directory and name.static PluginTool
Launch a tool.static ToolTemplate
saveTool
(Project project, PluginTool tool) Save a tool to the project tool chest.
-
Constructor Details
-
ProjectTestUtils
public ProjectTestUtils()
-
-
Method Details
-
getProject
Open the project for the given directory and name. If the project does not exist, create one. Only once instance of a given project may be open at any given point in time. Be sure to close the project if you will be re-opening.- Parameters:
directory
- directory for the projectname
- name of the project- Returns:
- the project
- Throws:
IOException
- if there was a problem creating the projectLockException
- if the project is already openIllegalArgumentException
- if the name has illegal characters such that a URL could not be created
-
deleteProject
Remove entire project. Note: this will not remove the parentdirectory
of the project.- Parameters:
directory
- directory of the project.name
- The name of the project to delete- Returns:
- True if the project was deleted.
-
createProgramFile
public static DomainFile createProgramFile(Project proj, String progName, Language language, CompilerSpec compilerSpec, DomainFolder folder) throws InvalidNameException, CancelledException, LanguageNotFoundException, IOException Create an empty program file within the specified project folder.- Parameters:
proj
- active project.progName
- name of program and domain file to be created.language
- a specified language, or 0 if it does not matter.compilerSpec
- the compiler specfolder
- domain folder within the specified project which the user has permission to write. If null, the root data folder will be used.- Returns:
- new domain file.
- Throws:
InvalidNameException
- if the filename is invalidCancelledException
- if the opening is cancelledLanguageNotFoundException
- if the language cannot be foundIOException
- if there is an exception creating the program or domain file
-
getTool
Launch a tool.- Parameters:
project
- the project to which the tool belongstoolName
- name of the tool to get from the active workspace. If null, launch a new empty tool in the active workspace.- Returns:
- the tool
-
saveTool
Save a tool to the project tool chest.- Parameters:
project
- The project which with the tool is associated.tool
- The tool to be saved- Returns:
- The tool template for the given tool.
-
deleteTool
Remove the specified tool if it exists.- Parameters:
project
- the projecttoolName
- the tool name- Returns:
- true if it existed and was removed from the local tool chest.
-