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 234 of file multi_runner.h.

Member Enumeration Documentation

◆ MessageType

Definition at line 148 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 480 of file multi_runner.cpp.

◆ ~MultiRunnerChild()

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

Definition at line 513 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 525 of file multi_runner.cpp.

◆ suites()

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

Definition at line 531 of file multi_runner.cpp.

◆ addFailures()

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

Definition at line 537 of file multi_runner.cpp.

◆ runMulti()

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

Definition at line 297 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 544 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 551 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 567 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 582 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 588 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 594 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 606 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 44 of file runner.h.

◆ arg() [2/2]

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

Returns the argument string.

Definition at line 51 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 170 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 186 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 196 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 209 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 219 of file runner.h.

◆ testcase()

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

Definition at line 232 of file runner.h.

◆ pass()

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

Definition at line 248 of file runner.h.

◆ fail()

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

Definition at line 259 of file runner.h.

◆ log()

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

Definition at line 271 of file runner.h.

◆ messageQueueSend()

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

Definition at line 150 of file multi_runner.cpp.

◆ checkoutTestIndex()

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

Definition at line 157 of file multi_runner.cpp.

◆ checkoutJobIndex()

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

Definition at line 160 of file multi_runner.cpp.

◆ anyFailed()

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

Definition at line 163 of file multi_runner.cpp.

◆ add()

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

Definition at line 166 of file multi_runner.cpp.

◆ incKeepAliveCount()

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

Definition at line 169 of file multi_runner.cpp.

◆ getKeepAliveCount()

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

Definition at line 172 of file multi_runner.cpp.

◆ printResults()

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

Definition at line 176 of file multi_runner.cpp.

Member Data Documentation

◆ jobIndex_

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

Definition at line 238 of file multi_runner.h.

◆ results_

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

Definition at line 239 of file multi_runner.h.

◆ suiteResults_

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

Definition at line 240 of file multi_runner.h.

◆ caseResults_

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

Definition at line 241 of file multi_runner.h.

◆ numJobs_

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

Definition at line 242 of file multi_runner.h.

◆ quiet_

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

Definition at line 243 of file multi_runner.h.

◆ printLog_

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

Definition at line 244 of file multi_runner.h.

◆ continueKeepAlive_

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

Definition at line 246 of file multi_runner.h.

◆ keepAliveThread_

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

Definition at line 247 of file multi_runner.h.

◆ arg_

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

Definition at line 23 of file runner.h.

◆ default_

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

Definition at line 24 of file runner.h.

◆ failed_

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

Definition at line 25 of file runner.h.

◆ cond_

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

Definition at line 26 of file runner.h.

◆ mutex_

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

Definition at line 27 of file runner.h.

◆ kSharedMemName

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

Definition at line 134 of file multi_runner.h.

◆ kMessageQueueName

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

Definition at line 137 of file multi_runner.h.

◆ inner_

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

Definition at line 140 of file multi_runner.h.

◆ sharedMem_

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

Definition at line 142 of file multi_runner.h.

◆ region_

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

Definition at line 143 of file multi_runner.h.

◆ messageQueue_

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

Definition at line 146 of file multi_runner.h.