From a087a283de255cfb687e78cdfc08679bfbe78c48 Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 2 Jan 2017 10:16:33 -0500 Subject: [PATCH] make tests print to stdout instead of stderr --- test/dht_server.cpp | 2 +- test/swarm_suite.cpp | 6 +-- test/test_dht.cpp | 12 +++--- test/test_dos_blocker.cpp | 2 +- test/test_fast_extension.cpp | 22 +++++----- test/test_http_parser.cpp | 1 - test/test_lsd.cpp | 2 +- test/test_natpmp.cpp | 14 +++---- test/test_pex.cpp | 2 +- test/test_priority.cpp | 36 ++++++++--------- test/test_settings_pack.cpp | 2 +- test/test_ssl.cpp | 4 +- test/test_storage.cpp | 78 ++++++++++++++++++------------------ test/test_string.cpp | 2 +- test/test_torrent_info.cpp | 6 +-- test/test_transfer.cpp | 4 +- test/test_upnp.cpp | 12 +++--- test/web_seed_suite.cpp | 2 +- 18 files changed, 104 insertions(+), 105 deletions(-) diff --git a/test/dht_server.cpp b/test/dht_server.cpp index a689018ee..ce66c22b7 100644 --- a/test/dht_server.cpp +++ b/test/dht_server.cpp @@ -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; } diff --git a/test/swarm_suite.cpp b/test/swarm_suite.cpp index 0e36d3b61..877e8a293 100644 --- a/test/swarm_suite.cpp +++ b/test/swarm_suite.cpp @@ -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); diff --git a/test/test_dht.cpp b/test/test_dht.cpp index e2cc7fb05..54704d1d2 100644 --- a/test/test_dht.cpp +++ b/test/test_dht.cpp @@ -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* nodes, node_entry const& ne) @@ -2915,7 +2915,7 @@ TORRENT_TEST(routing_table_set_id) std::set 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) diff --git a/test/test_dos_blocker.cpp b/test/test_dos_blocker.cpp index 5b6292755..050b07ee2 100644 --- a/test/test_dos_blocker.cpp +++ b/test/test_dos_blocker.cpp @@ -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); } diff --git a/test/test_fast_extension.cpp b/test/test_fast_extension.cpp index 22ce12228..72f1bc27e 100644 --- a/test/test_fast_extension.cpp +++ b/test/test_fast_extension.cpp @@ -472,7 +472,7 @@ std::shared_ptr 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 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 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 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 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 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 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 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 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); } diff --git a/test/test_http_parser.cpp b/test/test_http_parser.cpp index 0eee91237..4e369baca 100644 --- a/test/test_http_parser.cpp +++ b/test/test_http_parser.cpp @@ -59,7 +59,6 @@ std::tuple 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)); diff --git a/test/test_lsd.cpp b/test/test_lsd.cpp index deb990afe..6556bbd69 100644 --- a/test/test_lsd.cpp +++ b/test/test_lsd.cpp @@ -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(); diff --git a/test/test_natpmp.cpp b/test/test_natpmp.cpp index 9fefbb760..32060ae48 100644 --- a/test/test_natpmp.cpp +++ b/test/test_natpmp.cpp @@ -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(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; } diff --git a/test/test_pex.cpp b/test/test_pex.cpp index 5e8ae8304..6058e40cf 100644 --- a/test/test_pex.cpp +++ b/test/test_pex.cpp @@ -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(); diff --git a/test/test_priority.cpp b/test/test_priority.cpp index b4f6e8fef..ad569cdc8 100644 --- a/test/test_priority.cpp +++ b/test/test_priority.cpp @@ -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(std::cerr, ", ")); - std::cerr << std::endl; + std::cout << "setting priorities: "; + std::copy(priorities.begin(), priorities.end(), std::ostream_iterator(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 priorities2 = tor2.piece_priorities(); - std::copy(priorities2.begin(), priorities2.end(), std::ostream_iterator(std::cerr, ", ")); - std::cerr << std::endl; + std::copy(priorities2.begin(), priorities2.end(), std::ostream_iterator(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(std::cerr, ", ")); - std::cerr << std::endl; + std::copy(priorities2.begin(), priorities2.end(), std::ostream_iterator(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(std::cerr, ", ")); - std::cerr << std::endl; + std::copy(priorities2.begin(), priorities2.end(), std::ostream_iterator(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(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(std::cerr, ", ")); - std::cerr << std::endl; + std::copy(priorities.begin(), priorities.end(), std::ostream_iterator(std::cout, ", ")); + std::cout << std::endl; // drain alerts print_alerts(ses1, "ses1", true, true, true, &on_alert); diff --git a/test/test_settings_pack.cpp b/test/test_settings_pack.cpp index 408e48c4a..33d9a24fd 100644 --- a/test/test_settings_pack.cpp +++ b/test/test_settings_pack.cpp @@ -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 } diff --git a/test/test_ssl.cpp b/test/test_ssl.cpp index 1d1dd9498..c03558fa1 100644 --- a/test/test_ssl.cpp +++ b/test/test_ssl.cpp @@ -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 diff --git a/test/test_storage.cpp b/test/test_storage.cpp index 39148cc3c..e65b08784 100644 --- a/test/test_storage.cpp +++ b/test/test_storage.cpp @@ -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(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 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 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 buf; bencode(std::back_inserter(buf), t.generate()); info = std::make_shared(&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(&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 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(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 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; } diff --git a/test/test_string.cpp b/test/test_string.cpp index 34d2faec1..b388d61f5 100644 --- a/test/test_string.cpp +++ b/test/test_string.cpp @@ -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)); diff --git a/test/test_torrent_info.cpp b/test/test_torrent_info.cpp index a1c735bb3..849913af8 100644 --- a/test/test_torrent_info.cpp +++ b/test/test_torrent_info.cpp @@ -588,7 +588,7 @@ TORRENT_TEST(parse_torrents) std::vector 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()); diff --git a/test/test_transfer.cpp b/test/test_transfer.cpp index cfd1b6f2f..3f6ec3b8f 100644 --- a/test/test_transfer.cpp +++ b/test/test_transfer.cpp @@ -96,7 +96,7 @@ struct test_storage : default_storage std::unique_lock 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 diff --git a/test/test_upnp.cpp b/test/test_upnp.cpp index 4ea386071..a1d76ac55 100644 --- a/test/test_upnp.cpp +++ b/test/test_upnp.cpp @@ -76,14 +76,14 @@ void incoming_msearch(udp::endpoint const& from, char* buffer p.incoming(span(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(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); diff --git a/test/web_seed_suite.cpp b/test/web_seed_suite.cpp index 5b6eef35a..12acc8ca1 100644 --- a/test/web_seed_suite.cpp +++ b/test/web_seed_suite.cpp @@ -235,7 +235,7 @@ void test_transfer(lt::session& ses, std::shared_ptr 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"]