ROSE  0.9.12.28
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Rose::BinaryAnalysis::Concolic::Database Class Reference

Description

Database.

A database holds the entire state for a concolic testing system consisting of one or more test suites. A Database object is always connected to exactly one database and limits the scope of its operations to exactly one test suite (except where noted).

A Database object refers to persistent storage through a URL using ROSE's SqlDatabase layer. This supports both PostgreSQL databases and SQLite3 databases and the the possibility of adding other RDMSs later.

Objects within a database have an ID number, and these ID numbers are type-specific. When an object is inserted (copied) into a database a new ID number is returned. The Database object memoizes the association between object IDs and objects.

Definition at line 672 of file BinaryConcolic.h.

#include <BinaryConcolic.h>

Inheritance diagram for Rose::BinaryAnalysis::Concolic::Database:
Inheritance graph
[legend]
Collaboration diagram for Rose::BinaryAnalysis::Concolic::Database:
Collaboration graph
[legend]

Public Types

typedef Sawyer::SharedPointer< DatabasePtr
 Reference counting pointer to Database. More...
 
typedef ::Rose::BinaryAnalysis::Concolic::TestSuiteId TestSuiteId
 
typedef ::Rose::BinaryAnalysis::Concolic::SpecimenId SpecimenId
 
typedef ::Rose::BinaryAnalysis::Concolic::TestCaseId TestCaseId
 

Public Member Functions

std::vector< TestSuiteIdtestSuites ()
 All test suites. More...
 
std::vector< SpecimenIdspecimens ()
 All specimens. More...
 
std::vector< TestCaseIdtestCases ()
 All test cases. More...
 
Specimen::Ptr object_ns (SqlDatabase::TransactionPtr tx, SpecimenId id)
 Reconstitute an object from a database ID as part of a subquery. More...
 
TestSuiteId id_ns (SqlDatabase::TransactionPtr, const TestSuite::Ptr &, Update::Flag update=Update::YES)
 Returns an ID number for an object, optionally writing to the database. More...
 
TestCaseId id_ns (SqlDatabase::TransactionPtr, const TestCase::Ptr &, Update::Flag update=Update::YES)
 
SpecimenId id_ns (SqlDatabase::TransactionPtr, const Specimen::Ptr &, Update::Flag update=Update::YES)
 
TestSuite::Ptr findTestSuite (const std::string &nameOrId)
 Finds a test suite by name or ID. More...
 
std::vector< SpecimenIdfindSpecimensByName (const std::string &name)
 Finds all specimens having the specified name. More...
 
bool rbaExists (SpecimenId)
 Check whether a specimen has associated RBA data. More...
 
void saveRbaFile (const boost::filesystem::path &, SpecimenId)
 Associate new RBA data with a specimen. More...
 
void extractRbaFile (const boost::filesystem::path &, SpecimenId)
 Extract RBA data from the database into a file. More...
 
void eraseRba (SpecimenId)
 Remove any associated RBA data. More...
 
void assocTestCaseWithTestSuite (TestCaseId testcase, TestSuiteId testsuite)
 Associate TestCase w/ TestSuite. More...
 
std::vector< Database::TestCaseIdneedConcreteTesting (size_t)
 Returns n test cases without concrete results. More...
 
std::vector< Database::TestCaseIdneedConcolicTesting (size_t)
 Returns n test cases without concolic results. More...
 
void insertConcreteResults (const TestCase::Ptr &testCase, const ConcreteExecutor::Result &details)
 Updates a test case and its results. More...
 
bool hasUntested () const
 Tests if there are more test cases that require testing. More...
 
TestSuite::Ptr testSuite ()
 Property: the current test suite. More...
 
TestSuiteId testSuite (const TestSuite::Ptr &)
 Property: the current test suite. More...
 
TestSuite::Ptr object (TestSuiteId, Update::Flag update=Update::YES)
 Reconstitute a object from a database ID. More...
 
TestCase::Ptr object (TestCaseId, Update::Flag update=Update::YES)
 Reconstitute a object from a database ID. More...
 
Specimen::Ptr object (SpecimenId, Update::Flag update=Update::YES)
 Reconstitute a object from a database ID. More...
 
TestSuiteId id (const TestSuite::Ptr &, Update::Flag update=Update::YES)
 Returns an ID number for an object, optionally writing to the database. More...
 
TestCaseId id (const TestCase::Ptr &, Update::Flag update=Update::YES)
 Returns an ID number for an object, optionally writing to the database. More...
 
SpecimenId id (const Specimen::Ptr &, Update::Flag update=Update::YES)
 Returns an ID number for an object, optionally writing to the database. More...
 
- Public Member Functions inherited from Sawyer::SharedObject
 SharedObject ()
 Default constructor. More...
 
 SharedObject (const SharedObject &)
 Copy constructor. More...
 
virtual ~SharedObject ()
 Virtual destructor. More...
 
SharedObjectoperator= (const SharedObject &)
 Assignment. More...
 

Static Public Member Functions

static Ptr instance (const std::string &url)
 Open an existing database. More...
 
static Ptr create (const std::string &url)
 Create a new database and test suite. More...
 
static Ptr create (const std::string &url, const std::string &testSuiteName)
 Create a new database and test suite. More...
 

Member Typedef Documentation

Reference counting pointer to Database.

Definition at line 675 of file BinaryConcolic.h.

Member Function Documentation

static Ptr Rose::BinaryAnalysis::Concolic::Database::instance ( const std::string &  url)
static

Open an existing database.

Throws an Exception if the database does not exist.

static Ptr Rose::BinaryAnalysis::Concolic::Database::create ( const std::string &  url)
static

Create a new database and test suite.

For database management systems that support it, a new database is created, possibly overwriting any previous data if the database already existed. SQLite3 databases can be created this way because they're just files in the local filesystem, but PostgreSQL databases need to be created through the DBMS. Throws an Exception if the new database could not be created.

Once the database is created, a new test suite with the given name is created.

static Ptr Rose::BinaryAnalysis::Concolic::Database::create ( const std::string &  url,
const std::string &  testSuiteName 
)
static

Create a new database and test suite.

For database management systems that support it, a new database is created, possibly overwriting any previous data if the database already existed. SQLite3 databases can be created this way because they're just files in the local filesystem, but PostgreSQL databases need to be created through the DBMS. Throws an Exception if the new database could not be created.

Once the database is created, a new test suite with the given name is created.

std::vector<TestSuiteId> Rose::BinaryAnalysis::Concolic::Database::testSuites ( )

All test suites.

Returns information about all the test suites that exist in this database. This is essentially the table of contents for the database.

TestSuite::Ptr Rose::BinaryAnalysis::Concolic::Database::testSuite ( )

Property: the current test suite.

If the database has a current test suite, then queries are limited in scope to return results associated with that test suite. Setting the test suite property also updates the database with information about the test suite, creating the test suite if necessary.

TestSuiteId Rose::BinaryAnalysis::Concolic::Database::testSuite ( const TestSuite::Ptr )

Property: the current test suite.

If the database has a current test suite, then queries are limited in scope to return results associated with that test suite. Setting the test suite property also updates the database with information about the test suite, creating the test suite if necessary.

std::vector<SpecimenId> Rose::BinaryAnalysis::Concolic::Database::specimens ( )

All specimens.

If this database object has a current test suite, then the return value is limited to specimens used by that test suite, otherwise all specimens are returned.

std::vector<TestCaseId> Rose::BinaryAnalysis::Concolic::Database::testCases ( )

All test cases.

If this database object has a current test suite, then the return value is limited to test cases used by that test suite, otherwise all test cases are returned.

TestSuite::Ptr Rose::BinaryAnalysis::Concolic::Database::object ( TestSuiteId  ,
Update::Flag  update = Update::YES 
)

Reconstitute a object from a database ID.

The association between object and ID is memoized. If update is yes and a memoized object is being returned, then also updates the object with the current values from the database.

TestCase::Ptr Rose::BinaryAnalysis::Concolic::Database::object ( TestCaseId  ,
Update::Flag  update = Update::YES 
)

Reconstitute a object from a database ID.

The association between object and ID is memoized. If update is yes and a memoized object is being returned, then also updates the object with the current values from the database.

Specimen::Ptr Rose::BinaryAnalysis::Concolic::Database::object ( SpecimenId  ,
Update::Flag  update = Update::YES 
)

Reconstitute a object from a database ID.

The association between object and ID is memoized. If update is yes and a memoized object is being returned, then also updates the object with the current values from the database.

Specimen::Ptr Rose::BinaryAnalysis::Concolic::Database::object_ns ( SqlDatabase::TransactionPtr  tx,
SpecimenId  id 
)

Reconstitute an object from a database ID as part of a subquery.

Thread safety: not thread safe (assumes that it is called from a thread-safe context)

TestSuiteId Rose::BinaryAnalysis::Concolic::Database::id ( const TestSuite::Ptr ,
Update::Flag  update = Update::YES 
)

Returns an ID number for an object, optionally writing to the database.

If the object exists in the database (i.e., returned as the result of some query) then its ID is returned and the database is optionally updated. On the other hand, if the object does not exist in the database then it will be created only if update is yes and its new ID is returned. If the object doesn't exist and isn't created then an invalid ID is returned.

TestCaseId Rose::BinaryAnalysis::Concolic::Database::id ( const TestCase::Ptr ,
Update::Flag  update = Update::YES 
)

Returns an ID number for an object, optionally writing to the database.

If the object exists in the database (i.e., returned as the result of some query) then its ID is returned and the database is optionally updated. On the other hand, if the object does not exist in the database then it will be created only if update is yes and its new ID is returned. If the object doesn't exist and isn't created then an invalid ID is returned.

SpecimenId Rose::BinaryAnalysis::Concolic::Database::id ( const Specimen::Ptr ,
Update::Flag  update = Update::YES 
)

Returns an ID number for an object, optionally writing to the database.

If the object exists in the database (i.e., returned as the result of some query) then its ID is returned and the database is optionally updated. On the other hand, if the object does not exist in the database then it will be created only if update is yes and its new ID is returned. If the object doesn't exist and isn't created then an invalid ID is returned.

TestSuiteId Rose::BinaryAnalysis::Concolic::Database::id_ns ( SqlDatabase::TransactionPtr  ,
const TestSuite::Ptr ,
Update::Flag  update = Update::YES 
)

Returns an ID number for an object, optionally writing to the database.

The functions are executed in the context of some other transaction.

Thread safety: not thread safe

TestSuite::Ptr Rose::BinaryAnalysis::Concolic::Database::findTestSuite ( const std::string &  nameOrId)

Finds a test suite by name or ID.

Returns the (unique) TestSuite object has the specified name. If no such test suite exists and the specified name can be parsed as an object ID (see constructors for ObjectId) returns the test suite with the specified ID. If no matches are found by either mechanism then a null pointer is returned. This method is intended to be used mainly to convert command-line arguments to test suites.

std::vector<SpecimenId> Rose::BinaryAnalysis::Concolic::Database::findSpecimensByName ( const std::string &  name)

Finds all specimens having the specified name.

If the database is restricted to a test suite (see testSuite) then the returned specimens are only those that are part of the current test suite and have the specified name. Specimen names need not be unique or non-empty.

bool Rose::BinaryAnalysis::Concolic::Database::rbaExists ( SpecimenId  )

Check whether a specimen has associated RBA data.

Returns true if the indicated specimen has associated ROSE Binary Analysis (RBA) data, and false if it doesn't. Each specimen can have zero or one associated RBA data blob. The specimen ID must be valid.

Thread safety: Not thread safe.

void Rose::BinaryAnalysis::Concolic::Database::saveRbaFile ( const boost::filesystem::path &  ,
SpecimenId   
)

Associate new RBA data with a specimen.

The ROSE Binary Analysis (RBA) data is read from the specified existing, readable file and copied into this database to be associated with the indicated specimen. If the specimen had previous RBA data, the new data read from the file replaces the old data. If any data cannot be copied from the file into the database then an Exception is thrown and the database is not modified. The specimen ID must be valid.

Thread safety: Not thread safe.

void Rose::BinaryAnalysis::Concolic::Database::extractRbaFile ( const boost::filesystem::path &  ,
SpecimenId   
)

Extract RBA data from the database into a file.

The ROSE Binary Analysis (RBA) data associated with the indicated specimen is copied from the database into the specified file. The is created if it doesn't exist, or truncated if it does exist. If the specimen does not have associated RBA data or if any data could not be copied to the file, then an Exception is thrown. The specimen ID must be valid.

Thread safety: Not thread safe.

void Rose::BinaryAnalysis::Concolic::Database::eraseRba ( SpecimenId  )

Remove any associated RBA data.

If the indicated specimen has ROSE Binary Analysis (RBA) data, then it is removed from the database.

Thread safety: Not thread safe.

void Rose::BinaryAnalysis::Concolic::Database::assocTestCaseWithTestSuite ( TestCaseId  testcase,
TestSuiteId  testsuite 
)

Associate TestCase w/ TestSuite.

Thread safety: thread safe

std::vector<Database::TestCaseId> Rose::BinaryAnalysis::Concolic::Database::needConcreteTesting ( size_t  )

Returns n test cases without concrete results.

Thread safety: thread safe

std::vector<Database::TestCaseId> Rose::BinaryAnalysis::Concolic::Database::needConcolicTesting ( size_t  )

Returns n test cases without concolic results.

Thread safety: thread safe

void Rose::BinaryAnalysis::Concolic::Database::insertConcreteResults ( const TestCase::Ptr testCase,
const ConcreteExecutor::Result details 
)

Updates a test case and its results.

Parameters
testCasea pointer to a test case
detailsa polymorphic object holding results for a concrete execution

Thread safety: thread safe

bool Rose::BinaryAnalysis::Concolic::Database::hasUntested ( ) const

Tests if there are more test cases that require testing.

Thread safety: thread safe


The documentation for this class was generated from the following file: