decompiler
1.0.0
|
A collection of tests around a single program/function. More...
#include <testfunction.hh>
Public Member Functions | |
FunctionTestCollection (ostream &s) | |
Constructor. More... | |
FunctionTestCollection (IfaceStatus *con) | |
Constructor with preexisting console. | |
~FunctionTestCollection (void) | |
Destructor. | |
int4 | getTestsApplied (void) const |
Get the number of tests executed. | |
int4 | getTestsSucceeded (void) const |
Get the number of tests that passed. | |
int4 | numCommands (void) const |
Get the number of commands in the current script. | |
string | getCommand (int4 i) const |
Get the i-th command. | |
void | loadTest (const string &filename) |
Load a test program, tests, and script. More... | |
void | restoreXml (DocumentStorage &store, const Element *el) |
Load tests from a <decompilertest> tag. | |
void | restoreXmlOldForm (DocumentStorage &store, const Element *el) |
Load tests from <binaryimage> tag. More... | |
void | runTests (list< string > &lateStream) |
Run the script and perform the tests. More... | |
Static Public Member Functions | |
static int | runTestFiles (const vector< string > &testFiles, ostream &s) |
Run tests for each listed file. More... | |
Private Member Functions | |
void | clear (void) |
Clear any previous architecture and function. | |
void | restoreXmlCommands (const Element *el) |
Reconstruct commands from an XML tag. More... | |
void | buildProgram (DocumentStorage &store) |
Build program (Architecture) from <binaryimage> tag. More... | |
void | startTests (void) const |
Initialize each FunctionTestProperty. More... | |
void | passLineToTests (const string &line) const |
Let all tests analyze a line of the results. More... | |
void | evaluateTests (list< string > &lateStream) const |
Do the final evaluation of each test. More... | |
Private Attributes | |
IfaceDecompData * | dcp |
Program data for the test collection. | |
string | fileName |
Name of the file containing test data. | |
list< FunctionTestProperty > | testList |
List of tests for this collection. | |
vector< string > | commands |
Sequence of commands for current test. | |
IfaceStatus * | console |
Decompiler console for executing scripts. | |
bool | consoleOwner |
Set to true if this object owns the console. | |
int4 | numTestsApplied |
Count of tests that were executed. | |
int4 | numTestsSucceeded |
Count of tests that passed. | |
A collection of tests around a single program/function.
The collection of tests is loaded from a single XML file via loadTest(), and the tests are run by calling runTests(). An entire program is loaded and possibly annotated by a series of console command lines. Decompiler output is also triggered by a command, and then the output is scanned for by the test objects (FunctionTestProperty). Results of passed/failed tests are collected. If the command line script does not complete properly, this is considered a special kind of failure.
ghidra::FunctionTestCollection::FunctionTestCollection | ( | ostream & | s | ) |
Constructor.
s | is the stream where output is sent during tests |
References ghidra::ConsoleCommands::commands, and ghidra::ConsoleCommands::ConsoleCommands().
|
private |
Build program (Architecture) from <binaryimage> tag.
Instantiate an Architecture object.
References ghidra::ArchitectureCapability::buildArchitecture(), ghidra::LowlevelError::explain, ghidra::DecoderError::explain, ghidra::ArchitectureCapability::getCapability(), and ghidra::Architecture::init().
|
private |
Do the final evaluation of each test.
This is called after each test has been fed all lines of output. The result of each test is printed to the midStream, and then failures are written to the lateStream in order to see a summary.
lateStream | collects failures to display as a summary |
void ghidra::FunctionTestCollection::loadTest | ( | const string & | filename | ) |
Load a test program, tests, and script.
Load the architecture based on the discovered <binaryimage> tag. Collect the script commands and the specific tests.
filename | is the XML file holding the test data |
References ghidra::Element::getName(), ghidra::Document::getRoot(), and ghidra::DocumentStorage::openDocument().
Referenced by runTestFiles().
|
private |
Let all tests analyze a line of the results.
Each test gets a chance to process a line of output
line | is the given line of output |
|
private |
Reconstruct commands from an XML tag.
el | is the root <script> tag |
References ghidra::ConsoleCommands::commands, ghidra::Element::getChildren(), and ghidra::Element::getContent().
void ghidra::FunctionTestCollection::restoreXmlOldForm | ( | DocumentStorage & | store, |
const Element * | el | ||
) |
Load tests from <binaryimage> tag.
Pull the script and tests from a comment in <binaryimage>
|
static |
Run tests for each listed file.
Run through all XML files in the given list, processing each in turn.
testFiles | is the given list of test files |
s | is the output stream to print results to |
References clear(), ghidra::IfaceError::explain, getTestsApplied(), getTestsSucceeded(), loadTest(), and runTests().
Referenced by ghidra::UnitTest::run().
void ghidra::FunctionTestCollection::runTests | ( | list< string > & | lateStream | ) |
Run the script and perform the tests.
Run the script commands on the current program. Collect any bulk output, and run tests over the output. Report test failures back to the caller
lateStream | collects messages for a final summary |
References ghidra::ConsoleCommands::pos.
Referenced by runTestFiles().
|
private |
Initialize each FunctionTestProperty.
Let each test initialize itself thru its startTest() method.