20#include <test/unit_test/multi_runner.h>
22#include <xrpl/beast/unit_test/amount.h>
24#include <boost/lexical_cast.hpp>
41fmtdur(
typename clock_type::duration
const& d)
44 auto const ms = duration_cast<milliseconds>(d);
46 return boost::lexical_cast<std::string>(ms.count()) +
"ms";
78 [](
run_time const& t1,
typename clock_type::duration
const& t2) {
79 return t1.second > t2;
82 if (iter !=
top.end())
94 top.resize(
top.size() - 1);
119 boost::container::static_vector<run_time, 2 * max_top> top_result;
120 top_result.resize(
top.size() + r.
top.size());
128 return t1.second > t2.second;
131 if (top_result.size() >
max_top)
145 s <<
"Longest suite times:\n";
146 for (
auto const& [name, dur] :
top)
158template <
bool IsParent>
165template <
bool IsParent>
169 return test_index_++;
172template <
bool IsParent>
179template <
bool IsParent>
183 any_failed_ = any_failed_ || v;
186template <
bool IsParent>
191 return results_.total;
194template <
bool IsParent>
199 return results_.suites;
202template <
bool IsParent>
209template <
bool IsParent>
216template <
bool IsParent>
224template <
bool IsParent>
233template <
bool IsParent>
245 shared_mem_ = boost::interprocess::shared_memory_object{
248 boost::interprocess::create_only_t,
249 boost::interprocess::open_only_t>{},
251 boost::interprocess::read_write};
257 std::make_unique<boost::interprocess::message_queue>(
258 boost::interprocess::create_only,
266 std::make_unique<boost::interprocess::message_queue>(
270 region_ = boost::interprocess::mapped_region{
288template <
bool IsParent>
299template <
bool IsParent>
306template <
bool IsParent>
313template <
bool IsParent>
320template <
bool IsParent>
327template <
bool IsParent>
334template <
bool IsParent>
341template <
bool IsParent>
348template <
bool IsParent>
356template <
bool IsParent>
368template <
bool IsParent>
375template <
bool IsParent>
382template <
bool IsParent>
417 unsigned int priority = 0;
419 buf.
data(), buf.
size(), recvd_size, priority);
422 assert(recvd_size == 1);
426 buf.
data(), buf.
size(), recvd_size, priority);
432 case MessageType::log:
436 case MessageType::test_start:
439 case MessageType::test_end:
450 <<
" reading unit test message queue.\n";
455 std::cerr <<
"Unknown error reading unit test message queue.\n";
473 os_ <<
"\nSuite: " << s
474 <<
" failed to complete. The child process may have crashed.\n";
481 return multi_runner_base<true>::any_failed();
487 return multi_runner_base<true>::tests();
493 return multi_runner_base<true>::suites();
499 multi_runner_base<true>::add_failures(failures);
508 : job_index_{checkout_job_index()}
509 , num_jobs_{num_jobs}
511 , print_log_{!quiet || print_log}
527 if (cur_count == last_count)
532 if (cur_count == last_count)
536 <<
": Assuming parent died, exiting.\n";
540 last_count = cur_count;
645template class multi_runner_base<true>;
646template 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