Package ghidra.test

Class ProjectTestUtils

java.lang.Object
ghidra.test.ProjectTestUtils

public class ProjectTestUtils extends Object
Ghidra framework and program test utilities
  • Constructor Details

    • ProjectTestUtils

      public ProjectTestUtils()
  • Method Details

    • getProject

      public static Project getProject(String directory, String name) throws IOException, LockException
      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 project
      name - name of the project
      Returns:
      the project
      Throws:
      IOException - if there was a problem creating the project
      LockException - if the project is already open
      IllegalArgumentException - if the name has illegal characters such that a URL could not be created
    • deleteProject

      public static boolean deleteProject(String directory, String name)
      Remove entire project. Note: this will not remove the parent directory 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 spec
      folder - 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 invalid
      CancelledException - if the opening is cancelled
      LanguageNotFoundException - if the language cannot be found
      IOException - if there is an exception creating the program or domain file
    • getTool

      public static PluginTool getTool(Project project, String toolName)
      Launch a tool.
      Parameters:
      project - the project to which the tool belongs
      toolName - 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

      public static ToolTemplate saveTool(Project project, PluginTool tool)
      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

      public static boolean deleteTool(Project project, String toolName)
      Remove the specified tool if it exists.
      Parameters:
      project - the project
      toolName - the tool name
      Returns:
      true if it existed and was removed from the local tool chest.