Class AbstractAssemblyTest
- java.lang.Object
-
- generic.test.AbstractGTest
-
- generic.test.AbstractGenericTest
-
- ghidra.app.plugin.assembler.sleigh.AbstractAssemblyTest
-
- Direct Known Subclasses:
AARCH64BEAssemblyTest
,ARMAssemblyTest
,ARMBEAssemblyTest
,AVR32AssemblyTest
,AVR8AssemblyTest
,m68000AssemblyTest
,MIPSAssemblyTest
,MIPSMicroAssemblyTest
,MSP430XAssemblyTest
,PaRiscAssemblyTest
,PowerPC64AssemblyTest
,SparcAssemblyTest
,x86AssemblyTest
,x86AVX2AssemblyTest
public abstract class AbstractAssemblyTest extends AbstractGenericTest
A test for assembly of a particular SLEIGH language
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractAssemblyTest.DisassemblyMismatchException
A class which allows tests to attempt to gracefully handle changes in language modules.-
Nested classes/interfaces inherited from class generic.test.AbstractGenericTest
AbstractGenericTest.ExceptionHandlingRunner
-
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_ADDR
-
Fields inherited from class generic.test.AbstractGenericTest
concurrentTestExceptionRule, DEFAULT_TEST_TOOL_NAME, ruleChain, TESTDATA_DIRECTORY_NAME, watchman
-
Fields inherited from class generic.test.AbstractGTest
BATCH_MODE, DEFAULT_WAIT_DELAY, DEFAULT_WAIT_TIMEOUT, DEFAULT_WINDOW_TIMEOUT, PARALLEL_MODE, PRIVATE_LONG_WAIT_TIMEOUT, testName
-
-
Constructor Summary
Constructors Constructor Description AbstractAssemblyTest()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
assertAllSemanticErrors(java.lang.String assembly)
Run a test checking that the given assembly parses, but does not assembleprotected void
assertAllSemanticErrors(java.lang.String assembly, java.lang.String ctxstr)
Like {@link # assertAllSemanticErrors(String), but a context is givenprotected void
assertAllSyntaxErrors(java.lang.String assembly)
Run a test checking that the given assembly does not parseprotected void
assertOneCompatRestExact(java.lang.String assembly, java.lang.String instr)
Run a test where one result must match a given instruction pattern, and all others must disassemble exactly to the inputprotected void
assertOneCompatRestExact(java.lang.String assembly, java.lang.String instr, long addr)
LikeassertOneCompatRestExact(String, String)
, except the address is givenprotected void
assertOneCompatRestExact(java.lang.String assembly, java.lang.String instr, long addr, java.lang.String... disassemblies)
LikeassertOneCompatRestExact(String, String, long)
, except an alternative disassembly is givenprotected void
assertOneCompatRestExact(java.lang.String assembly, java.lang.String instr, java.lang.String... disassemblies)
Run a test where one result must match a given instruction pattern, and all others must disassemble to an acceptable resultprotected void
assertOneCompatRestExact(java.lang.String assembly, java.lang.String instr, java.lang.String ctxstr, long addr, java.lang.String... disassemblies)
Like {@link #assertOneCompatRestExact(String, String, String, long), except a context is givenprotected void
checkAllExact(AssemblyResolutionResults rr, java.util.Collection<java.lang.String> disassembly, long addr, java.lang.String ctxstr)
Confirm that every non-erroneous resolution disassembles to the given textprotected void
checkAllSemanticErrs(AssemblyResolutionResults res)
Confirm that every resolution result describes an error, i.e., the text failed to assembleprotected void
checkAllSyntaxErrs(java.util.Collection<AssemblyParseResult> parse)
Confirm that every parse result describes an error, i.e., the text failed to parse.protected void
checkOneCompat(java.lang.String instr, AssemblyResolutionResults rr)
Confirm that one of the assembly results matches the pattern described by instrprotected static void
dbgPrintTrees(java.util.Collection<AssemblyParseResult> trees)
Print a collection of parse trees to the debug printerprotected PseudoInstruction
disassemble(long addr, byte[] ins, byte[] ctx)
Disassemble an instruction, presumably the result of assemblyprotected java.lang.String
dumpConstructorTree(PseudoInstruction ins)
Get the constructor tree of the given instructionprotected java.lang.String
formatWithCons(PseudoInstruction ins)
Conveniently format the instruction mnemonic and constructor treeprotected abstract LanguageID
getLanguageID()
Get the ID of the language under test The test case will automatically attempt to obtain a suitable assembler before the first test is run.protected void
runTest(java.lang.String assembly, java.lang.String instr, java.util.Collection<java.lang.String> disassembly, long addr, java.lang.String ctxstr, boolean checkOneCompat, boolean checkAllExact, boolean checkAllSyntaxErrs, boolean checkAllSemanticErrs)
Run a test with the given checksvoid
setUp()
void
tearDown()
-
Methods inherited from class generic.test.AbstractGenericTest
clickMouse, clickMouse, clickTableCell, createApplicationConfiguration, createApplicationLayout, createStackTraceForAllThreads, createTempDirectory, createTempFile, createTempFile, createTempFileForTest, createTempFileForTest, createTempFilePath, createTempFilePath, deleteMatchingTempFiles, deleteSimilarTempFiles, doubleClick, dragMouse, editCell, executeOnSwingWithoutBlocking, findAbstractButtonByName, findAbstractButtonByText, findButtonByIcon, findButtonByText, findComponent, findComponent, findComponentByName, findComponentByName, findComponentsByName, findOwnedWindows, findPathToText, findTestDataFile, findTreePathToText, fixupGUI, getAllWindows, getDebugFileDirectory, getInstanceField, getInstanceFieldByClassType, getLocalResourceFile, getTestDataDir, getTestDataDirectory, getTestDataFile, getText, hasTestFailed, initializeLayout, initializeSystemProperties, invokeConstructor, invokeInstanceMethod, invokeInstanceMethod, leftClick, loadTextResource, loadTextResource, middleClick, moveMouse, postEvent, pressButton, pressButton, pressButtonByName, pressButtonByName, pressButtonByText, pressButtonByText, printMemory, privateWaitForPostedSwingRunnables_SwingSafe, rightClick, runSwing, runSwing, runSwing, setComboBoxSelection, setInstanceField, setText, testFailed, toString, waitForPostedSwingRunnables, waitForSwing, waitForTasks, windowForComponent, yieldToSwing
-
Methods inherited from class generic.test.AbstractGTest
assertArraysEqualOrdered, assertArraysEqualUnordered, assertArraysEqualUnordered, assertContainsExactly, assertContainsExactly, assertListEqualOrdered, assertListEqualOrdered, assertListEqualsArrayOrdered, assertListEqualsArrayUnordered, assertListEqualUnordered, failWithException, getName, getRandomInt, getRandomInt, getRandomString, getRandomString, getTestDirectoryPath, sleep, waitFor, waitFor, waitFor, waitForCondition, waitForCondition, waitForConditionWithoutFailing, waitForValue, waitForValueWithoutFailing
-
-
-
-
Field Detail
-
DEFAULT_ADDR
public static final long DEFAULT_ADDR
- See Also:
- Constant Field Values
-
-
Method Detail
-
getLanguageID
protected abstract LanguageID getLanguageID()
Get the ID of the language under test The test case will automatically attempt to obtain a suitable assembler before the first test is run.- Returns:
- the ID of the language
-
setUp
public void setUp() throws java.lang.Exception
- Throws:
java.lang.Exception
-
tearDown
public void tearDown()
-
dbgPrintTrees
protected static void dbgPrintTrees(java.util.Collection<AssemblyParseResult> trees)
Print a collection of parse trees to the debug printer- Parameters:
trees
- the trees
-
disassemble
protected PseudoInstruction disassemble(long addr, byte[] ins, byte[] ctx) throws InsufficientBytesException, UnknownInstructionException, AddressOverflowException, MemoryAccessException
Disassemble an instruction, presumably the result of assembly- Parameters:
addr
- the address of the instructionins
- the instruction bytesctx
- the input context- Returns:
- the resulting decoded instruction
- Throws:
InsufficientBytesException
UnknownInstructionException
AddressOverflowException
MemoryAccessException
-
dumpConstructorTree
protected java.lang.String dumpConstructorTree(PseudoInstruction ins)
Get the constructor tree of the given instruction- Parameters:
ins
- the instruction unit- Returns:
- the constructor tree
- See Also:
SleighInstructionPrototype.dumpConstructorTree()
-
formatWithCons
protected java.lang.String formatWithCons(PseudoInstruction ins)
Conveniently format the instruction mnemonic and constructor tree- Parameters:
ins
- the instruction unit- Returns:
- a nice display
-
checkOneCompat
protected void checkOneCompat(java.lang.String instr, AssemblyResolutionResults rr)
Confirm that one of the assembly results matches the pattern described by instr- Parameters:
instr
- a hex-ish representation of the instruction patternrr
- the collection of assembly resolutions- See Also:
AssemblyPatternBlock.fromString(String)
-
checkAllExact
protected void checkAllExact(AssemblyResolutionResults rr, java.util.Collection<java.lang.String> disassembly, long addr, java.lang.String ctxstr)
Confirm that every non-erroneous resolution disassembles to the given text- Parameters:
rr
- the collection of assembly resolutionsdisassembly
- the expected disassembly textaddr
- the address of the instruction(s)ctxstr
- a string describing the input context pattern- See Also:
AssemblyPatternBlock.fromString(String)
-
checkAllSyntaxErrs
protected void checkAllSyntaxErrs(java.util.Collection<AssemblyParseResult> parse)
Confirm that every parse result describes an error, i.e., the text failed to parse.- Parameters:
parse
- the collection of parse results
-
checkAllSemanticErrs
protected void checkAllSemanticErrs(AssemblyResolutionResults res)
Confirm that every resolution result describes an error, i.e., the text failed to assemble- Parameters:
res
- the collection of assembly resolutions
-
runTest
protected void runTest(java.lang.String assembly, java.lang.String instr, java.util.Collection<java.lang.String> disassembly, long addr, java.lang.String ctxstr, boolean checkOneCompat, boolean checkAllExact, boolean checkAllSyntaxErrs, boolean checkAllSemanticErrs)
Run a test with the given checks- Parameters:
assembly
- the text to assemblyinstr
- an instruction pattern that must appear in the resultsdisassembly
- a set of acceptable disassembly textsaddr
- the address for assembly and disassemblyctxstr
- the context for assembly and disassemblycheckOneCompat
- ifinstr != null
check that one result matches itcheckAllExact
- ifdisassembly != null
check that all are acceptablecheckAllSyntaxErrs
- confirm thatassembly
does not parsecheckAllSemanticErrs
- confirm thatassembly
does not assemble- See Also:
AssemblyPatternBlock.fromString(String)
-
assertOneCompatRestExact
protected void assertOneCompatRestExact(java.lang.String assembly, java.lang.String instr)
Run a test where one result must match a given instruction pattern, and all others must disassemble exactly to the input- Parameters:
assembly
- the input assemblyinstr
- the instruction pattern- See Also:
AssemblyPatternBlock.fromString(String)
-
assertOneCompatRestExact
protected void assertOneCompatRestExact(java.lang.String assembly, java.lang.String instr, java.lang.String... disassemblies)
Run a test where one result must match a given instruction pattern, and all others must disassemble to an acceptable result- Parameters:
assembly
- the input assemblyinstr
- the instruction patterndisassemblies
- the set of acceptable disassemblies- See Also:
AssemblyPatternBlock.fromString(String)
-
assertOneCompatRestExact
protected void assertOneCompatRestExact(java.lang.String assembly, java.lang.String instr, long addr)
LikeassertOneCompatRestExact(String, String)
, except the address is given- Parameters:
assembly
- the input assemblyinstr
- the instruction patternaddr
- the address for assembly and disassembly- See Also:
AssemblyPatternBlock.fromString(String)
-
assertOneCompatRestExact
protected void assertOneCompatRestExact(java.lang.String assembly, java.lang.String instr, long addr, java.lang.String... disassemblies)
LikeassertOneCompatRestExact(String, String, long)
, except an alternative disassembly is given- Parameters:
assembly
- the input assemblyinstr
- the instruction patternaddr
- the address for assembly and disassemblydisassemblies
- the set of acceptable disassemblies- See Also:
AssemblyPatternBlock.fromString(String)
-
assertOneCompatRestExact
protected void assertOneCompatRestExact(java.lang.String assembly, java.lang.String instr, java.lang.String ctxstr, long addr, java.lang.String... disassemblies)
Like {@link #assertOneCompatRestExact(String, String, String, long), except a context is given- Parameters:
assembly
- the input assemblyinstr
- the instruction patternaddr
- the address for assembly and disassemblyctxstr
- the context pattern for assembly and disassemblydisassemblies
- the set of acceptable disassemblies- See Also:
AssemblyPatternBlock.fromString(String)
-
assertAllSyntaxErrors
protected void assertAllSyntaxErrors(java.lang.String assembly)
Run a test checking that the given assembly does not parse- Parameters:
assembly
- the input assembly
-
assertAllSemanticErrors
protected void assertAllSemanticErrors(java.lang.String assembly)
Run a test checking that the given assembly parses, but does not assemble- Parameters:
assembly
- the input assembly
-
assertAllSemanticErrors
protected void assertAllSemanticErrors(java.lang.String assembly, java.lang.String ctxstr)
Like {@link # assertAllSemanticErrors(String), but a context is given- Parameters:
assembly
- the input assemblyctxstr
- the context pattern for assembly- See Also:
AssemblyPatternBlock.fromString(String)
-
-