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

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

#include <multi_runner.h>

Inheritance diagram for ripple::test::multi_runner_child:
Inheritance graph
[legend]
Collaboration diagram for ripple::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 236 of file multi_runner.h.

Member Enumeration Documentation

◆ MessageType

Definition at line 150 of file multi_runner.h.

Constructor & Destructor Documentation

◆ multi_runner_child() [1/2]

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

◆ multi_runner_child() [2/2]

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

Definition at line 485 of file multi_runner.cpp.

◆ ~multi_runner_child()

ripple::test::multi_runner_child::~multi_runner_child ( )

Definition at line 524 of file multi_runner.cpp.

Member Function Documentation

◆ operator=()

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

◆ tests()

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

Definition at line 536 of file multi_runner.cpp.

◆ suites()

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

Definition at line 542 of file multi_runner.cpp.

◆ add_failures()

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

Definition at line 548 of file multi_runner.cpp.

◆ run_multi()

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

Definition at line 299 of file multi_runner.h.

◆ on_suite_begin()

void ripple::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 555 of file multi_runner.cpp.

◆ on_suite_end()

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

Called when a suite ends.

Reimplemented from beast::unit_test::runner.

Definition at line 562 of file multi_runner.cpp.

◆ on_case_begin()

void ripple::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 579 of file multi_runner.cpp.

◆ on_case_end()

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

Called when a new case ends.

Reimplemented from beast::unit_test::runner.

Definition at line 595 of file multi_runner.cpp.

◆ on_pass()

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

Called for each passing condition.

Reimplemented from beast::unit_test::runner.

Definition at line 601 of file multi_runner.cpp.

◆ on_fail()

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

Called for each failing condition.

Reimplemented from beast::unit_test::runner.

Definition at line 607 of file multi_runner.cpp.

◆ on_log()

void ripple::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 620 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 argumnet 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
inherited

Returns the argument string.

Definition at line 53 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 172 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 188 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 198 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 209 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 219 of file runner.h.

◆ testcase()

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

Definition at line 230 of file runner.h.

◆ pass()

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

Definition at line 246 of file runner.h.

◆ fail()

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

Definition at line 257 of file runner.h.

◆ log()

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

Definition at line 269 of file runner.h.

◆ message_queue_send()

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

Definition at line 152 of file multi_runner.cpp.

◆ checkout_test_index()

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

Definition at line 159 of file multi_runner.cpp.

◆ checkout_job_index()

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

Definition at line 162 of file multi_runner.cpp.

◆ any_failed() [1/2]

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

Definition at line 165 of file multi_runner.cpp.

◆ any_failed() [2/2]

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

Definition at line 181 of file multi_runner.cpp.

◆ add()

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

Definition at line 168 of file multi_runner.cpp.

◆ inc_keep_alive_count()

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

Definition at line 171 of file multi_runner.cpp.

◆ get_keep_alive_count()

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

Definition at line 174 of file multi_runner.cpp.

◆ print_results()

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

Definition at line 178 of file multi_runner.cpp.

Member Data Documentation

◆ job_index_

std::size_t ripple::test::multi_runner_child::job_index_
private

Definition at line 240 of file multi_runner.h.

◆ results_

detail::results ripple::test::multi_runner_child::results_
private

Definition at line 241 of file multi_runner.h.

◆ suite_results_

detail::suite_results ripple::test::multi_runner_child::suite_results_
private

Definition at line 242 of file multi_runner.h.

◆ case_results_

detail::case_results ripple::test::multi_runner_child::case_results_
private

Definition at line 243 of file multi_runner.h.

◆ num_jobs_

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

Definition at line 244 of file multi_runner.h.

◆ quiet_

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

Definition at line 245 of file multi_runner.h.

◆ print_log_

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

Definition at line 246 of file multi_runner.h.

◆ continue_keep_alive_

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

Definition at line 248 of file multi_runner.h.

◆ keep_alive_thread_

std::thread ripple::test::multi_runner_child::keep_alive_thread_
private

Definition at line 249 of file multi_runner.h.

◆ arg_

std::string beast::unit_test::runner::arg_
privateinherited

Definition at line 25 of file runner.h.

◆ default_

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

Definition at line 26 of file runner.h.

◆ failed_

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

Definition at line 27 of file runner.h.

◆ cond_

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

Definition at line 28 of file runner.h.

◆ mutex_

std::recursive_mutex beast::unit_test::runner::mutex_
privateinherited

Definition at line 29 of file runner.h.

◆ shared_mem_name_

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

Definition at line 135 of file multi_runner.h.

◆ message_queue_name_

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

Definition at line 138 of file multi_runner.h.

◆ inner_

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

Definition at line 142 of file multi_runner.h.

◆ shared_mem_

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

Definition at line 144 of file multi_runner.h.

◆ region_

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

Definition at line 145 of file multi_runner.h.

◆ message_queue_

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

Definition at line 148 of file multi_runner.h.