xrpld
Loading...
Searching...
No Matches
xrpl::test::MultiRunnerChild Class Reference

A class to run a subset of unit tests. More...

#include <multi_runner.h>

Inheritance diagram for xrpl::test::MultiRunnerChild:
Collaboration diagram for xrpl::test::MultiRunnerChild:

Public Member Functions

 MultiRunnerChild (MultiRunnerChild const &)=delete
MultiRunnerChildoperator= (MultiRunnerChild const &)=delete
 MultiRunnerChild (std::size_t numJobs, bool quiet, bool printLog)
 ~MultiRunnerChild () override
std::size_t tests () const
std::size_t suites () const
void addFailures (std::size_t failures)
template<class Pred>
bool runMulti (Pred pred)
void arg (std::string const &s)
 Set the argument string.
std::string const & arg () const
 Returns the argument string.
template<class = void>
bool run (SuiteInfo const &s)
 Run the specified suite.
template<class FwdIter>
bool run (FwdIter first, FwdIter last)
 Run a sequence of suites.
template<class FwdIter, class Pred>
bool runIf (FwdIter first, FwdIter last, Pred pred=Pred{})
 Conditionally run a sequence of suites.
template<class SequenceContainer>
bool runEach (SequenceContainer const &c)
 Run all suites in a container.
template<class SequenceContainer, class Pred>
bool runEachIf (SequenceContainer const &c, Pred pred=Pred{})
 Conditionally run suites in a container.

Private Types

enum  MessageType

Private Member Functions

void onSuiteBegin (beast::unit_test::SuiteInfo const &info) override
 Called when a new suite starts.
void onSuiteEnd () override
 Called when a suite ends.
void onCaseBegin (std::string const &name) override
 Called when a new case starts.
void onCaseEnd () override
 Called when a new case ends.
void onPass () override
 Called for each passing condition.
void onFail (std::string const &reason) override
 Called for each failing condition.
void onLog (std::string const &s) override
 Called when a test logs output.
template<class = void>
void testcase (std::string const &name)
template<class = void>
void pass ()
template<class = void>
void fail (std::string const &reason)
template<class = void>
void log (std::string const &s)
void messageQueueSend (MessageType mt, std::string const &s)
std::size_t checkoutTestIndex ()
std::size_t checkoutJobIndex ()
void anyFailed (bool v)
void add (Results const &r)
void incKeepAliveCount ()
std::size_t getKeepAliveCount ()
void printResults (S &s)

Private Attributes

std::size_t jobIndex_
detail::Results results_
detail::SuiteResults suiteResults_
detail::CaseResults caseResults_
std::size_t numJobs_ {0}
bool quiet_ {false}
bool printLog_ {true}
std::atomic< bool > continueKeepAlive_ {true}
std::thread keepAliveThread_
std::string arg_
bool default_ = false
bool failed_ = false
bool cond_ = false
std::recursive_mutex mutex_
Inner * inner_
boost::interprocess::shared_memory_object sharedMem_
boost::interprocess::mapped_region region_
std::unique_ptr< boost::interprocess::message_queue > messageQueue_

Static Private Attributes

static constexpr char const * kSharedMemName
static constexpr char const * kMessageQueueName

Detailed Description

A class to run a subset of unit tests.

Definition at line 241 of file multi_runner.h.

Member Enumeration Documentation

◆ MessageType

Definition at line 153 of file multi_runner.h.

Constructor & Destructor Documentation

◆ MultiRunnerChild() [1/2]

xrpl::test::MultiRunnerChild::MultiRunnerChild ( MultiRunnerChild const & )
delete

◆ MultiRunnerChild() [2/2]

xrpl::test::MultiRunnerChild::MultiRunnerChild ( std::size_t numJobs,
bool quiet,
bool printLog )

Definition at line 479 of file multi_runner.cpp.

◆ ~MultiRunnerChild()

xrpl::test::MultiRunnerChild::~MultiRunnerChild ( )
override

Definition at line 512 of file multi_runner.cpp.

Member Function Documentation

◆ operator=()

MultiRunnerChild & xrpl::test::MultiRunnerChild::operator= ( MultiRunnerChild const & )
delete

◆ tests()

std::size_t xrpl::test::MultiRunnerChild::tests ( ) const
nodiscard

Definition at line 524 of file multi_runner.cpp.

◆ suites()

std::size_t xrpl::test::MultiRunnerChild::suites ( ) const
nodiscard

Definition at line 530 of file multi_runner.cpp.

◆ addFailures()

void xrpl::test::MultiRunnerChild::addFailures ( std::size_t failures)

Definition at line 536 of file multi_runner.cpp.

◆ runMulti()

template<class Pred>
bool xrpl::test::MultiRunnerChild::runMulti ( Pred pred)

Definition at line 304 of file multi_runner.h.

◆ onSuiteBegin()

void xrpl::test::MultiRunnerChild::onSuiteBegin ( beast::unit_test::SuiteInfo const & )
overrideprivatevirtual

Called when a new suite starts.

Reimplemented from beast::unit_test::Runner.

Definition at line 543 of file multi_runner.cpp.

◆ onSuiteEnd()

void xrpl::test::MultiRunnerChild::onSuiteEnd ( )
overrideprivatevirtual

Called when a suite ends.

Reimplemented from beast::unit_test::Runner.

Definition at line 550 of file multi_runner.cpp.

◆ onCaseBegin()

void xrpl::test::MultiRunnerChild::onCaseBegin ( std::string const & )
overrideprivatevirtual

Called when a new case starts.

Reimplemented from beast::unit_test::Runner.

Definition at line 566 of file multi_runner.cpp.

◆ onCaseEnd()

void xrpl::test::MultiRunnerChild::onCaseEnd ( )
overrideprivatevirtual

Called when a new case ends.

Reimplemented from beast::unit_test::Runner.

Definition at line 581 of file multi_runner.cpp.

◆ onPass()

void xrpl::test::MultiRunnerChild::onPass ( )
overrideprivatevirtual

Called for each passing condition.

Reimplemented from beast::unit_test::Runner.

Definition at line 587 of file multi_runner.cpp.

◆ onFail()

void xrpl::test::MultiRunnerChild::onFail ( std::string const & )
overrideprivatevirtual

Called for each failing condition.

Reimplemented from beast::unit_test::Runner.

Definition at line 593 of file multi_runner.cpp.

◆ onLog()

void xrpl::test::MultiRunnerChild::onLog ( std::string const & )
overrideprivatevirtual

Called when a test logs output.

Reimplemented from beast::unit_test::Runner.

Definition at line 605 of file multi_runner.cpp.

◆ arg() [1/2]

void beast::unit_test::Runner::arg ( std::string const & s)
inherited

Set the argument string.

The argument string is available to suites and allows for customization of the test. Each suite defines its own syntax for the argument string. The same argument is passed to all suites.

Definition at line 46 of file runner.h.

◆ arg() [2/2]

std::string const & beast::unit_test::Runner::arg ( ) const
nodiscardinherited

Returns the argument string.

Definition at line 55 of file runner.h.

◆ run() [1/2]

template<class>
bool beast::unit_test::Runner::run ( SuiteInfo const & s)
inherited

Run the specified suite.

Returns
true if any conditions failed.

Definition at line 193 of file runner.h.

◆ run() [2/2]

template<class FwdIter>
bool beast::unit_test::Runner::run ( FwdIter first,
FwdIter last )
inherited

Run a sequence of suites.

The expression FwdIter::value_type must be convertible to SuiteInfo.

Returns
true if any conditions failed.

Definition at line 209 of file runner.h.

◆ runIf()

template<class FwdIter, class Pred>
bool beast::unit_test::Runner::runIf ( FwdIter first,
FwdIter last,
Pred pred = Pred{} )
inherited

Conditionally run a sequence of suites.

pred will be called as:

bool pred(SuiteInfo const&);
Returns
true if any conditions failed.

Definition at line 219 of file runner.h.

◆ runEach()

template<class SequenceContainer>
bool beast::unit_test::Runner::runEach ( SequenceContainer const & c)
inherited

Run all suites in a container.

Returns
true if any conditions failed.

Definition at line 232 of file runner.h.

◆ runEachIf()

template<class SequenceContainer, class Pred>
bool beast::unit_test::Runner::runEachIf ( SequenceContainer const & c,
Pred pred = Pred{} )
inherited

Conditionally run suites in a container.

pred will be called as:

bool pred(SuiteInfo const&);
Returns
true if any conditions failed.

Definition at line 242 of file runner.h.

◆ testcase()

template<class>
void beast::unit_test::Runner::testcase ( std::string const & name)
privateinherited

Definition at line 255 of file runner.h.

◆ pass()

template<class>
void beast::unit_test::Runner::pass ( )
privateinherited

Definition at line 271 of file runner.h.

◆ fail()

template<class>
void beast::unit_test::Runner::fail ( std::string const & reason)
privateinherited

Definition at line 282 of file runner.h.

◆ log()

template<class>
void beast::unit_test::Runner::log ( std::string const & s)
privateinherited

Definition at line 294 of file runner.h.

◆ messageQueueSend()

void xrpl::detail::MultiRunnerBase< IsParent >::messageQueueSend ( MessageType mt,
std::string const & s )
protectedinherited

Definition at line 155 of file multi_runner.cpp.

◆ checkoutTestIndex()

std::size_t xrpl::detail::MultiRunnerBase< IsParent >::checkoutTestIndex ( )
inherited

Definition at line 162 of file multi_runner.cpp.

◆ checkoutJobIndex()

std::size_t xrpl::detail::MultiRunnerBase< IsParent >::checkoutJobIndex ( )
inherited

Definition at line 165 of file multi_runner.cpp.

◆ anyFailed()

void xrpl::detail::MultiRunnerBase< IsParent >::anyFailed ( bool v)
inherited

Definition at line 168 of file multi_runner.cpp.

◆ add()

void xrpl::detail::MultiRunnerBase< IsParent >::add ( Results const & r)
inherited

Definition at line 171 of file multi_runner.cpp.

◆ incKeepAliveCount()

void xrpl::detail::MultiRunnerBase< IsParent >::incKeepAliveCount ( )
inherited

Definition at line 174 of file multi_runner.cpp.

◆ getKeepAliveCount()

std::size_t xrpl::detail::MultiRunnerBase< IsParent >::getKeepAliveCount ( )
inherited

Definition at line 177 of file multi_runner.cpp.

◆ printResults()

void xrpl::detail::MultiRunnerBase< IsParent >::printResults ( S & s)
inherited

Definition at line 181 of file multi_runner.cpp.

Member Data Documentation

◆ jobIndex_

std::size_t xrpl::test::MultiRunnerChild::jobIndex_
private

Definition at line 245 of file multi_runner.h.

◆ results_

detail::Results xrpl::test::MultiRunnerChild::results_
private

Definition at line 246 of file multi_runner.h.

◆ suiteResults_

detail::SuiteResults xrpl::test::MultiRunnerChild::suiteResults_
private

Definition at line 247 of file multi_runner.h.

◆ caseResults_

detail::CaseResults xrpl::test::MultiRunnerChild::caseResults_
private

Definition at line 248 of file multi_runner.h.

◆ numJobs_

std::size_t xrpl::test::MultiRunnerChild::numJobs_ {0}
private

Definition at line 249 of file multi_runner.h.

◆ quiet_

bool xrpl::test::MultiRunnerChild::quiet_ {false}
private

Definition at line 250 of file multi_runner.h.

◆ printLog_

bool xrpl::test::MultiRunnerChild::printLog_ {true}
private

Definition at line 251 of file multi_runner.h.

◆ continueKeepAlive_

std::atomic<bool> xrpl::test::MultiRunnerChild::continueKeepAlive_ {true}
private

Definition at line 253 of file multi_runner.h.

◆ keepAliveThread_

std::thread xrpl::test::MultiRunnerChild::keepAliveThread_
private

Definition at line 254 of file multi_runner.h.

◆ arg_

std::string beast::unit_test::Runner::arg_
privateinherited

Definition at line 24 of file runner.h.

◆ default_

bool beast::unit_test::Runner::default_ = false
privateinherited

Definition at line 25 of file runner.h.

◆ failed_

bool beast::unit_test::Runner::failed_ = false
privateinherited

Definition at line 26 of file runner.h.

◆ cond_

bool beast::unit_test::Runner::cond_ = false
privateinherited

Definition at line 27 of file runner.h.

◆ mutex_

std::recursive_mutex beast::unit_test::Runner::mutex_
privateinherited

Definition at line 28 of file runner.h.

◆ kSharedMemName

char const* xrpl::detail::MultiRunnerBase< IsParent >::kSharedMemName
staticconstexprprivateinherited

Definition at line 139 of file multi_runner.h.

◆ kMessageQueueName

char const* xrpl::detail::MultiRunnerBase< IsParent >::kMessageQueueName
staticconstexprprivateinherited

Definition at line 142 of file multi_runner.h.

◆ inner_

Inner* xrpl::detail::MultiRunnerBase< IsParent >::inner_
privateinherited

Definition at line 145 of file multi_runner.h.

◆ sharedMem_

boost::interprocess::shared_memory_object xrpl::detail::MultiRunnerBase< IsParent >::sharedMem_
privateinherited

Definition at line 147 of file multi_runner.h.

◆ region_

boost::interprocess::mapped_region xrpl::detail::MultiRunnerBase< IsParent >::region_
privateinherited

Definition at line 148 of file multi_runner.h.

◆ messageQueue_

std::unique_ptr<boost::interprocess::message_queue> xrpl::detail::MultiRunnerBase< IsParent >::messageQueue_
protectedinherited

Definition at line 151 of file multi_runner.h.