Package ghidra.test

Class TestProgramManager

java.lang.Object
ghidra.test.TestProgramManager

public class TestProgramManager extends 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 Details

    • TestProgramManager

      public TestProgramManager()
  • Method Details

    • add

      public void add(Program p)
    • getProgram

      public ProgramDB getProgram(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 Set<Program> getOpenPrograms()
    • addOpenProgram

      public void addOpenProgram(Program program)
    • release

      public void release(Program program)
    • 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 name
      program - program object
      replace - if true any existing cached database with the same name will be replaced
      monitor - task monitor
      Throws:
      IOException - if the database cannot be created
      DuplicateNameException - if already cached
      CancelledException - if the save operation is cancelled
    • isProgramCached

      public boolean isProgramCached(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(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, Object consumer)
    • 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 restored
      programName - 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 inserted
      programName - the name of the program zip file without the ".gzf" extension.
      Returns:
      the file
      Throws:
      FileNotFoundException - if the file cannot be found
    • setDbTestDir

      public static void setDbTestDir(File newDbTestDir)
    • getDbTestDir

      public static File getDbTestDir()
    • cleanDbTestDir

      public static void cleanDbTestDir()