Package ghidra.test

Class 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 Detail

      • TestProgramManager

        public TestProgramManager()
    • 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 name
        program - program object
        replace - if true any existing cached database with the same name will be replaced
        monitor - task monitor
        Throws:
        java.io.IOException - if the database cannot be created
        DuplicateNameException - if already cached
        CancelledException - if the save operation is cancelled
      • 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 restored
        programName - the name of the program zip file without the ".gzf" extension
        Returns:
        the file
        Throws:
        java.io.FileNotFoundException - if the file cannot be found
      • 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 inserted
        programName - the name of the program zip file without the ".gzf" extension.
        Returns:
        the file
        Throws:
        java.io.FileNotFoundException - if the file cannot be found
      • setDbTestDir

        public static void setDbTestDir​(java.io.File newDbTestDir)
      • getDbTestDir

        public static java.io.File getDbTestDir()