1#include <test/unit_test/multi_runner.h>
3#include <xrpl/beast/unit_test/amount.h>
5#include <boost/lexical_cast.hpp>
18fmtdur(
typename clock_type::duration
const& d)
21 auto const ms = duration_cast<milliseconds>(d);
23 return boost::lexical_cast<std::string>(ms.count()) +
"ms";
55 [](
run_time const& t1,
typename clock_type::duration
const& t2) {
56 return t1.second > t2;
59 if (iter !=
top.end())
96 boost::container::static_vector<run_time, 2 * max_top> top_result;
97 top_result.resize(
top.size() + r.
top.size());
105 return t1.second > t2.second;
108 if (top_result.size() >
max_top)
122 s <<
"Longest suite times:\n";
123 for (
auto const& [name, dur] :
top)
124 s <<
std::setw(8) <<
fmtdur(dur) <<
" " << name <<
'\n';
135template <
bool IsParent>
142template <
bool IsParent>
146 return test_index_++;
149template <
bool IsParent>
156template <
bool IsParent>
160 any_failed_ = any_failed_ || v;
163template <
bool IsParent>
168 return results_.total;
171template <
bool IsParent>
176 return results_.suites;
179template <
bool IsParent>
186template <
bool IsParent>
193template <
bool IsParent>
201template <
bool IsParent>
210template <
bool IsParent>
222 shared_mem_ = boost::interprocess::shared_memory_object{
225 boost::interprocess::create_only_t,
226 boost::interprocess::open_only_t>{},
228 boost::interprocess::read_write};
235 boost::interprocess::create_only,
247 region_ = boost::interprocess::mapped_region{
265template <
bool IsParent>
276template <
bool IsParent>
283template <
bool IsParent>
290template <
bool IsParent>
297template <
bool IsParent>
304template <
bool IsParent>
311template <
bool IsParent>
318template <
bool IsParent>
325template <
bool IsParent>
333template <
bool IsParent>
345template <
bool IsParent>
352template <
bool IsParent>
359template <
bool IsParent>
375multi_runner_parent::multi_runner_parent() : os_(
std::
cout)
396 unsigned int priority = 0;
398 buf.
data(), buf.
size(), recvd_size, priority);
401 assert(recvd_size == 1);
405 buf.
data(), buf.
size(), recvd_size, priority);
411 case MessageType::log:
415 case MessageType::test_start:
418 case MessageType::test_end:
429 <<
" reading unit test message queue.\n";
434 std::cerr <<
"Unknown error reading unit test message queue.\n";
454 os_ <<
"\nSuite: " << s
455 <<
" failed to complete. The child process may have crashed.\n";
462 return multi_runner_base<true>::any_failed();
468 return multi_runner_base<true>::tests();
474 return multi_runner_base<true>::suites();
480 multi_runner_base<true>::add_failures(failures);
489 : job_index_{checkout_job_index()}
490 , num_jobs_{num_jobs}
492 , print_log_{!quiet || print_log}
505 if (cur_count == last_count)
510 if (cur_count == last_count)
514 <<
": Assuming parent died, exiting.\n";
518 last_count = cur_count;
635template class multi_runner_base<true>;
636template 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::unique_ptr< boost::interprocess::message_queue > message_queue_
static constexpr char const * message_queue_name_
void message_queue_send(MessageType mt, std::string const &s)
boost::interprocess::mapped_region region_
void add_failures(std::size_t failures)
static constexpr char const * shared_mem_name_
void add(results const &r)
std::size_t checkout_job_index()
boost::interprocess::shared_memory_object shared_mem_
std::size_t checkout_test_index()
std::size_t suites() const
std::size_t get_keep_alive_count()
std::size_t tests() const
void inc_keep_alive_count()
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(std::chrono::duration< Period, Rep > const &d)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
T setprecision(T... args)
boost::interprocess::interprocess_mutex m_
std::size_t suites() const
void inc_keep_alive_count()
std::atomic< std::size_t > job_index_
void add(results const &r)
std::size_t checkout_test_index()
std::size_t checkout_job_index()
std::size_t tests() const
std::size_t get_keep_alive_count()
void add(suite_results const &r)
boost::beast::static_string< 256 > static_string
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 merge(results const &r)
void add(case_results const &r)
clock_type::time_point start