mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Update test logging text for change in newlines
This commit is contained in:
committed by
Vinnie Falco
parent
3de738429f
commit
39829a09cb
@@ -88,7 +88,6 @@ public:
|
||||
{
|
||||
using namespace jtx;
|
||||
for (std::size_t i = 1; i <= n; ++i)
|
||||
//env(offer("alice", XRP(i), iou(1)));
|
||||
env(offer("alice", XRP(1), iou(1)));
|
||||
}
|
||||
|
||||
@@ -153,7 +152,6 @@ public:
|
||||
using namespace jtx;
|
||||
for (std::size_t i = 1; i <= n; ++i)
|
||||
env(offer("alice", XRP(i), iou(1)));
|
||||
//env(offer("alice", XRP(1), iou(1)));
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -178,9 +176,8 @@ public:
|
||||
run()
|
||||
{
|
||||
auto const result = bfind(100, 9000,
|
||||
[&](std::size_t n)
|
||||
{ return oversize(n); });
|
||||
log << "Min oversize offers = " << result;
|
||||
[&](std::size_t n) { return oversize(n); });
|
||||
log << "Min oversize offers = " << result << '\n';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -218,10 +218,9 @@ private:
|
||||
{
|
||||
log <<
|
||||
"Expected: " << format_amount (expected.in) <<
|
||||
" : " << format_amount (expected.out);
|
||||
log <<
|
||||
" : " << format_amount (expected.out) << '\n' <<
|
||||
" Actual: " << format_amount (result.in) <<
|
||||
" : " << format_amount (result.out);
|
||||
" : " << format_amount (result.out) << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,59 +32,55 @@ class abstract_clock_test : public unit_test::suite
|
||||
{
|
||||
public:
|
||||
template <class Clock>
|
||||
void test (abstract_clock<Clock>& c)
|
||||
void test (std::string name, abstract_clock<Clock>& c)
|
||||
{
|
||||
{
|
||||
auto const t1 (c.now ());
|
||||
std::this_thread::sleep_for (
|
||||
std::chrono::milliseconds (1500));
|
||||
auto const t2 (c.now ());
|
||||
testcase (name);
|
||||
|
||||
std::stringstream ss;
|
||||
ss <<
|
||||
"t1= " << t1.time_since_epoch().count() <<
|
||||
", t2= " << t2.time_since_epoch().count() <<
|
||||
", elapsed= " << (t2 - t1).count();
|
||||
log << ss.str();
|
||||
}
|
||||
auto const t1 (c.now ());
|
||||
std::this_thread::sleep_for (
|
||||
std::chrono::milliseconds (1500));
|
||||
auto const t2 (c.now ());
|
||||
|
||||
log <<
|
||||
"t1= " << t1.time_since_epoch().count() <<
|
||||
", t2= " << t2.time_since_epoch().count() <<
|
||||
", elapsed= " << (t2 - t1).count() << std::endl;
|
||||
|
||||
pass ();
|
||||
}
|
||||
|
||||
void test_manual ()
|
||||
{
|
||||
testcase ("manual");
|
||||
|
||||
using clock_type = manual_clock<std::chrono::steady_clock>;
|
||||
clock_type c;
|
||||
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "now() = " << c.now().time_since_epoch().count() << std::endl;
|
||||
|
||||
auto c1 = c.now().time_since_epoch();
|
||||
c.set (clock_type::time_point (std::chrono::seconds(1)));
|
||||
ss << "now() = " << c.now().time_since_epoch().count() << std::endl;
|
||||
|
||||
auto c2 = c.now().time_since_epoch();
|
||||
c.set (clock_type::time_point (std::chrono::seconds(2)));
|
||||
ss << "now() = " << c.now().time_since_epoch().count() << std::endl;
|
||||
auto c3 = c.now().time_since_epoch();
|
||||
|
||||
log << ss.str();
|
||||
log <<
|
||||
"[" << c1.count () << "," << c2.count () <<
|
||||
"," << c3.count () << "]" << std::endl;
|
||||
|
||||
pass ();
|
||||
}
|
||||
|
||||
void run ()
|
||||
{
|
||||
log << "steady_clock";
|
||||
test (get_abstract_clock<
|
||||
test ("steady_clock", get_abstract_clock<
|
||||
std::chrono::steady_clock>());
|
||||
|
||||
log << "system_clock";
|
||||
test (get_abstract_clock<
|
||||
test ("system_clock", get_abstract_clock<
|
||||
std::chrono::system_clock>());
|
||||
|
||||
log << "high_resolution_clock";
|
||||
test (get_abstract_clock<
|
||||
test ("high_resolution_clock", get_abstract_clock<
|
||||
std::chrono::high_resolution_clock>());
|
||||
|
||||
log << "manual_clock";
|
||||
test_manual ();
|
||||
|
||||
pass ();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -18,66 +18,35 @@ namespace unit_test {
|
||||
/** A suite that prints the list of globally defined suites. */
|
||||
class print_test : public suite
|
||||
{
|
||||
private:
|
||||
template <class = void>
|
||||
void
|
||||
do_run();
|
||||
|
||||
public:
|
||||
template <class = void>
|
||||
static
|
||||
std::string
|
||||
prefix (suite_info const& s);
|
||||
|
||||
template <class = void>
|
||||
void
|
||||
print (suite_list const& c);
|
||||
|
||||
void
|
||||
run()
|
||||
{
|
||||
do_run();
|
||||
std::size_t manual = 0;
|
||||
std::size_t total = 0;
|
||||
|
||||
auto prefix = [](suite_info const& s)
|
||||
{
|
||||
return s.manual() ? "|M| " : " ";
|
||||
};
|
||||
|
||||
for (auto const& s : global_suites())
|
||||
{
|
||||
log << prefix (s) << s.full_name() << '\n';
|
||||
|
||||
if (s.manual())
|
||||
++manual;
|
||||
++total;
|
||||
}
|
||||
|
||||
log <<
|
||||
amount (total, "suite") << " total, " <<
|
||||
amount (manual, "manual suite") << std::endl;
|
||||
|
||||
pass();
|
||||
}
|
||||
};
|
||||
|
||||
template <class>
|
||||
void
|
||||
print_test::do_run()
|
||||
{
|
||||
log << "------------------------------------------";
|
||||
print (global_suites());
|
||||
log << "------------------------------------------";
|
||||
pass();
|
||||
}
|
||||
|
||||
template <class>
|
||||
std::string
|
||||
print_test::prefix (suite_info const& s)
|
||||
{
|
||||
if (s.manual())
|
||||
return "|M| ";
|
||||
return " ";
|
||||
}
|
||||
|
||||
template <class>
|
||||
void
|
||||
print_test::print (suite_list const& c)
|
||||
{
|
||||
std::size_t manual (0);
|
||||
for (auto const& s : c)
|
||||
{
|
||||
log <<
|
||||
prefix (s) <<
|
||||
s.full_name();
|
||||
if (s.manual())
|
||||
++manual;
|
||||
}
|
||||
log <<
|
||||
amount (c.size(), "suite") << " total, " <<
|
||||
amount (manual, "manual suite")
|
||||
;
|
||||
}
|
||||
|
||||
BEAST_DEFINE_TESTSUITE_MANUAL(print,unit_test,beast);
|
||||
|
||||
} // unit_test
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
}
|
||||
auto const elapsed = clock_type::now() - start;
|
||||
log << setw(12) << what << " " <<
|
||||
duration<double>(elapsed) << "s";
|
||||
duration<double>(elapsed) << "s" << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -461,7 +461,7 @@ public:
|
||||
std::setw (13) << std::setprecision (5) <<
|
||||
results.windowed_score << " | " <<
|
||||
std::left <<
|
||||
results.elapsed.count();
|
||||
results.elapsed.count() << std::endl;
|
||||
pass ();
|
||||
}
|
||||
|
||||
@@ -469,8 +469,8 @@ public:
|
||||
run()
|
||||
{
|
||||
log <<
|
||||
"name | collision | distribution | windowed | time (milliseconds)" << std::endl <<
|
||||
"----------------------------------------+---------------+---------------+---------------+--------------------";
|
||||
"name | collision | distribution | windowed | time (milliseconds)" << '\n' <<
|
||||
"----------------------------------------+---------------+---------------+---------------+--------------------" << std::endl;
|
||||
|
||||
//test_hasher <hash_append_tests::prng_hasher<>, SlowKey> ("prng_hasher <SlowKey>", 10000);
|
||||
//test_hasher <hash_append_tests::prng_hasher<>, FastKey> ("prng_hasher <FastKey>", 100000);
|
||||
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
}
|
||||
auto const elapsed = clock_type::now() - start;
|
||||
log << setw(12) << what << " " <<
|
||||
duration<double>(elapsed).count() << "s";
|
||||
duration<double>(elapsed).count() << "s" << std::endl;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -147,10 +147,11 @@ public:
|
||||
|
||||
void run ()
|
||||
{
|
||||
log << "_DEBUG = " << envDebug ();
|
||||
log << "BEAST_DEBUG = " << beastDebug ();
|
||||
log << "BEAST_FORCE_DEBUG = " << beastForceDebug ();
|
||||
log << "sizeof(std::size_t) = " << sizeof(std::size_t);
|
||||
log <<
|
||||
"_DEBUG = " << envDebug () << '\n' <<
|
||||
"BEAST_DEBUG = " << beastDebug () << '\n' <<
|
||||
"BEAST_FORCE_DEBUG = " << beastForceDebug () << '\n' <<
|
||||
"sizeof(std::size_t) = " << sizeof(std::size_t) << std::endl;
|
||||
pass ();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -661,15 +661,14 @@ public:
|
||||
if (w < test.first.size())
|
||||
w = test.first.size();
|
||||
log <<
|
||||
"\n" <<
|
||||
threads << " Thread" << (threads > 1 ? "s" : "") << ", " <<
|
||||
default_items << " Objects";
|
||||
default_items << " Objects" << std::endl;
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << std::left << setw(10) << "Backend" << std::right;
|
||||
for (auto const& test : tests)
|
||||
ss << " " << setw(w) << test.first;
|
||||
log << ss.str();
|
||||
log << ss.str() << std::endl;
|
||||
}
|
||||
|
||||
for (auto const& config_string : config_strings)
|
||||
@@ -689,7 +688,7 @@ public:
|
||||
ss << " " << setw(w) << to_string(
|
||||
do_test (test.second, config, params));
|
||||
ss << " " << to_string(config);
|
||||
log << ss.str();
|
||||
log << ss.str() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +220,8 @@ private:
|
||||
if (acceptor_.is_open())
|
||||
{
|
||||
if (ec != boost::asio::error::operation_aborted)
|
||||
test_.log << what << ": " << ec.message();
|
||||
test_.log << what <<
|
||||
": " << ec.message() << std::endl;
|
||||
acceptor_.close();
|
||||
}
|
||||
}
|
||||
@@ -292,7 +293,8 @@ private:
|
||||
if (socket_.is_open())
|
||||
{
|
||||
if (ec != boost::asio::error::operation_aborted)
|
||||
test_.log << "[server] " << what << ": " << ec.message();
|
||||
test_.log << "[server] " << what <<
|
||||
": " << ec.message() << std::endl;
|
||||
socket_.close();
|
||||
timer_.cancel();
|
||||
}
|
||||
@@ -305,7 +307,7 @@ private:
|
||||
return;
|
||||
if (ec)
|
||||
return fail("timer", ec);
|
||||
test_.log << "[server] timeout";
|
||||
test_.log << "[server] timeout" << std::endl;
|
||||
socket_.close();
|
||||
}
|
||||
|
||||
@@ -329,7 +331,7 @@ private:
|
||||
{
|
||||
if (ec == boost::asio::error::eof)
|
||||
{
|
||||
server_.test_.log << "[server] read: EOF";
|
||||
server_.test_.log << "[server] read: EOF" << std::endl;
|
||||
return stream_.async_shutdown(strand_.wrap(std::bind(
|
||||
&Connection::on_shutdown, shared_from_this(),
|
||||
beast::asio::placeholders::error)));
|
||||
@@ -442,7 +444,8 @@ private:
|
||||
if (socket_.is_open())
|
||||
{
|
||||
if (ec != boost::asio::error::operation_aborted)
|
||||
test_.log << "[client] " << what << ": " << ec.message();
|
||||
test_.log << "[client] " << what <<
|
||||
": " << ec.message() << std::endl;
|
||||
socket_.close();
|
||||
timer_.cancel();
|
||||
}
|
||||
|
||||
@@ -107,8 +107,9 @@ public:
|
||||
|
||||
expect (current_protocol >= minimum_protocol);
|
||||
|
||||
log << " Ripple Version: " << BuildInfo::getVersionString();
|
||||
log << " Protocol Version: " << to_string (current_protocol);
|
||||
log <<
|
||||
" Ripple Version: " << BuildInfo::getVersionString() << '\n' <<
|
||||
" Protocol Version: " << to_string (current_protocol) << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -136,8 +136,9 @@ public:
|
||||
|
||||
if (object1.getSerializer () == object2.getSerializer ())
|
||||
{
|
||||
log << "O1: " << object1.getJson (0);
|
||||
log << "O2: " << object2.getJson (0);
|
||||
log <<
|
||||
"O1: " << object1.getJson (0) << '\n' <<
|
||||
"O2: " << object2.getJson (0) << std::endl;
|
||||
fail ("STObject error 4");
|
||||
}
|
||||
else
|
||||
|
||||
@@ -61,8 +61,9 @@ public:
|
||||
|
||||
if (copy != j)
|
||||
{
|
||||
log << j.getJson (0);
|
||||
log << copy.getJson (0);
|
||||
log <<
|
||||
"j=" << j.getJson (0) << '\n' <<
|
||||
"copy=" << copy.getJson (0) << std::endl;
|
||||
fail ("Transaction fails serialize/deserialize test");
|
||||
}
|
||||
else
|
||||
@@ -76,8 +77,9 @@ public:
|
||||
|
||||
if (STObject (j) != parsed.object)
|
||||
{
|
||||
log << "ORIG: " << j.getJson (0);
|
||||
log << "BUILT " << parsed.object->getJson (0);
|
||||
log <<
|
||||
"ORIG: " << j.getJson (0) << '\n' <<
|
||||
"BUILT " << parsed.object->getJson (0) << std::endl;
|
||||
fail ("Built a different transaction");
|
||||
}
|
||||
else
|
||||
|
||||
@@ -68,7 +68,7 @@ class digest_test : public beast::unit_test::suite
|
||||
result = d;
|
||||
}
|
||||
|
||||
log << " " << name << ":";
|
||||
log << " " << name << ":" << '\n';
|
||||
|
||||
auto const sum = std::accumulate(
|
||||
results.begin(), results.end(),
|
||||
@@ -78,7 +78,7 @@ class digest_test : public beast::unit_test::suite
|
||||
auto ms = duration_cast<milliseconds>(sum) - s;
|
||||
log <<
|
||||
" Total Time = " << s.count() <<
|
||||
"." << ms.count() << " seconds";
|
||||
"." << ms.count() << " seconds" << std::endl;
|
||||
}
|
||||
|
||||
auto const mean = sum / results.size();
|
||||
@@ -87,7 +87,7 @@ class digest_test : public beast::unit_test::suite
|
||||
auto ms = duration_cast<milliseconds>(mean) - s;
|
||||
log <<
|
||||
" Mean Time = " << s.count() <<
|
||||
"." << ms.count() << " seconds";
|
||||
"." << ms.count() << " seconds" << std::endl;
|
||||
}
|
||||
|
||||
std::vector<nanoseconds::rep> diff(results.size());
|
||||
@@ -108,7 +108,7 @@ class digest_test : public beast::unit_test::suite
|
||||
auto ms = duration_cast<milliseconds>(stddev) - s;
|
||||
log <<
|
||||
" Std Dev = " << s.count() <<
|
||||
"." << ms.count() << " seconds";
|
||||
"." << ms.count() << " seconds" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
|
||||
if (!map.addItem (std::move(*item), false, false))
|
||||
{
|
||||
log << "Unable to add item to map";
|
||||
log << "Unable to add item to map\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -66,14 +66,16 @@ public:
|
||||
{
|
||||
if (!map.delItem (item))
|
||||
{
|
||||
log << "Unable to remove item from map";
|
||||
log << "Unable to remove item from map\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (beforeHash != map.getHash ())
|
||||
{
|
||||
log << "Hashes do not match " << beforeHash << " " << map.getHash ();
|
||||
log <<
|
||||
"Hashes do not match " << beforeHash <<
|
||||
" " << map.getHash () << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -82,10 +84,10 @@ public:
|
||||
|
||||
void run()
|
||||
{
|
||||
std::cerr << "Run, version 1" << std::endl;
|
||||
log << "Run, version 1\n" << std::endl;
|
||||
run(SHAMap::version{1});
|
||||
|
||||
std::cerr << "Run, version 2" << std::endl;
|
||||
log << "Run, version 2\n" << std::endl;
|
||||
run(SHAMap::version{2});
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
|
||||
// Only write the string if the level at least equals the threshold.
|
||||
if (level >= threshold())
|
||||
suite_.log << s << partition_ << text;
|
||||
suite_.log << s << partition_ << text << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -383,7 +383,7 @@ Env::postconditions(JTx const& jt, TER ter, bool didApply)
|
||||
transToken(*jt.ter) + " (" +
|
||||
transHuman(*jt.ter) + ")"))
|
||||
{
|
||||
test.log << pretty(jt.jv);
|
||||
test.log << pretty(jt.jv) << std::endl;
|
||||
// Don't check postconditions if
|
||||
// we didn't get the expected result.
|
||||
return;
|
||||
@@ -392,7 +392,7 @@ Env::postconditions(JTx const& jt, TER ter, bool didApply)
|
||||
{
|
||||
if (trace_ > 0)
|
||||
--trace_;
|
||||
test.log << pretty(jt.jv);
|
||||
test.log << pretty(jt.jv) << std::endl;
|
||||
}
|
||||
for (auto const& f : jt.requires)
|
||||
f(*this);
|
||||
@@ -447,9 +447,8 @@ Env::autofill (JTx& jt)
|
||||
}
|
||||
catch (parse_error const&)
|
||||
{
|
||||
test.log <<
|
||||
"parse failed:\n" <<
|
||||
pretty(jv);
|
||||
test.log << "parse failed:\n" <<
|
||||
pretty(jv) << std::endl;
|
||||
Rethrow();
|
||||
}
|
||||
}
|
||||
@@ -466,9 +465,8 @@ Env::st (JTx const& jt)
|
||||
}
|
||||
catch(jtx::parse_error const&)
|
||||
{
|
||||
test.log <<
|
||||
"Exception: parse_error\n" <<
|
||||
pretty(jt.jv);
|
||||
test.log << "Exception: parse_error\n" <<
|
||||
pretty(jt.jv) << std::endl;
|
||||
Rethrow();
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ msig::operator()(Env& env, JTx& jt) const
|
||||
}
|
||||
catch(parse_error const&)
|
||||
{
|
||||
env.test.log << pretty(jt.jv);
|
||||
env.test.log << pretty(jt.jv) << std::endl;
|
||||
Rethrow();
|
||||
}
|
||||
auto& js = jt[sfSigners.getJsonName()];
|
||||
|
||||
Reference in New Issue
Block a user