Package ghidra.test

Class AbstractProgramBasedTest


  • public abstract class AbstractProgramBasedTest
    extends AbstractGhidraHeadedIntegrationTest
    A convenience base class for creating tests that use the default tool and open a program. This class will create for you a tool, a TestEnv and will open the program specified by getProgramName().

    To use this class, you must call initialize() from your test or setUp method.

    Note: if you are loading a pre-existing program, then simply override getProgramName(). Alternatively, if you are building a program, then override getProgram() and return it there.

    • Field Detail

      • program NEW

        protected Program program
      • codeBrowser NEW

        protected ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin codeBrowser

Constructor Detail

  • Method Detail

    • getProgramName NEW

      protected java.lang.String getProgramName()
    • initialize NEW

      protected void initialize()
                         throws java.lang.Exception
      Throws:
      java.lang.Exception
    • getProgram NEW

      protected Program getProgram()
                            throws java.lang.Exception
      Override this method if you need to build your own program.
      Returns:
      the program to use for this test.
      Throws:
      java.lang.Exception
    • tearDown

      public void tearDown()
                    throws java.lang.Exception
      Throws:
      java.lang.Exception
    • assertCurrentAddress

      public void assertCurrentAddress​(Address expected)
    • addr

      public Address addr​(long offset)
    • addr

      public Address addr​(java.lang.String offset)
    • goTo

      public void goTo​(long offset)
    • goTo

      public void goTo​(java.lang.String offset)
    • range

      public AddressRange range​(long from,
                                long to)
    • showProvider

      public void showProvider​(java.lang.String name)
    • addrs

      public java.util.List<Address> addrs​(long... offsets)
    • toAddressSet

      public AddressSet toAddressSet​(long... offsets)
    • goTo

      public void goTo​(Address a)
    • createInProgram

      public <R> R createInProgram​(AbstractProgramBasedTest.ExceptionalFunction<Program,​R> f)
      Provides a convenient method for modifying the current program, handling the transaction logic and returning a new item as a result.
      Parameters:
      f - the function for modifying the program and creating the desired result
      Returns:
      the result