rippled
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
xrpl::test::multi_runner_child Class Reference

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

#include <multi_runner.h>

Inheritance diagram for xrpl::test::multi_runner_child:
Inheritance graph
[legend]
Collaboration diagram for xrpl::test::multi_runner_child:
Collaboration graph
[legend]

Public Member Functions

 multi_runner_child (multi_runner_child const &)=delete
 
multi_runner_childoperator= (multi_runner_child const &)=delete
 
 multi_runner_child (std::size_t num_jobs, bool quiet, bool print_log)
 
 ~multi_runner_child ()
 
std::size_t tests () const
 
std::size_t suites () const
 
void add_failures (std::size_t failures)
 
template<class Pred >
bool run_multi (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 (suite_info 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 run_if (FwdIter first, FwdIter last, Pred pred=Pred{})
 Conditionally run a sequence of suites.
 
template<class SequenceContainer >
bool run_each (SequenceContainer const &c)
 Run all suites in a container.
 
template<class SequenceContainer , class Pred >
bool run_each_if (SequenceContainer const &c, Pred pred=Pred{})
 Conditionally run suites in a container.
 

Private Types

enum  MessageType
 

Private Member Functions

virtual void on_suite_begin (beast::unit_test::suite_info const &info) override
 Called when a new suite starts.
 
virtual void on_suite_end () override
 Called when a suite ends.
 
virtual void on_case_begin (std::string const &name) override
 Called when a new case starts.
 
virtual void on_case_end () override
 Called when a new case ends.
 
virtual void on_pass () override
 Called for each passing condition.
 
virtual void on_fail (std::string const &reason) override
 Called for each failing condition.
 
virtual void on_log (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 message_queue_send (MessageType mt, std::string const &s)
 
std::size_t checkout_test_index ()
 
std::size_t checkout_job_index ()
 
void any_failed (bool v)
 
bool any_failed () const
 
void add (results const &r)
 
void inc_keep_alive_count ()
 
std::size_t get_keep_alive_count ()
 
void print_results (S &s)
 

Private Attributes

std::size_t job_index_
 
detail::results results_
 
detail::suite_results suite_results_
 
detail::case_results case_results_
 
std::size_t num_jobs_ {0}
 
bool quiet_ {false}
 
bool print_log_ {true}
 
std::atomic< bool > continue_keep_alive_ {true}
 
std::thread keep_alive_thread_
 
std::string arg_
 
bool default_ = false
 
bool failed_ = false
 
bool cond_ = false
 
std::recursive_mutex mutex_
 
inner * inner_
 
boost::interprocess::shared_memory_object shared_mem_
 
boost::interprocess::mapped_region region_
 
std::unique_ptr< boost::interprocess::message_queue > message_queue_
 

Static Private Attributes

static constexpr char const * shared_mem_name_
 
static constexpr char const * message_queue_name_
 

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

◆ multi_runner_child() [1/2]

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

◆ multi_runner_child() [2/2]

xrpl::test::multi_runner_child::multi_runner_child ( std::size_t  num_jobs,
bool  quiet,
bool  print_log 
)

Definition at line 459 of file multi_runner.cpp.

◆ ~multi_runner_child()

xrpl::test::multi_runner_child::~multi_runner_child ( )

Definition at line 491 of file multi_runner.cpp.

Member Function Documentation

◆ operator=()

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

◆ tests()

std::size_t xrpl::test::multi_runner_child::tests ( ) const

Definition at line 503 of file multi_runner.cpp.

◆ suites()

std::size_t xrpl::test::multi_runner_child::suites ( ) const

Definition at line 509 of file multi_runner.cpp.

◆ add_failures()

void xrpl::test::multi_runner_child::add_failures ( std::size_t  failures)

Definition at line 515 of file multi_runner.cpp.

◆ run_multi()

template<class Pred >
bool xrpl::test::multi_runner_child::run_multi ( Pred  pred)

Definition at line 296 of file multi_runner.h.

◆ on_suite_begin()

void xrpl::test::multi_runner_child::on_suite_begin ( beast::unit_test::suite_info const &  )
overrideprivatevirtual

Called when a new suite starts.

Reimplemented from beast::unit_test::runner.

Definition at line 522 of file multi_runner.cpp.

◆ on_suite_end()

void xrpl::test::multi_runner_child::on_suite_end ( )
overrideprivatevirtual

Called when a suite ends.

Reimplemented from beast::unit_test::runner.

Definition at line 529 of file multi_runner.cpp.

◆ on_case_begin()

void xrpl::test::multi_runner_child::on_case_begin ( std::string const &  )
overrideprivatevirtual

Called when a new case starts.

Reimplemented from beast::unit_test::runner.

Definition at line 545 of file multi_runner.cpp.

◆ on_case_end()

void xrpl::test::multi_runner_child::on_case_end ( )
overrideprivatevirtual

Called when a new case ends.

Reimplemented from beast::unit_test::runner.

Definition at line 560 of file multi_runner.cpp.

◆ on_pass()

void xrpl::test::multi_runner_child::on_pass ( )
overrideprivatevirtual

Called for each passing condition.

Reimplemented from beast::unit_test::runner.

Definition at line 566 of file multi_runner.cpp.

◆ on_fail()

void xrpl::test::multi_runner_child::on_fail ( std::string const &  )
overrideprivatevirtual

Called for each failing condition.

Reimplemented from beast::unit_test::runner.

Definition at line 572 of file multi_runner.cpp.

◆ on_log()

void xrpl::test::multi_runner_child::on_log ( std::string const &  )
overrideprivatevirtual

Called when a test logs output.

Reimplemented from beast::unit_test::runner.

Definition at line 584 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 45 of file runner.h.

◆ arg() [2/2]

std::string const & beast::unit_test::runner::arg ( ) const
inherited

Returns the argument string.

Definition at line 52 of file runner.h.

◆ run() [1/2]

template<class >
bool beast::unit_test::runner::run ( suite_info const &  s)
inherited

Run the specified suite.

Returns
true if any conditions failed.

Definition at line 171 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 suite_info.

Returns
true if any conditions failed.

Definition at line 187 of file runner.h.

◆ run_if()

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

Conditionally run a sequence of suites.

pred will be called as:

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

Definition at line 197 of file runner.h.

◆ run_each()

template<class SequenceContainer >
bool beast::unit_test::runner::run_each ( SequenceContainer const &  c)
inherited

Run all suites in a container.

Returns
true if any conditions failed.

Definition at line 208 of file runner.h.

◆ run_each_if()

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

Conditionally run suites in a container.

pred will be called as:

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

Definition at line 218 of file runner.h.

◆ testcase()

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

Definition at line 229 of file runner.h.

◆ pass()

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

Definition at line 245 of file runner.h.

◆ fail()

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

Definition at line 256 of file runner.h.

◆ log()

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

Definition at line 268 of file runner.h.

◆ message_queue_send()

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

Definition at line 150 of file multi_runner.cpp.

◆ checkout_test_index()

std::size_t xrpl::detail::multi_runner_base< IsParent >::checkout_test_index ( )
inherited

Definition at line 157 of file multi_runner.cpp.

◆ checkout_job_index()

std::size_t xrpl::detail::multi_runner_base< IsParent >::checkout_job_index ( )
inherited

Definition at line 160 of file multi_runner.cpp.

◆ any_failed() [1/2]

void xrpl::detail::multi_runner_base< IsParent >::any_failed ( bool  v)
inherited

Definition at line 163 of file multi_runner.cpp.

◆ any_failed() [2/2]

bool xrpl::detail::multi_runner_base< IsParent >::any_failed ( ) const
inherited

Definition at line 179 of file multi_runner.cpp.

◆ add()

void xrpl::detail::multi_runner_base< IsParent >::add ( results const &  r)
inherited

Definition at line 166 of file multi_runner.cpp.

◆ inc_keep_alive_count()

void xrpl::detail::multi_runner_base< IsParent >::inc_keep_alive_count ( )
inherited

Definition at line 169 of file multi_runner.cpp.

◆ get_keep_alive_count()

std::size_t xrpl::detail::multi_runner_base< IsParent >::get_keep_alive_count ( )
inherited

Definition at line 172 of file multi_runner.cpp.

◆ print_results()

void xrpl::detail::multi_runner_base< IsParent >::print_results ( S &  s)
inherited

Definition at line 176 of file multi_runner.cpp.

Member Data Documentation

◆ job_index_

std::size_t xrpl::test::multi_runner_child::job_index_
private

Definition at line 237 of file multi_runner.h.

◆ results_

detail::results xrpl::test::multi_runner_child::results_
private

Definition at line 238 of file multi_runner.h.

◆ suite_results_

detail::suite_results xrpl::test::multi_runner_child::suite_results_
private

Definition at line 239 of file multi_runner.h.

◆ case_results_

detail::case_results xrpl::test::multi_runner_child::case_results_
private

Definition at line 240 of file multi_runner.h.

◆ num_jobs_

std::size_t xrpl::test::multi_runner_child::num_jobs_ {0}
private

Definition at line 241 of file multi_runner.h.

◆ quiet_

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

Definition at line 242 of file multi_runner.h.

◆ print_log_

bool xrpl::test::multi_runner_child::print_log_ {true}
private

Definition at line 243 of file multi_runner.h.

◆ continue_keep_alive_

std::atomic<bool> xrpl::test::multi_runner_child::continue_keep_alive_ {true}
private

Definition at line 245 of file multi_runner.h.

◆ keep_alive_thread_

std::thread xrpl::test::multi_runner_child::keep_alive_thread_
private

Definition at line 246 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.

◆ shared_mem_name_

constexpr char const* xrpl::detail::multi_runner_base< IsParent >::shared_mem_name_
staticconstexprprivateinherited

Definition at line 134 of file multi_runner.h.

◆ message_queue_name_

constexpr char const* xrpl::detail::multi_runner_base< IsParent >::message_queue_name_
staticconstexprprivateinherited

Definition at line 137 of file multi_runner.h.

◆ inner_

inner* xrpl::detail::multi_runner_base< IsParent >::inner_
privateinherited

Definition at line 140 of file multi_runner.h.

◆ shared_mem_

boost::interprocess::shared_memory_object xrpl::detail::multi_runner_base< IsParent >::shared_mem_
privateinherited

Definition at line 142 of file multi_runner.h.

◆ region_

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

Definition at line 143 of file multi_runner.h.

◆ message_queue_

std::unique_ptr<boost::interprocess::message_queue> xrpl::detail::multi_runner_base< IsParent >::message_queue_
protectedinherited

Definition at line 146 of file multi_runner.h.