make tests print to stdout instead of stderr
This commit is contained in:
parent
e99d907c72
commit
a087a283de
|
@ -146,7 +146,7 @@ struct dht_server
|
|||
entry msg = bdecode(buffer, buffer + bytes_transferred);
|
||||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
std::cerr << msg << std::endl;
|
||||
std::cout << msg << std::endl;
|
||||
#endif
|
||||
++m_dht_requests;
|
||||
}
|
||||
|
|
|
@ -184,11 +184,11 @@ void test_swarm(int flags)
|
|||
float average2 = sum_dl_rate2 / float(count_dl_rates2);
|
||||
float average3 = sum_dl_rate3 / float(count_dl_rates3);
|
||||
|
||||
std::cerr << average2 << std::endl;
|
||||
std::cerr << "average rate: " << (average2 / 1000.f) << "kB/s - "
|
||||
std::cout << average2 << std::endl;
|
||||
std::cout << "average rate: " << (average2 / 1000.f) << "kB/s - "
|
||||
<< (average3 / 1000.f) << "kB/s" << std::endl;
|
||||
|
||||
if (tor2.status().is_seeding && tor3.status().is_seeding) std::cerr << "done\n";
|
||||
if (tor2.status().is_seeding && tor3.status().is_seeding) std::cout << "done\n";
|
||||
|
||||
// make sure the files are deleted
|
||||
ses1.remove_torrent(tor1, lt::session::delete_files);
|
||||
|
|
|
@ -1627,7 +1627,7 @@ void test_routing_table(address(&rand_addr)())
|
|||
//TODO: 2 test num_global_nodes
|
||||
//TODO: 2 test need_refresh
|
||||
|
||||
print_state(std::cerr, table);
|
||||
print_state(std::cout, table);
|
||||
|
||||
table.for_each_node(node_push_back, nop, &nodes);
|
||||
|
||||
|
@ -2832,7 +2832,7 @@ TORRENT_TEST(routing_table_uniform)
|
|||
// i.e. no more than 5 levels
|
||||
TEST_EQUAL(tbl.num_active_buckets(), 5);
|
||||
|
||||
print_state(std::cerr, tbl);
|
||||
print_state(std::cout, tbl);
|
||||
}
|
||||
|
||||
TORRENT_TEST(routing_table_balance)
|
||||
|
@ -2855,7 +2855,7 @@ TORRENT_TEST(routing_table_balance)
|
|||
std::printf("num_active_buckets: %d\n", tbl.num_active_buckets());
|
||||
TEST_EQUAL(tbl.num_active_buckets(), 2);
|
||||
|
||||
print_state(std::cerr, tbl);
|
||||
print_state(std::cout, tbl);
|
||||
}
|
||||
|
||||
TORRENT_TEST(routing_table_extended)
|
||||
|
@ -2882,7 +2882,7 @@ TORRENT_TEST(routing_table_extended)
|
|||
}
|
||||
TEST_EQUAL(tbl.num_active_buckets(), 6);
|
||||
|
||||
print_state(std::cerr, tbl);
|
||||
print_state(std::cout, tbl);
|
||||
}
|
||||
|
||||
void inserter(std::set<node_id>* nodes, node_entry const& ne)
|
||||
|
@ -2915,7 +2915,7 @@ TORRENT_TEST(routing_table_set_id)
|
|||
std::set<node_id> original_nodes;
|
||||
tbl.for_each_node(std::bind(&inserter, &original_nodes, _1));
|
||||
|
||||
print_state(std::cerr, tbl);
|
||||
print_state(std::cout, tbl);
|
||||
|
||||
id = to_hash("ffffffffffffffffffffffffffffffffffffffff");
|
||||
|
||||
|
@ -2933,7 +2933,7 @@ TORRENT_TEST(routing_table_set_id)
|
|||
// all remaining nodes also exist in the original nodes
|
||||
TEST_EQUAL(intersection.size(), remaining_nodes.size());
|
||||
|
||||
print_state(std::cerr, tbl);
|
||||
print_state(std::cout, tbl);
|
||||
}
|
||||
|
||||
TORRENT_TEST(node_set_id)
|
||||
|
|
|
@ -52,7 +52,7 @@ struct log_t : libtorrent::dht::dht_logger
|
|||
{
|
||||
va_list v;
|
||||
va_start(v, fmt);
|
||||
vfprintf(stderr, fmt, v);
|
||||
std::vprintf(fmt, v);
|
||||
va_end(v);
|
||||
}
|
||||
|
||||
|
|
|
@ -472,7 +472,7 @@ std::shared_ptr<torrent_info> setup_peer(tcp::socket& s, sha1_hash& ih
|
|||
// rejected aren't requested again
|
||||
TORRENT_TEST(reject_fast)
|
||||
{
|
||||
std::cerr << "\n === test reject ===\n" << std::endl;
|
||||
std::cout << "\n === test reject ===\n" << std::endl;
|
||||
|
||||
sha1_hash ih;
|
||||
std::shared_ptr<lt::session> ses;
|
||||
|
@ -541,7 +541,7 @@ TORRENT_TEST(reject_fast)
|
|||
|
||||
TORRENT_TEST(invalid_suggest)
|
||||
{
|
||||
std::cerr << "\n === test suggest ===\n" << std::endl;
|
||||
std::cout << "\n === test suggest ===\n" << std::endl;
|
||||
|
||||
sha1_hash ih;
|
||||
std::shared_ptr<lt::session> ses;
|
||||
|
@ -581,7 +581,7 @@ TORRENT_TEST(invalid_suggest)
|
|||
|
||||
TORRENT_TEST(reject_suggest)
|
||||
{
|
||||
std::cerr << "\n === test suggest ===\n" << std::endl;
|
||||
std::cout << "\n === test suggest ===\n" << std::endl;
|
||||
|
||||
sha1_hash ih;
|
||||
std::shared_ptr<lt::session> ses;
|
||||
|
@ -660,7 +660,7 @@ TORRENT_TEST(reject_suggest)
|
|||
|
||||
TORRENT_TEST(suggest_order)
|
||||
{
|
||||
std::cerr << "\n === test suggest ===\n" << std::endl;
|
||||
std::cout << "\n === test suggest ===\n" << std::endl;
|
||||
|
||||
sha1_hash ih;
|
||||
std::shared_ptr<lt::session> ses;
|
||||
|
@ -720,7 +720,7 @@ TORRENT_TEST(suggest_order)
|
|||
|
||||
TORRENT_TEST(multiple_bitfields)
|
||||
{
|
||||
std::cerr << "\n === test multiple bitfields ===\n" << std::endl;
|
||||
std::cout << "\n === test multiple bitfields ===\n" << std::endl;
|
||||
|
||||
sha1_hash ih;
|
||||
std::shared_ptr<lt::session> ses;
|
||||
|
@ -754,7 +754,7 @@ TORRENT_TEST(multiple_bitfields)
|
|||
|
||||
TORRENT_TEST(multiple_have_all)
|
||||
{
|
||||
std::cerr << "\n === test multiple have_all ===\n" << std::endl;
|
||||
std::cout << "\n === test multiple have_all ===\n" << std::endl;
|
||||
|
||||
sha1_hash ih;
|
||||
std::shared_ptr<lt::session> ses;
|
||||
|
@ -788,7 +788,7 @@ TORRENT_TEST(dont_have)
|
|||
{
|
||||
using namespace libtorrent::detail;
|
||||
|
||||
std::cerr << "\n === test dont_have ===\n" << std::endl;
|
||||
std::cout << "\n === test dont_have ===\n" << std::endl;
|
||||
|
||||
sha1_hash ih;
|
||||
torrent_handle th;
|
||||
|
@ -891,7 +891,7 @@ TORRENT_TEST(invalid_metadata_request)
|
|||
{
|
||||
using namespace libtorrent::detail;
|
||||
|
||||
std::cerr << "\n === test invalid metadata ===\n" << std::endl;
|
||||
std::cout << "\n === test invalid metadata ===\n" << std::endl;
|
||||
|
||||
sha1_hash ih;
|
||||
std::shared_ptr<lt::session> ses;
|
||||
|
@ -944,7 +944,7 @@ TORRENT_TEST(invalid_metadata_request)
|
|||
|
||||
TORRENT_TEST(invalid_request)
|
||||
{
|
||||
std::cerr << "\n === test request ===\n" << std::endl;
|
||||
std::cout << "\n === test request ===\n" << std::endl;
|
||||
|
||||
sha1_hash ih;
|
||||
std::shared_ptr<lt::session> ses;
|
||||
|
@ -1003,13 +1003,13 @@ void have_all_test(bool const incoming)
|
|||
|
||||
TORRENT_TEST(outgoing_have_all)
|
||||
{
|
||||
std::cerr << "\n === test outgoing have-all ===\n" << std::endl;
|
||||
std::cout << "\n === test outgoing have-all ===\n" << std::endl;
|
||||
have_all_test(true);
|
||||
}
|
||||
|
||||
TORRENT_TEST(incoming_have_all)
|
||||
{
|
||||
std::cerr << "\n === test outgoing have-all ===\n" << std::endl;
|
||||
std::cout << "\n === test outgoing have-all ===\n" << std::endl;
|
||||
have_all_test(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@ std::tuple<int, int, bool> feed_bytes(http_parser& parser, char const* str)
|
|||
std::get<0>(ret) += payload;
|
||||
std::get<1>(ret) += protocol;
|
||||
std::get<2>(ret) |= error;
|
||||
// std::cerr << payload << ", " << protocol << ", " << chunk_size << std::endl;
|
||||
TORRENT_ASSERT(payload + protocol == chunk_size || std::get<2>(ret));
|
||||
}
|
||||
TEST_CHECK(prev == std::make_tuple(0, 0, false) || ret == prev || std::get<2>(ret));
|
||||
|
|
|
@ -87,7 +87,7 @@ void test_lsd()
|
|||
|
||||
TEST_CHECK(tor2.status().is_seeding);
|
||||
|
||||
if (tor2.status().is_seeding) std::cerr << "done\n";
|
||||
if (tor2.status().is_seeding) std::cout << "done\n";
|
||||
|
||||
// this allows shutting down the sessions in parallel
|
||||
p1 = ses1.abort();
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace
|
|||
, portmap_protocol const protocol, error_code const& err
|
||||
, aux::portmap_transport transport) override
|
||||
{
|
||||
std::cerr
|
||||
std::cout
|
||||
<< "mapping: " << mapping
|
||||
<< ", port: " << port
|
||||
<< ", protocol: " << static_cast<int>(protocol)
|
||||
|
@ -64,7 +64,7 @@ namespace
|
|||
|
||||
virtual void log_portmap(aux::portmap_transport transport, char const* msg) const override
|
||||
{
|
||||
std::cerr << msg << std::endl;
|
||||
std::cout << msg << std::endl;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
@ -77,7 +77,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
if (argc != 3)
|
||||
{
|
||||
std::cerr << "usage: " << argv[0] << " tcp-port udp-port" << std::endl;
|
||||
std::cout << "usage: " << argv[0] << " tcp-port udp-port" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -93,22 +93,22 @@ int main(int argc, char* argv[])
|
|||
error_code ec;
|
||||
timer.expires_from_now(seconds(2), ec);
|
||||
timer.async_wait([&] (error_code const&) { ios.io_service::stop(); });
|
||||
std::cerr << "mapping ports TCP: " << argv[1]
|
||||
std::cout << "mapping ports TCP: " << argv[1]
|
||||
<< " UDP: " << argv[2] << std::endl;
|
||||
|
||||
ios.reset();
|
||||
ios.run(ec);
|
||||
timer.expires_from_now(seconds(2), ec);
|
||||
timer.async_wait([&] (error_code const&) { ios.io_service::stop(); });
|
||||
std::cerr << "removing mapping " << tcp_map << std::endl;
|
||||
std::cout << "removing mapping " << tcp_map << std::endl;
|
||||
natpmp_handler->delete_mapping(tcp_map);
|
||||
|
||||
ios.reset();
|
||||
ios.run(ec);
|
||||
std::cerr << "removing mappings" << std::endl;
|
||||
std::cout << "removing mappings" << std::endl;
|
||||
natpmp_handler->close();
|
||||
|
||||
ios.reset();
|
||||
ios.run(ec);
|
||||
std::cerr << "closing" << std::endl;
|
||||
std::cout << "closing" << std::endl;
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ void test_pex()
|
|||
|
||||
TEST_CHECK(st1.num_peers == 2 && st2.num_peers == 2 && st3.num_peers == 2)
|
||||
|
||||
if (!tor2.status().is_seeding && tor3.status().is_seeding) std::cerr << "done\n";
|
||||
if (!tor2.status().is_seeding && tor3.status().is_seeding) std::cout << "done\n";
|
||||
|
||||
// this allows shutting down the sessions in parallel
|
||||
p1 = ses1.abort();
|
||||
|
|
|
@ -141,9 +141,9 @@ void test_transfer(settings_pack const& sett, bool test_deprecated = false)
|
|||
// set half of the pieces to priority 0
|
||||
std::fill(priorities.begin(), priorities.begin() + (num_pieces / 2), 0);
|
||||
tor2.prioritize_pieces(priorities);
|
||||
std::cerr << "setting priorities: ";
|
||||
std::copy(priorities.begin(), priorities.end(), std::ostream_iterator<int>(std::cerr, ", "));
|
||||
std::cerr << std::endl;
|
||||
std::cout << "setting priorities: ";
|
||||
std::copy(priorities.begin(), priorities.end(), std::ostream_iterator<int>(std::cout, ", "));
|
||||
std::cout << std::endl;
|
||||
|
||||
for (int i = 0; i < 200; ++i)
|
||||
{
|
||||
|
@ -166,7 +166,7 @@ void test_transfer(settings_pack const& sett, bool test_deprecated = false)
|
|||
static char const* state_str[] =
|
||||
{"checking (q)", "checking", "dl metadata"
|
||||
, "downloading", "finished", "seeding", "allocating", "checking (r)"};
|
||||
std::cerr << "st2 state: " << state_str[st2.state] << std::endl;
|
||||
std::cout << "st2 state: " << state_str[st2.state] << std::endl;
|
||||
}
|
||||
|
||||
TEST_CHECK(st1.state == torrent_status::seeding
|
||||
|
@ -186,20 +186,20 @@ void test_transfer(settings_pack const& sett, bool test_deprecated = false)
|
|||
TEST_CHECK(tor2.status().is_finished);
|
||||
|
||||
if (tor2.status().is_finished)
|
||||
std::cerr << "torrent is finished (50% complete)" << std::endl;
|
||||
std::cout << "torrent is finished (50% complete)" << std::endl;
|
||||
else return;
|
||||
|
||||
std::vector<int> priorities2 = tor2.piece_priorities();
|
||||
std::copy(priorities2.begin(), priorities2.end(), std::ostream_iterator<int>(std::cerr, ", "));
|
||||
std::cerr << std::endl;
|
||||
std::copy(priorities2.begin(), priorities2.end(), std::ostream_iterator<int>(std::cout, ", "));
|
||||
std::cout << std::endl;
|
||||
TEST_CHECK(std::equal(priorities.begin(), priorities.end(), priorities2.begin()));
|
||||
|
||||
std::cerr << "force recheck" << std::endl;
|
||||
std::cout << "force recheck" << std::endl;
|
||||
tor2.force_recheck();
|
||||
|
||||
priorities2 = tor2.piece_priorities();
|
||||
std::copy(priorities2.begin(), priorities2.end(), std::ostream_iterator<int>(std::cerr, ", "));
|
||||
std::cerr << std::endl;
|
||||
std::copy(priorities2.begin(), priorities2.end(), std::ostream_iterator<int>(std::cout, ", "));
|
||||
std::cout << std::endl;
|
||||
TEST_CHECK(std::equal(priorities.begin(), priorities.end(), priorities2.begin()));
|
||||
|
||||
peer_disconnects = 0;
|
||||
|
@ -216,7 +216,7 @@ void test_transfer(settings_pack const& sett, bool test_deprecated = false)
|
|||
st2 = tor2.status();
|
||||
if (i % 10 == 0)
|
||||
{
|
||||
std::cerr << int(st2.progress * 100) << "% " << std::endl;
|
||||
std::cout << int(st2.progress * 100) << "% " << std::endl;
|
||||
}
|
||||
if (st2.state == torrent_status::finished) break;
|
||||
std::this_thread::sleep_for(lt::milliseconds(100));
|
||||
|
@ -227,11 +227,11 @@ void test_transfer(settings_pack const& sett, bool test_deprecated = false)
|
|||
if (st2.state != torrent_status::finished)
|
||||
return;
|
||||
|
||||
std::cerr << "recheck complete" << std::endl;
|
||||
std::cout << "recheck complete" << std::endl;
|
||||
|
||||
priorities2 = tor2.piece_priorities();
|
||||
std::copy(priorities2.begin(), priorities2.end(), std::ostream_iterator<int>(std::cerr, ", "));
|
||||
std::cerr << std::endl;
|
||||
std::copy(priorities2.begin(), priorities2.end(), std::ostream_iterator<int>(std::cout, ", "));
|
||||
std::cout << std::endl;
|
||||
TEST_CHECK(std::equal(priorities.begin(), priorities.end(), priorities2.begin()));
|
||||
|
||||
tor2.pause();
|
||||
|
@ -253,7 +253,7 @@ void test_transfer(settings_pack const& sett, bool test_deprecated = false)
|
|||
, end(alerts.end()); i != end; ++i)
|
||||
{
|
||||
alert* a = *i;
|
||||
std::cerr << "ses2: " << a->message() << std::endl;
|
||||
std::cout << "ses2: " << a->message() << std::endl;
|
||||
if (alert_cast<save_resume_data_alert>(a))
|
||||
{
|
||||
bencode(std::back_inserter(resume_data)
|
||||
|
@ -280,7 +280,7 @@ done:
|
|||
|
||||
ses2.remove_torrent(tor2);
|
||||
|
||||
std::cerr << "removed" << std::endl;
|
||||
std::cout << "removed" << std::endl;
|
||||
|
||||
std::this_thread::sleep_for(lt::milliseconds(100));
|
||||
|
||||
|
@ -336,8 +336,8 @@ done:
|
|||
std::cout << "setting priorities to 1" << std::endl;
|
||||
TEST_EQUAL(tor2.status().is_finished, false);
|
||||
|
||||
std::copy(priorities.begin(), priorities.end(), std::ostream_iterator<int>(std::cerr, ", "));
|
||||
std::cerr << std::endl;
|
||||
std::copy(priorities.begin(), priorities.end(), std::ostream_iterator<int>(std::cout, ", "));
|
||||
std::cout << std::endl;
|
||||
|
||||
// drain alerts
|
||||
print_alerts(ses1, "ses1", true, true, true, &on_alert);
|
||||
|
|
|
@ -54,7 +54,7 @@ TORRENT_TEST(default_settings)
|
|||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
if (e.dict().size() > 0)
|
||||
std::cerr << e << std::endl;
|
||||
std::cout << e << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ void test_ssl(int test_idx, bool use_utp)
|
|||
|
||||
if (i % 10 == 0)
|
||||
{
|
||||
std::cerr << time_now_string() << " "
|
||||
std::cout << time_now_string() << " "
|
||||
<< "\033[32m" << int(st1.download_payload_rate / 1000.f) << "kB/s "
|
||||
<< "\033[33m" << int(st1.upload_payload_rate / 1000.f) << "kB/s "
|
||||
<< "\033[0m" << int(st1.progress * 100) << "% "
|
||||
|
@ -274,7 +274,7 @@ void test_ssl(int test_idx, bool use_utp)
|
|||
static char const* state_str[] =
|
||||
{"checking (q)", "checking", "dl metadata"
|
||||
, "downloading", "finished", "seeding", "allocating", "checking (r)"};
|
||||
std::cerr << "st2 state: " << state_str[st2.state] << std::endl;
|
||||
std::cout << "st2 state: " << state_str[st2.state] << std::endl;
|
||||
}
|
||||
|
||||
TEST_CHECK(st1.state == torrent_status::seeding
|
||||
|
|
|
@ -58,37 +58,37 @@ const int half = piece_size / 2;
|
|||
void signal_bool(bool* b, char const* string)
|
||||
{
|
||||
*b = true;
|
||||
std::cerr << time_now_string() << " " << string << std::endl;
|
||||
std::cout << time_now_string() << " " << string << std::endl;
|
||||
}
|
||||
|
||||
void on_read_piece(int ret, disk_io_job const& j, char const* data, int size)
|
||||
{
|
||||
std::cerr << time_now_string() << " on_read_piece piece: " << j.piece << std::endl;
|
||||
std::cout << time_now_string() << " on_read_piece piece: " << j.piece << std::endl;
|
||||
TEST_EQUAL(ret, size);
|
||||
if (ret > 0) TEST_CHECK(std::equal(j.buffer.disk_block, j.buffer.disk_block + ret, data));
|
||||
}
|
||||
|
||||
void on_check_resume_data(status_t const status, storage_error const& error, bool* done)
|
||||
{
|
||||
std::cerr << time_now_string() << " on_check_resume_data ret: "
|
||||
std::cout << time_now_string() << " on_check_resume_data ret: "
|
||||
<< static_cast<int>(status);
|
||||
switch (status)
|
||||
{
|
||||
case status_t::no_error:
|
||||
std::cerr << time_now_string() << " success" << std::endl;
|
||||
std::cout << time_now_string() << " success" << std::endl;
|
||||
break;
|
||||
case status_t::fatal_disk_error:
|
||||
std::cerr << time_now_string() << " disk error: " << error.ec.message()
|
||||
std::cout << time_now_string() << " disk error: " << error.ec.message()
|
||||
<< " file: " << error.file() << std::endl;
|
||||
break;
|
||||
case status_t::need_full_check:
|
||||
std::cerr << time_now_string() << " need full check" << std::endl;
|
||||
std::cout << time_now_string() << " need full check" << std::endl;
|
||||
break;
|
||||
case status_t::file_exist:
|
||||
std::cerr << time_now_string() << " file exist" << std::endl;
|
||||
std::cout << time_now_string() << " file exist" << std::endl;
|
||||
break;
|
||||
}
|
||||
std::cerr << std::endl;
|
||||
std::cout << std::endl;
|
||||
*done = true;
|
||||
}
|
||||
|
||||
|
@ -108,10 +108,10 @@ void run_until(io_service& ios, bool const& done)
|
|||
ios.run_one(ec);
|
||||
if (ec)
|
||||
{
|
||||
std::cerr << "run_one: " << ec.message().c_str() << std::endl;
|
||||
std::cout << "run_one: " << ec.message().c_str() << std::endl;
|
||||
return;
|
||||
}
|
||||
std::cerr << time_now_string() << " done: " << done << std::endl;
|
||||
std::cout << time_now_string() << " done: " << done << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,15 +191,15 @@ void run_storage_tests(std::shared_ptr<torrent_info> info
|
|||
TORRENT_ASSERT(fs.num_files() > 0);
|
||||
error_code ec;
|
||||
create_directory(combine_path(test_path, "temp_storage"), ec);
|
||||
if (ec) std::cerr << "create_directory '" << combine_path(test_path, "temp_storage")
|
||||
if (ec) std::cout << "create_directory '" << combine_path(test_path, "temp_storage")
|
||||
<< "': " << ec.message() << std::endl;
|
||||
remove_all(combine_path(test_path, "temp_storage2"), ec);
|
||||
if (ec && ec != boost::system::errc::no_such_file_or_directory)
|
||||
std::cerr << "remove_all '" << combine_path(test_path, "temp_storage2")
|
||||
std::cout << "remove_all '" << combine_path(test_path, "temp_storage2")
|
||||
<< "': " << ec.message() << std::endl;
|
||||
remove_all(combine_path(test_path, "part0"), ec);
|
||||
if (ec && ec != boost::system::errc::no_such_file_or_directory)
|
||||
std::cerr << "remove_all '" << combine_path(test_path, "part0")
|
||||
std::cout << "remove_all '" << combine_path(test_path, "part0")
|
||||
<< "': " << ec.message() << std::endl;
|
||||
|
||||
int num_pieces = fs.num_pieces();
|
||||
|
@ -306,7 +306,7 @@ void test_remove(std::string const& test_path, bool unbuffered)
|
|||
error_code ec;
|
||||
remove_all(combine_path(test_path, "temp_storage"), ec);
|
||||
if (ec && ec != boost::system::errc::no_such_file_or_directory)
|
||||
std::cerr << "remove_all '" << combine_path(test_path, "temp_storage")
|
||||
std::cout << "remove_all '" << combine_path(test_path, "temp_storage")
|
||||
<< "': " << ec.message() << std::endl;
|
||||
TEST_CHECK(!exists(combine_path(test_path, "temp_storage")));
|
||||
|
||||
|
@ -380,7 +380,7 @@ void test_rename(std::string const& test_path)
|
|||
error_code ec;
|
||||
remove_all(combine_path(test_path, "temp_storage"), ec);
|
||||
if (ec && ec != boost::system::errc::no_such_file_or_directory)
|
||||
std::cerr << "remove_all '" << combine_path(test_path, "temp_storage")
|
||||
std::cout << "remove_all '" << combine_path(test_path, "temp_storage")
|
||||
<< "': " << ec.message() << std::endl;
|
||||
TEST_CHECK(!exists(combine_path(test_path, "temp_storage")));
|
||||
|
||||
|
@ -425,7 +425,7 @@ void test_check_files(std::string const& test_path
|
|||
const int piece_size = 16 * 1024;
|
||||
remove_all(combine_path(test_path, "temp_storage"), ec);
|
||||
if (ec && ec != boost::system::errc::no_such_file_or_directory)
|
||||
std::cerr << "remove_all '" << combine_path(test_path, "temp_storage")
|
||||
std::cout << "remove_all '" << combine_path(test_path, "temp_storage")
|
||||
<< "': " << ec.message() << std::endl;
|
||||
file_storage fs;
|
||||
fs.add_file("temp_storage/test1.tmp", piece_size);
|
||||
|
@ -442,7 +442,7 @@ void test_check_files(std::string const& test_path
|
|||
t.set_hash(piece_index_t(3), hasher(piece2).final());
|
||||
|
||||
create_directory(combine_path(test_path, "temp_storage"), ec);
|
||||
if (ec) std::cerr << "create_directory: " << ec.message() << std::endl;
|
||||
if (ec) std::cout << "create_directory: " << ec.message() << std::endl;
|
||||
|
||||
std::ofstream f;
|
||||
f.open(combine_path(test_path, combine_path("temp_storage", "test1.tmp")).c_str()
|
||||
|
@ -495,7 +495,7 @@ void test_check_files(std::string const& test_path
|
|||
void run_test(bool unbuffered)
|
||||
{
|
||||
std::string test_path = current_working_directory();
|
||||
std::cerr << "\n=== " << test_path << " ===\n" << std::endl;
|
||||
std::cout << "\n=== " << test_path << " ===\n" << std::endl;
|
||||
|
||||
std::shared_ptr<torrent_info> info;
|
||||
|
||||
|
@ -508,7 +508,7 @@ void run_test(bool unbuffered)
|
|||
error_code ec;
|
||||
remove_all(combine_path(test_path, "temp_storage"), ec);
|
||||
if (ec && ec != boost::system::errc::no_such_file_or_directory)
|
||||
std::cerr << "remove_all '" << combine_path(test_path, "temp_storage")
|
||||
std::cout << "remove_all '" << combine_path(test_path, "temp_storage")
|
||||
<< "': " << ec.message() << std::endl;
|
||||
file_storage fs;
|
||||
fs.add_file("temp_storage/test1.tmp", 17);
|
||||
|
@ -537,7 +537,7 @@ void run_test(bool unbuffered)
|
|||
std::vector<char> buf;
|
||||
bencode(std::back_inserter(buf), t.generate());
|
||||
info = std::make_shared<torrent_info>(&buf[0], int(buf.size()), std::ref(ec), 0);
|
||||
std::cerr << "=== test 1 === " << (unbuffered?"unbuffered":"buffered") << std::endl;
|
||||
std::cout << "=== test 1 === " << (unbuffered?"unbuffered":"buffered") << std::endl;
|
||||
|
||||
// run_storage_tests writes piece 0, 1 and 2. not 3
|
||||
run_storage_tests(info, fs, test_path, storage_mode_sparse, unbuffered);
|
||||
|
@ -562,7 +562,7 @@ void run_test(bool unbuffered)
|
|||
TEST_EQUAL(file_size(combine_path(base, "test7.tmp")), last_file_size - piece_size);
|
||||
remove_all(combine_path(test_path, "temp_storage"), ec);
|
||||
if (ec && ec != boost::system::errc::no_such_file_or_directory)
|
||||
std::cerr << "remove_all '" << combine_path(test_path, "temp_storage")
|
||||
std::cout << "remove_all '" << combine_path(test_path, "temp_storage")
|
||||
<< "': " << ec.message() << std::endl;
|
||||
}
|
||||
|
||||
|
@ -582,44 +582,44 @@ void run_test(bool unbuffered)
|
|||
bencode(std::back_inserter(buf), t.generate());
|
||||
info = std::make_shared<torrent_info>(&buf[0], int(buf.size()), std::ref(ec), 0);
|
||||
|
||||
std::cerr << "=== test 3 ===" << std::endl;
|
||||
std::cout << "=== test 3 ===" << std::endl;
|
||||
|
||||
run_storage_tests(info, fs, test_path, storage_mode_sparse, unbuffered);
|
||||
|
||||
TEST_EQUAL(file_size(combine_path(test_path, combine_path("temp_storage", "test1.tmp"))), piece_size * 3);
|
||||
remove_all(combine_path(test_path, "temp_storage"), ec);
|
||||
if (ec && ec != boost::system::errc::no_such_file_or_directory)
|
||||
std::cerr << "remove_all '" << combine_path(test_path, "temp_storage")
|
||||
std::cout << "remove_all '" << combine_path(test_path, "temp_storage")
|
||||
<< "': " << ec.message() << std::endl;
|
||||
|
||||
// ==============================================
|
||||
|
||||
std::cerr << "=== test 4 ===" << std::endl;
|
||||
std::cout << "=== test 4 ===" << std::endl;
|
||||
|
||||
run_storage_tests(info, fs, test_path, storage_mode_allocate, unbuffered);
|
||||
|
||||
std::cerr << file_size(combine_path(test_path, combine_path("temp_storage", "test1.tmp"))) << std::endl;
|
||||
std::cout << file_size(combine_path(test_path, combine_path("temp_storage", "test1.tmp"))) << std::endl;
|
||||
TEST_EQUAL(file_size(combine_path(test_path, combine_path("temp_storage", "test1.tmp"))), 3 * piece_size);
|
||||
|
||||
remove_all(combine_path(test_path, "temp_storage"), ec);
|
||||
if (ec && ec != boost::system::errc::no_such_file_or_directory)
|
||||
std::cerr << "remove_all '" << combine_path(test_path, "temp_storage")
|
||||
std::cout << "remove_all '" << combine_path(test_path, "temp_storage")
|
||||
<< "': " << ec.message() << std::endl;
|
||||
|
||||
}
|
||||
|
||||
// ==============================================
|
||||
|
||||
std::cerr << "=== test 5 ===" << std::endl;
|
||||
std::cout << "=== test 5 ===" << std::endl;
|
||||
test_remove(test_path, unbuffered);
|
||||
|
||||
// ==============================================
|
||||
|
||||
std::cerr << "=== test 6 ===" << std::endl;
|
||||
std::cout << "=== test 6 ===" << std::endl;
|
||||
test_check_files(test_path, storage_mode_sparse, unbuffered);
|
||||
test_check_files(test_path, storage_mode_sparse, unbuffered);
|
||||
|
||||
std::cerr << "=== test 7 ===" << std::endl;
|
||||
std::cout << "=== test 7 ===" << std::endl;
|
||||
test_rename(test_path);
|
||||
}
|
||||
|
||||
|
@ -630,10 +630,10 @@ void test_fastresume(bool const test_deprecated)
|
|||
std::cout << "\n\n=== test fastresume ===" << std::endl;
|
||||
remove_all(combine_path(test_path, "tmp1"), ec);
|
||||
if (ec && ec != boost::system::errc::no_such_file_or_directory)
|
||||
std::cerr << "remove_all '" << combine_path(test_path, "tmp1")
|
||||
std::cout << "remove_all '" << combine_path(test_path, "tmp1")
|
||||
<< "': " << ec.message() << std::endl;
|
||||
create_directory(combine_path(test_path, "tmp1"), ec);
|
||||
if (ec) std::cerr << "create_directory '" << combine_path(test_path, "tmp1")
|
||||
if (ec) std::cout << "create_directory '" << combine_path(test_path, "tmp1")
|
||||
<< "': " << ec.message() << std::endl;
|
||||
std::ofstream file(combine_path(test_path, "tmp1/temporary").c_str());
|
||||
std::shared_ptr<torrent_info> t = ::create_torrent(&file);
|
||||
|
@ -690,7 +690,7 @@ void test_fastresume(bool const test_deprecated)
|
|||
if (exists(combine_path(test_path, combine_path("tmp1", "temporary"))))
|
||||
return;
|
||||
|
||||
std::cerr << resume.to_string() << "\n";
|
||||
std::cout << resume.to_string() << "\n";
|
||||
|
||||
// make sure the fast resume check fails! since we removed the file
|
||||
{
|
||||
|
@ -728,7 +728,7 @@ void test_fastresume(bool const test_deprecated)
|
|||
}
|
||||
remove_all(combine_path(test_path, "tmp1"), ec);
|
||||
if (ec && ec != boost::system::errc::no_such_file_or_directory)
|
||||
std::cerr << "remove_all '" << combine_path(test_path, "tmp1")
|
||||
std::cout << "remove_all '" << combine_path(test_path, "tmp1")
|
||||
<< "': " << ec.message() << std::endl;
|
||||
}
|
||||
|
||||
|
@ -804,7 +804,7 @@ TORRENT_TEST(rename_file)
|
|||
if (!ra) return;
|
||||
entry resume = *alert_cast<save_resume_data_alert>(ra)->resume_data;
|
||||
|
||||
std::cerr << resume.to_string() << "\n";
|
||||
std::cout << resume.to_string() << "\n";
|
||||
|
||||
entry::list_type files = resume.dict().find("mapped_files")->second.list();
|
||||
for (entry::list_type::iterator i = files.begin(); i != files.end(); ++i)
|
||||
|
@ -820,10 +820,10 @@ void test_rename_file_fastresume(bool test_deprecated)
|
|||
std::cout << "\n\n=== test rename file in fastresume ===" << std::endl;
|
||||
remove_all(combine_path(test_path, "tmp2"), ec);
|
||||
if (ec && ec != boost::system::errc::no_such_file_or_directory)
|
||||
std::cerr << "remove_all '" << combine_path(test_path, "tmp2")
|
||||
std::cout << "remove_all '" << combine_path(test_path, "tmp2")
|
||||
<< "': " << ec.message() << std::endl;
|
||||
create_directory(combine_path(test_path, "tmp2"), ec);
|
||||
if (ec) std::cerr << "create_directory: " << ec.message() << std::endl;
|
||||
if (ec) std::cout << "create_directory: " << ec.message() << std::endl;
|
||||
std::ofstream file(combine_path(test_path, "tmp2/temporary").c_str());
|
||||
std::shared_ptr<torrent_info> t = ::create_torrent(&file);
|
||||
file.close();
|
||||
|
@ -864,7 +864,7 @@ void test_rename_file_fastresume(bool test_deprecated)
|
|||
TEST_CHECK(exists(combine_path(test_path, "tmp2/testing_renamed_files")));
|
||||
TEST_CHECK(resume.dict().find("mapped_files") != resume.dict().end());
|
||||
|
||||
std::cerr << resume.to_string() << "\n";
|
||||
std::cout << resume.to_string() << "\n";
|
||||
|
||||
// make sure the fast resume check succeeds, even though we renamed the file
|
||||
{
|
||||
|
@ -910,11 +910,11 @@ void test_rename_file_fastresume(bool test_deprecated)
|
|||
}
|
||||
TEST_CHECK(resume.dict().find("mapped_files") != resume.dict().end());
|
||||
|
||||
std::cerr << resume.to_string() << "\n";
|
||||
std::cout << resume.to_string() << "\n";
|
||||
|
||||
remove_all(combine_path(test_path, "tmp2"), ec);
|
||||
if (ec && ec != boost::system::errc::no_such_file_or_directory)
|
||||
std::cerr << "remove_all '" << combine_path(test_path, "tmp2")
|
||||
std::cout << "remove_all '" << combine_path(test_path, "tmp2")
|
||||
<< "': " << ec.message() << std::endl;
|
||||
}
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ TORRENT_TEST(escape_string)
|
|||
// unescape_string
|
||||
TEST_CHECK(unescape_string(escape_string(test_string), ec)
|
||||
== test_string);
|
||||
std::cerr << unescape_string(escape_string(test_string), ec) << std::endl;
|
||||
std::cout << unescape_string(escape_string(test_string), ec) << std::endl;
|
||||
// prematurely terminated string
|
||||
unescape_string("%", ec);
|
||||
TEST_CHECK(ec == error_code(errors::invalid_escaped_string));
|
||||
|
|
|
@ -588,7 +588,7 @@ TORRENT_TEST(parse_torrents)
|
|||
std::vector<char> buf;
|
||||
bencode(std::back_inserter(buf), torrent);
|
||||
torrent_info ti(&buf[0], int(buf.size()), ec);
|
||||
std::cerr << ti.name() << std::endl;
|
||||
std::cout << ti.name() << std::endl;
|
||||
TEST_CHECK(ti.name() == "test1");
|
||||
|
||||
#ifdef TORRENT_WINDOWS
|
||||
|
@ -600,7 +600,7 @@ TORRENT_TEST(parse_torrents)
|
|||
buf.clear();
|
||||
bencode(std::back_inserter(buf), torrent);
|
||||
torrent_info ti2(&buf[0], int(buf.size()), ec);
|
||||
std::cerr << ti2.name() << std::endl;
|
||||
std::cout << ti2.name() << std::endl;
|
||||
#ifdef TORRENT_WINDOWS
|
||||
TEST_EQUAL(ti2.name(), "ctest1test2test3");
|
||||
#else
|
||||
|
@ -612,7 +612,7 @@ TORRENT_TEST(parse_torrents)
|
|||
buf.clear();
|
||||
bencode(std::back_inserter(buf), torrent);
|
||||
torrent_info ti3(&buf[0], int(buf.size()), ec);
|
||||
std::cerr << ti3.name() << std::endl;
|
||||
std::cout << ti3.name() << std::endl;
|
||||
TEST_EQUAL(ti3.name(), "test2..test3.......test4");
|
||||
|
||||
std::string root_dir = parent_path(current_working_directory());
|
||||
|
|
|
@ -96,7 +96,7 @@ struct test_storage : default_storage
|
|||
std::unique_lock<std::mutex> l(m_mutex);
|
||||
if (m_written >= m_limit)
|
||||
{
|
||||
std::cerr << "storage written: " << m_written << " limit: " << m_limit << std::endl;
|
||||
std::cout << "storage written: " << m_written << " limit: " << m_limit << std::endl;
|
||||
error_code ec;
|
||||
ec = error_code(boost::system::errc::no_space_on_device, generic_category());
|
||||
se.ec = ec;
|
||||
|
@ -277,7 +277,7 @@ void test_transfer(int proxy_type, settings_pack const& sett
|
|||
test_move_storage = true;
|
||||
tor1.move_storage("tmp1_transfer_moved");
|
||||
tor2.move_storage("tmp2_transfer_moved");
|
||||
std::cerr << "moving storage" << std::endl;
|
||||
std::cout << "moving storage" << std::endl;
|
||||
}
|
||||
|
||||
// wait 10 loops before we restart the torrent. This lets
|
||||
|
|
|
@ -76,14 +76,14 @@ void incoming_msearch(udp::endpoint const& from, char* buffer
|
|||
p.incoming(span<char const>(buffer, size), error);
|
||||
if (error || !p.header_finished())
|
||||
{
|
||||
std::cerr << "*** malformed HTTP from "
|
||||
std::cout << "*** malformed HTTP from "
|
||||
<< print_endpoint(from) << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (p.method() != "m-search") return;
|
||||
|
||||
std::cerr << "< incoming m-search from " << from << std::endl;
|
||||
std::cout << "< incoming m-search from " << from << std::endl;
|
||||
|
||||
char msg[] = "HTTP/1.1 200 OK\r\n"
|
||||
"ST:upnp:rootdevice\r\n"
|
||||
|
@ -101,7 +101,7 @@ void incoming_msearch(udp::endpoint const& from, char* buffer
|
|||
error_code ec;
|
||||
sock->send(buf, len, ec);
|
||||
|
||||
if (ec) std::cerr << "*** error sending " << ec.message() << std::endl;
|
||||
if (ec) std::cout << "*** error sending " << ec.message() << std::endl;
|
||||
}
|
||||
|
||||
struct callback_info
|
||||
|
@ -125,7 +125,7 @@ namespace
|
|||
{
|
||||
callback_info info = {mapping, port, err};
|
||||
callbacks.push_back(info);
|
||||
std::cerr << "mapping: " << mapping << ", port: " << port << ", IP: " << ip
|
||||
std::cout << "mapping: " << mapping << ", port: " << port << ", IP: " << ip
|
||||
<< ", proto: " << static_cast<int>(protocol)
|
||||
<< ", error: \"" << err.message() << "\"\n";
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ namespace
|
|||
|
||||
virtual void log_portmap(aux::portmap_transport transport, char const* msg) const override
|
||||
{
|
||||
std::cerr << "UPnP: " << msg << std::endl;
|
||||
std::cout << "UPnP: " << msg << std::endl;
|
||||
//TODO: store the log and verify that some key messages are there
|
||||
}
|
||||
#endif
|
||||
|
@ -195,7 +195,7 @@ void run_upnp_test(char const* root_filename, char const* router_model, char con
|
|||
std::this_thread::sleep_for(lt::milliseconds(100));
|
||||
}
|
||||
|
||||
std::cerr << "router: " << upnp_handler->router_model() << std::endl;
|
||||
std::cout << "router: " << upnp_handler->router_model() << std::endl;
|
||||
TEST_EQUAL(upnp_handler->router_model(), router_model);
|
||||
|
||||
int mapping1 = upnp_handler->add_mapping(portmap_protocol::tcp, 500, 500);
|
||||
|
|
|
@ -235,7 +235,7 @@ void test_transfer(lt::session& ses, std::shared_ptr<torrent_info> torrent_file
|
|||
}
|
||||
}
|
||||
|
||||
std::cerr << "total_size: " << total_size
|
||||
std::cout << "total_size: " << total_size
|
||||
<< " read cache size: " << cnt["disk.disk_blocks_in_use"]
|
||||
<< " total used buffer: " << cnt["disk.disk_blocks_in_use"]
|
||||
<< " session total download: " << cnt["net.recv_payload_bytes"]
|
||||
|
|
Loading…
Reference in New Issue