Class CSpecPrototypeTest
java.lang.Object
generic.test.AbstractGTest
generic.test.AbstractGenericTest
generic.test.AbstractGuiTest
docking.test.AbstractDockingTest
ghidra.test.AbstractGhidraHeadlessIntegrationTest
ghidra.test.compilers.support.CSpecPrototypeTest
CSpecPrototypeTest provides an abstract JUnit test implementation
for processor-specific and compiler-specific calling convention test cases.
Tests which extend this class must implement abstract functions to specify LANGUAGE_ID,
COMPILER_SPEC_ID, and CALLING_CONVENTION.
An optional list of function names that contain errors can be passed to the constructor to
designate those errors as expected. The test will pass as long as only expected errors are found.
Source and binary files have a naming scheme.
(LANGUAGE_ID)_(COMPILER_SPEC_ID)_(CALLING_CONVENTION)
Trace logging is disabled by default. Specific traceLevel and traceLog disabled controlled via
environment properties CSpecTestTraceLevel and EmuTestTraceDisable.
To create a new CSpecPrototypeTest for a given Module (e.g. Processors x86) complete the
following steps:
1. Generate source code using Ghidra and the Ghidra script "GeneratePrototypeTestFileScript".
NOTE: Do not rename the generated file; the filename is required for the test suit.
2. Compile the source code using the following recommended GCC flags:
gcc -O1 -c -fno-inline -fno-leading-underscore -o filename_without_extension filename.c
3. Place the source code and compiled binary in the module's "data/cspectests" directory or the
ghidra.bin repository in the directory: "Ghidra/Test/TestResources/data/cspectests"
4. Add a new package named "ghidra.test.processors.cspec" to the module if it does not exist and
place all new CSpecTest's in this package.
5. New CSpecTests should extend this class and have a class name which ends in 'CSpecTest' and
starts with processor details that indicate what cspec prototype is being tested.
- Implement abstract methods for Language ID, Compiler Spec ID, and Calling Convention.
6. Use Ghidra and the Ghidra script "TestPrototypeScript" to debug errors.
- Click function links in the Script Console to jump to the Listing View.
- To isolate a single function, highlight it in the Listing and re-run the script
for detailed debug output.-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractGuiTest
AbstractGuiTest.ExceptionHandlingRunner -
Field Summary
Fields inherited from class AbstractGhidraHeadlessIntegrationTest
PROJECT_NAMEFields inherited from class AbstractGenericTest
concurrentTestExceptionRule, DEFAULT_TEST_TOOL_NAME, DEFAULT_TOOL_NAME, ruleChain, TESTDATA_DIRECTORY_NAME, watchmanFields inherited from class AbstractGTest
BATCH_MODE, DEFAULT_WAIT_DELAY, DEFAULT_WAIT_TIMEOUT, DEFAULT_WINDOW_TIMEOUT, ignoreUnfinishedRule, PARALLEL_MODE, PRIVATE_LONG_WAIT_TIMEOUT, repeatedRule, testName -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedCSpecPrototypeTest(String[] expectedPrototypeErrors) -
Method Summary
Modifier and TypeMethodDescriptionabstract Stringabstract Stringabstract StringvoidTests that for a given binary and source code all functions in the binary are interpreted correctly by Ghidra using cspec files for the given calling convention.voidsetUp()Ran before every test to prepare Ghidra for testing.voidtearDown()Methods inherited from class AbstractGhidraHeadlessIntegrationTest
applyCmd, cleanDbTestDir, clearSelection, createApplicationConfiguration, createApplicationLayout, createDefaultProgram, createDefaultProgram, debugProgramInTool, deleteProject, getLanguageCompilerSpecPair, getLanguageService, getPlugin, getSLEIGH_8051_LANGUAGE, getSLEIGH_X86_64_LANGUAGE, getSLEIGH_X86_LANGUAGE, getUniqueSymbol, getUniqueSymbol, getZ80_LANGUAGE, goTo, goTo, initializeSystemProperties, makeSelection, makeSelection, makeSelection, makeSelection, modifyProgram, modifyProgram, redo, redo, redo, replaceService, toAddressSet, toAddressSet, toAddressSet, toAddressSet, tx, tx, tx, undo, undo, undo, undo, waitForScriptCompletionMethods inherited from class AbstractDockingTest
assertEnabled, assertIconsEqual, assertToggleButtonSelected, capture, clickComponentProvider, clickComponentProvider, close, close, closeAllWindows, closeAllWindows, closeAllWindowsAndFrames, closeProvider, closeSaveChangesDialog, createActionContext, createContext, createContext, createRenderedImage, createScreenImage, disposeErrorGUI, dockingSetUp, dockingTearDown, expandPath, expandTree, findButtonByActionName, findButtonByIcon, findButtonByName, findButtonByText, findComponent, findComponentByName, getAction, getAction, getAction, getActionsByName, getActionsByOwner, getActionsByOwnerAndName, getClipboardText, getComponentProvider, getDialogComponent, getDialogComponentProvider, getDockableComponent, getLocalAction, getMessageText, getNode, getOpenWindowsAsString, getStatusText, getTitleForWindow, getURL, getWindow, getWindowByTitle, getWindowByTitleContaining, getWindows, isEnabled, isEnabled, isEnabled, isSelected, isToggleButttonSelected, isUseErrorGUI, performAction, performAction, performAction, performAction, performDialogAction, pressButtonByText, pressButtonByText, printOpenWindows, selectPath, selectTabIfAvailable, setErrorGUIEnabled, setToggleActionSelected, setToggleActionSelected, setToggleButtonSelected, setToggleButtonSelected, showProvider, triggerActionKey, triggerActionKey, triggerBackspace, triggerEnter, triggerEscape, triggerKey, triggerKey, triggerKey, triggerText, triggerText, waitForComponentProvider, waitForComponentProvider, waitForComponentProvider, waitForDialogComponent, waitForDialogComponent, waitForDialogComponent, waitForErrorDialog, waitForInfoDialog, waitForJDialog, waitForJDialog, waitForTableModel, waitForTree, waitForUpdateOnChooser, waitForWindow, waitForWindow, waitForWindow, waitForWindowByName, waitForWindowByTitleContaining, writeImage, writeImageMethods inherited from class AbstractGuiTest
assertColorsEqual, clickListRange, clickMouse, clickMouse, clickTableCell, clickTableRange, doubleClick, dragMouse, editCell, executeOnSwingWithoutBlocking, findAbstractButtonByName, findAbstractButtonByText, findButtonByIcon, findButtonByName, findButtonByText, findComponent, findComponent, findComponentByName, findComponentByName, findComponents, findComponents, findOwnedWindows, findPathToText, findTreePathToText, fixupGUI, getAllWindows, getRenderedTableCellValue, getSwing, getText, leftClick, middleClick, moveMouse, postEvent, pressButton, pressButton, pressButtonByName, pressButtonByName, pressButtonByText, pressButtonByText, printMemory, privatewaitForSwing_SwingSafe, rightClick, runSwing, runSwing, runSwing, runSwingLater, runSwingWithException, setComboBoxSelection, setText, waitForExpiringSwingTimers, waitForSwing, waitForTasks, waitForTasks, yieldToSwingMethods inherited from class AbstractGenericTest
createStackTraceForAllThreads, createTempDirectory, createTempFile, createTempFile, createTempFileForTest, createTempFileForTest, createTempFilePath, createTempFilePath, deleteMatchingTempFiles, deleteSimilarTempFiles, findTestDataFile, getDebugFileDirectory, getFontMetrics, getInstanceField, getInstanceFieldByClassType, getTestDataDir, getTestDataDirectory, getTestDataFile, hasTestFailed, initializeLayout, invokeConstructor, invokeInstanceMethod, invokeInstanceMethod, loadTextResource, loadTextResource, resetLogging, setErrorsExpected, setInstanceField, setLogLevel, setLogLevel, testFailed, toString, windowForComponentMethods inherited from class AbstractGTest
assertArraysEqualOrdered, assertArraysEqualUnordered, assertArraysEqualUnordered, assertContainsExactly, assertContainsExactly, assertContainsString, assertContainsStringIgnoringCase, assertListEqualOrdered, assertListEqualOrdered, assertListEqualsArrayOrdered, assertListEqualsArrayUnordered, assertListEqualUnordered, bytes, failWithException, getName, getRandomInt, getRandomInt, getRandomString, getRandomString, getTestDirectoryPath, sleep, waitFor, waitFor, waitFor, waitFor, waitFor, waitForCondition, waitForCondition, waitForCondition, waitForConditionWithoutFailing, waitForValue, waitForValueWithoutFailing
-
Constructor Details
-
CSpecPrototypeTest
-
CSpecPrototypeTest
-
-
Method Details
-
setUp
-
tearDown
-
prototypeTest
Tests that for a given binary and source code all functions in the binary are interpreted correctly by Ghidra using cspec files for the given calling convention.- Throws:
Exception- when the Prototype cannot be established, the source code could not be parsed correctly, or the test could not be completed.
-
getLanguageID
- Returns:
- String Language ID
-
getCompilerSpecID
- Returns:
- String Compiler Spec ID
-
getCallingConvention
- Returns:
- String Calling Convention
-