20#include <test/unit_test/multi_runner.h>
22#include <xrpl/beast/unit_test/amount.h>
24#include <boost/lexical_cast.hpp>
38fmtdur(
typename clock_type::duration
const& d)
41 auto const ms = duration_cast<milliseconds>(d);
43 return boost::lexical_cast<std::string>(ms.count()) +
"ms";
75 [](
run_time const& t1,
typename clock_type::duration
const& t2) {
76 return t1.second > t2;
79 if (iter !=
top.end())
91 top.resize(
top.size() - 1);
116 boost::container::static_vector<run_time, 2 * max_top> top_result;
117 top_result.resize(
top.size() + r.
top.size());
125 return t1.second > t2.second;
128 if (top_result.size() >
max_top)
142 s <<
"Longest suite times:\n";
143 for (
auto const& [name, dur] :
top)
155template <
bool IsParent>
162template <
bool IsParent>
166 return test_index_++;
169template <
bool IsParent>
176template <
bool IsParent>
180 any_failed_ = any_failed_ || v;
183template <
bool IsParent>
188 return results_.total;
191template <
bool IsParent>
196 return results_.suites;
199template <
bool IsParent>
206template <
bool IsParent>
213template <
bool IsParent>
221template <
bool IsParent>
230template <
bool IsParent>
242 shared_mem_ = boost::interprocess::shared_memory_object{
245 boost::interprocess::create_only_t,
246 boost::interprocess::open_only_t>{},
248 boost::interprocess::read_write};
254 std::make_unique<boost::interprocess::message_queue>(
255 boost::interprocess::create_only,
263 std::make_unique<boost::interprocess::message_queue>(
267 region_ = boost::interprocess::mapped_region{
285template <
bool IsParent>
296template <
bool IsParent>
303template <
bool IsParent>
310template <
bool IsParent>
317template <
bool IsParent>
324template <
bool IsParent>
331template <
bool IsParent>
338template <
bool IsParent>
345template <
bool IsParent>
353template <
bool IsParent>
365template <
bool IsParent>
372template <
bool IsParent>
379template <
bool IsParent>
414 unsigned int priority = 0;
416 buf.
data(), buf.
size(), recvd_size, priority);
419 assert(recvd_size == 1);
423 buf.
data(), buf.
size(), recvd_size, priority);
429 case MessageType::log:
433 case MessageType::test_start:
436 case MessageType::test_end:
447 <<
" reading unit test message queue.\n";
452 std::cerr <<
"Unknown error reading unit test message queue.\n";
470 os_ <<
"\nSuite: " << s
471 <<
" failed to complete. The child process may have crashed.\n";
478 return multi_runner_base<true>::any_failed();
484 return multi_runner_base<true>::tests();
490 return multi_runner_base<true>::suites();
496 multi_runner_base<true>::add_failures(failures);
505 : job_index_{checkout_job_index()}
506 , num_jobs_{num_jobs}
508 , print_log_{!quiet || print_log}
521 if (cur_count == last_count)
526 if (cur_count == last_count)
530 <<
": Assuming parent died, exiting.\n";
534 last_count = cur_count;
639template class multi_runner_base<true>;
640template class multi_runner_base<false>;
Utility for producing nicely composed output of amounts with units.
Associates a unit test type with metadata.
std::string full_name() const
Return the canonical suite name as a string.
std::size_t suites() const
std::size_t checkout_test_index()
void add(results const &r)
static constexpr const char * shared_mem_name_
std::size_t get_keep_alive_count()
boost::interprocess::shared_memory_object shared_mem_
std::size_t tests() const
void inc_keep_alive_count()
boost::interprocess::mapped_region region_
static constexpr const char * message_queue_name_
void add_failures(std::size_t failures)
void message_queue_send(MessageType mt, std::string const &s)
std::unique_ptr< boost::interprocess::message_queue > message_queue_
std::size_t checkout_job_index()
multi_runner_child(multi_runner_child const &)=delete
virtual void on_log(std::string const &s) override
Called when a test logs output.
detail::case_results case_results_
virtual void on_case_end() override
Called when a new case ends.
std::thread keep_alive_thread_
detail::suite_results suite_results_
virtual void on_case_begin(std::string const &name) override
Called when a new case starts.
void add_failures(std::size_t failures)
virtual void on_suite_end() override
Called when a suite ends.
std::atomic< bool > continue_keep_alive_
virtual void on_suite_begin(beast::unit_test::suite_info const &info) override
Called when a new suite starts.
virtual void on_pass() override
Called for each passing condition.
virtual void on_fail(std::string const &reason) override
Called for each failing condition.
std::size_t suites() const
std::size_t tests() const
std::size_t tests() const
std::atomic< bool > continue_message_queue_
std::size_t suites() const
std::thread message_queue_thread_
void add_failures(std::size_t failures)
std::set< std::string > running_suites_
std::string fmtdur(typename clock_type::duration const &d)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
T setprecision(T... args)
std::size_t suites() const
std::size_t checkout_job_index()
std::atomic< std::size_t > job_index_
boost::interprocess::interprocess_mutex m_
void inc_keep_alive_count()
void add(results const &r)
std::size_t get_keep_alive_count()
std::size_t checkout_test_index()
std::size_t tests() const
void merge(results const &r)
boost::beast::static_string< 256 > static_string
void add(suite_results const &r)
std::pair< static_string, typename clock_type::duration > run_time
boost::container::static_vector< run_time, max_top > top
clock_type::time_point start
void add(case_results const &r)
clock_type::time_point start