parent
5f7e2eb928
commit
6bb2d7c017
13
.travis.yml
13
.travis.yml
|
@ -3,7 +3,7 @@ language: cpp
|
|||
matrix:
|
||||
include:
|
||||
- env: variant=test_release lang=cpp11 sim=0 coverage=1 docs=1
|
||||
- env: variant=test_debug lang=ubsan sim=1 coverage=0
|
||||
- env: variant=test_debug lang=sanitizer sim=1 coverage=0
|
||||
- env: variant=test_debug lang=cpp98 sim=0 coverage=0
|
||||
- env: variant=test_barebones lang=cpp11 sim=0 coverage=0
|
||||
|
||||
|
@ -67,17 +67,20 @@ before_install:
|
|||
else
|
||||
export coverage_toolset=$toolset;
|
||||
fi
|
||||
- 'if [[ $lang == "ubsan" ]]; then export test_args=testing.arg="--no-stderr-redirect"; fi'
|
||||
- 'if [[ $lang == "sanitizer" ]]; then export test_args=testing.arg="--no-stderr-redirect"; fi'
|
||||
- 'echo "toolset: " ${toolset}'
|
||||
- 'echo "target: " ${target}'
|
||||
- 'echo "coverage_toolset: " ${coverage_toolset}'
|
||||
- 'echo "test_args: " ${test_args}'
|
||||
- 'echo "variant: " ${variant}'
|
||||
# disable leak checking for now. it reports some suspicious reports against some
|
||||
# tests
|
||||
- export ASAN_OPTIONS=detect_leaks=0;
|
||||
|
||||
install:
|
||||
- 'if [[ $toolset == "gcc" ]]; then g++-5 --version; fi'
|
||||
- 'echo "using gcc : cpp11 : ccache g++-5 : <cflags>-std=c11 <cxxflags>-std=c++11 ;" > ~/user-config.jam'
|
||||
- 'echo "using gcc : ubsan : ccache g++-5 : <cflags>-std=c11 <cxxflags>-std=c++11 <compileflags>-fsanitize=undefined <compileflags>-fno-sanitize-recover=undefined <linkflags>-fsanitize=undefined <linkflags>-fno-sanitize-recover=undefined ;" >> ~/user-config.jam'
|
||||
- 'echo "using gcc : sanitizer : ccache g++-5 : <cflags>-std=c11 <cxxflags>-std=c++11 <compileflags>-fsanitize=address,undefined <compileflags>-fno-sanitize-recover=undefined <linkflags>-fuse-ld=gold <linkflags>-fsanitize=address,undefined <linkflags>-fno-sanitize-recover=undefined ;" >> ~/user-config.jam'
|
||||
- 'echo "using gcc : coverage : ccache g++-5 : <cflags>-std=c11 <cxxflags>-std=c++11 <compileflags>--coverage <linkflags>--coverage ;" >> ~/user-config.jam'
|
||||
- 'echo "using gcc : cpp98 : ccache g++-5 : <cflags>-std=c99 <cxxflags>-std=c++98 ;" >> ~/user-config.jam'
|
||||
|
||||
|
@ -116,8 +119,8 @@ script:
|
|||
- bjam --hash -j3 warnings-as-errors=on link=shared debug-iterators=on picker-debugging=on invariant-checks=full variant=$variant $coverage_toolset install location=./lib
|
||||
|
||||
# here we specify the temporary lib dir as a path to look for the main library
|
||||
# a binary built with ubsan does not interact well with python
|
||||
- 'if [[ $lang != "ubsan" ]]; then
|
||||
# a binary built with sanitizer does not interact well with python
|
||||
- 'if [[ $lang != "sanitizer" ]]; then
|
||||
cd bindings/python;
|
||||
bjam --hash -j3 warnings-as-errors=on debug-iterators=on picker-debugging=on invariant-checks=full variant=$variant $coverage_toolset stage_module libtorrent-link=shared install-type=LIB dll-path=../../lib;
|
||||
LD_LIBRARY_PATH=../../lib DYLD_LIBRARY_PATH=../../lib python test.py;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c19b35e05831ad46cefd1a9e9f8b022c799bc8d0
|
||||
Subproject commit 3eae1da7de7d13ab26472c4a44ee4477ce24fa26
|
|
@ -118,7 +118,7 @@ boost::shared_ptr<http_connection> test_request(io_service& ios
|
|||
, int* handler_called
|
||||
, std::string const& auth = std::string())
|
||||
{
|
||||
fprintf(stderr, " ===== TESTING: %s =====\n", url.c_str());
|
||||
fprintf(stdout, " ===== TESTING: %s =====\n", url.c_str());
|
||||
|
||||
auto h = boost::make_shared<http_connection>(ios
|
||||
, res
|
||||
|
@ -401,7 +401,7 @@ void run_test(lt::aux::proxy_settings ps, std::string url, int expect_size, int
|
|||
TEST_EQUAL(counters.size(), expect_counters.size());
|
||||
for (int i = 0; i < int(counters.size()); ++i)
|
||||
{
|
||||
if (counters[i] != expect_counters[i]) fprintf(stderr, "i=%d\n", i);
|
||||
if (counters[i] != expect_counters[i]) fprintf(stdout, "i=%d\n", i);
|
||||
TEST_EQUAL(counters[i], expect_counters[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ TORRENT_TEST(event_completed)
|
|||
// we there can only be one event
|
||||
const bool has_event = str.find("&event=") != std::string::npos;
|
||||
|
||||
fprintf(stderr, "- %s\n", str.c_str());
|
||||
fprintf(stdout, "- %s\n", str.c_str());
|
||||
|
||||
// there is exactly 0 or 1 events.
|
||||
TEST_EQUAL(int(has_start) + int(has_completed) + int(has_stopped)
|
||||
|
@ -662,7 +662,7 @@ TORRENT_TEST(try_next)
|
|||
|
||||
for (int i = 0; i < int(tr.size()); ++i)
|
||||
{
|
||||
fprintf(stderr, "tracker \"%s\"\n", tr[i].url.c_str());
|
||||
fprintf(stdout, "tracker \"%s\"\n", tr[i].url.c_str());
|
||||
if (tr[i].url == "http://tracker.com:8080/announce")
|
||||
{
|
||||
TEST_EQUAL(tr[i].fails, 0);
|
||||
|
|
|
@ -271,13 +271,6 @@ namespace libtorrent
|
|||
|
||||
#endif
|
||||
open_multicast_socket(ios, i->interface_address, loopback, ec);
|
||||
#ifdef TORRENT_DEBUG
|
||||
fprintf(stderr, "broadcast socket [ if: %s group: %s mask: %s ] %s\n"
|
||||
, i->interface_address.to_string().c_str()
|
||||
, m_multicast_endpoint.address().to_string().c_str()
|
||||
, i->netmask.to_string().c_str()
|
||||
, ec.message().c_str());
|
||||
#endif
|
||||
open_unicast_socket(ios, i->interface_address
|
||||
, i->netmask.is_v4() ? i->netmask.to_v4() : address_v4());
|
||||
}
|
||||
|
|
|
@ -198,7 +198,22 @@ namespace
|
|||
memset(&m_counters, 0, sizeof(m_counters));
|
||||
}
|
||||
|
||||
~dht_default_storage() {}
|
||||
~dht_default_storage()
|
||||
{
|
||||
for (dht_mutable_table_t::iterator i = m_mutable_table.begin();
|
||||
i != m_mutable_table.end(); ++i)
|
||||
{
|
||||
std::free(i->second.value);
|
||||
std::free(i->second.salt);
|
||||
}
|
||||
m_counters.mutable_data -= m_mutable_table.size();
|
||||
|
||||
for (dht_immutable_table_t::iterator i = m_immutable_table.begin();
|
||||
i != m_immutable_table.end(); ++i)
|
||||
{
|
||||
std::free(i->second.value);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
size_t num_torrents() const TORRENT_OVERRIDE { return m_map.size(); }
|
||||
|
@ -365,12 +380,12 @@ namespace
|
|||
, immutable_item_comparator(m_id));
|
||||
|
||||
TORRENT_ASSERT(j != m_immutable_table.end());
|
||||
free(j->second.value);
|
||||
std::free(j->second.value);
|
||||
m_immutable_table.erase(j);
|
||||
m_counters.immutable_data -= 1;
|
||||
}
|
||||
dht_immutable_item to_add;
|
||||
to_add.value = static_cast<char*>(malloc(size));
|
||||
to_add.value = static_cast<char*>(std::malloc(size));
|
||||
to_add.size = size;
|
||||
memcpy(to_add.value, buf, size);
|
||||
|
||||
|
@ -437,20 +452,20 @@ namespace
|
|||
< boost::bind(&dht_immutable_item::num_announcers
|
||||
, boost::bind(&dht_mutable_table_t::value_type::second, _2)));
|
||||
TORRENT_ASSERT(j != m_mutable_table.end());
|
||||
free(j->second.value);
|
||||
free(j->second.salt);
|
||||
std::free(j->second.value);
|
||||
std::free(j->second.salt);
|
||||
m_mutable_table.erase(j);
|
||||
m_counters.mutable_data -= 1;
|
||||
}
|
||||
dht_mutable_item to_add;
|
||||
to_add.value = static_cast<char*>(malloc(size));
|
||||
to_add.value = static_cast<char*>(std::malloc(size));
|
||||
to_add.size = size;
|
||||
to_add.seq = seq;
|
||||
to_add.salt = NULL;
|
||||
to_add.salt_size = 0;
|
||||
if (salt_size > 0)
|
||||
{
|
||||
to_add.salt = static_cast<char*>(malloc(salt_size));
|
||||
to_add.salt = static_cast<char*>(std::malloc(salt_size));
|
||||
to_add.salt_size = salt_size;
|
||||
memcpy(to_add.salt, salt, salt_size);
|
||||
}
|
||||
|
@ -473,8 +488,8 @@ namespace
|
|||
{
|
||||
if (item->size != size)
|
||||
{
|
||||
free(item->value);
|
||||
item->value = static_cast<char*>(malloc(size));
|
||||
std::free(item->value);
|
||||
item->value = static_cast<char*>(std::malloc(size));
|
||||
item->size = size;
|
||||
}
|
||||
item->seq = seq;
|
||||
|
@ -521,7 +536,7 @@ namespace
|
|||
++i;
|
||||
continue;
|
||||
}
|
||||
free(i->second.value);
|
||||
std::free(i->second.value);
|
||||
m_immutable_table.erase(i++);
|
||||
m_counters.immutable_data -= 1;
|
||||
}
|
||||
|
@ -534,8 +549,8 @@ namespace
|
|||
++i;
|
||||
continue;
|
||||
}
|
||||
free(i->second.value);
|
||||
free(i->second.salt);
|
||||
std::free(i->second.value);
|
||||
std::free(i->second.salt);
|
||||
m_mutable_table.erase(i++);
|
||||
m_counters.mutable_data -= 1;
|
||||
}
|
||||
|
|
|
@ -97,12 +97,17 @@ udp_socket::udp_socket(io_service& ios)
|
|||
|
||||
m_buf_size = 2048;
|
||||
m_new_buf_size = m_buf_size;
|
||||
m_buf = static_cast<char*>(malloc(m_buf_size));
|
||||
m_buf = static_cast<char*>(std::malloc(m_buf_size));
|
||||
}
|
||||
|
||||
udp_socket::~udp_socket()
|
||||
{
|
||||
free(m_buf);
|
||||
for (std::deque<queued_packet>::iterator i = m_queue.begin()
|
||||
, end(m_queue.end()); i != end; ++i)
|
||||
{
|
||||
if (i->hostname) std::free(i->hostname);
|
||||
}
|
||||
std::free(m_buf);
|
||||
#if TORRENT_USE_IPV6
|
||||
TORRENT_ASSERT_VAL(m_v6_outstanding == 0, m_v6_outstanding);
|
||||
#endif
|
||||
|
@ -741,7 +746,7 @@ void udp_socket::set_buf_size(int s)
|
|||
|
||||
if (no_mem)
|
||||
{
|
||||
free(m_buf);
|
||||
std::free(m_buf);
|
||||
m_buf = 0;
|
||||
m_buf_size = 0;
|
||||
m_new_buf_size = 0;
|
||||
|
@ -1470,7 +1475,7 @@ void udp_socket::drain_queue()
|
|||
{
|
||||
udp_socket::send_hostname(p.hostname, p.ep.port(), &p.buf[0]
|
||||
, p.buf.size(), ec, p.flags | dont_queue);
|
||||
free(p.hostname);
|
||||
std::free(p.hostname);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -69,7 +69,7 @@ using namespace libtorrent;
|
|||
int old_stdout = -1;
|
||||
int old_stderr = -1;
|
||||
bool redirect_stdout = true;
|
||||
bool redirect_stderr = true;
|
||||
bool redirect_stderr = false; // TODO: TEMPORARY!
|
||||
bool keep_files = false;
|
||||
|
||||
extern int _g_test_idx;
|
||||
|
|
|
@ -167,7 +167,7 @@ alert const* wait_for_alert(lt::session& ses, int type, char const* name)
|
|||
for (std::vector<alert*>::iterator i = alerts.begin()
|
||||
, end(alerts.end()); i != end; ++i)
|
||||
{
|
||||
fprintf(stderr, "%s: %s: [%s] %s\n", time_now_string(), name
|
||||
fprintf(stdout, "%s: %s: [%s] %s\n", time_now_string(), name
|
||||
, (*i)->what(), (*i)->message().c_str());
|
||||
if ((*i)->type() == type && !ret)
|
||||
{
|
||||
|
@ -277,14 +277,14 @@ bool print_alerts(lt::session& ses, char const* name
|
|||
if (predicate && predicate(*i)) ret = true;
|
||||
if (peer_disconnected_alert const* p = alert_cast<peer_disconnected_alert>(*i))
|
||||
{
|
||||
fprintf(stderr, "%s: %s: [%s] (%s): %s\n", time_now_string(), name, (*i)->what(), print_endpoint(p->ip).c_str(), p->message().c_str());
|
||||
fprintf(stdout, "%s: %s: [%s] (%s): %s\n", time_now_string(), name, (*i)->what(), print_endpoint(p->ip).c_str(), p->message().c_str());
|
||||
}
|
||||
else if ((*i)->message() != "block downloading"
|
||||
&& (*i)->message() != "block finished"
|
||||
&& (*i)->message() != "piece finished"
|
||||
&& !no_output)
|
||||
{
|
||||
fprintf(stderr, "%s: %s: [%s] %s\n", time_now_string(), name, (*i)->what(), (*i)->message().c_str());
|
||||
fprintf(stdout, "%s: %s: [%s] %s\n", time_now_string(), name, (*i)->what(), (*i)->message().c_str());
|
||||
}
|
||||
|
||||
TEST_CHECK(alert_cast<fastresume_rejected_alert>(*i) == 0 || allow_failed_fastresume);
|
||||
|
@ -292,7 +292,7 @@ bool print_alerts(lt::session& ses, char const* name
|
|||
peer_error_alert const* pea = alert_cast<peer_error_alert>(*i);
|
||||
if (pea)
|
||||
{
|
||||
fprintf(stderr, "%s: peer error: %s\n", time_now_string(), pea->error.message().c_str());
|
||||
fprintf(stdout, "%s: peer error: %s\n", time_now_string(), pea->error.message().c_str());
|
||||
TEST_CHECK((!handles.empty() && h.status().is_seeding)
|
||||
|| pea->error.message() == "connecting to peer"
|
||||
|| pea->error.message() == "closing connection to ourself"
|
||||
|
@ -310,7 +310,7 @@ bool print_alerts(lt::session& ses, char const* name
|
|||
invalid_request_alert const* ira = alert_cast<invalid_request_alert>(*i);
|
||||
if (ira)
|
||||
{
|
||||
fprintf(stderr, "peer error: %s\n", ira->message().c_str());
|
||||
fprintf(stdout, "peer error: %s\n", ira->message().c_str());
|
||||
TEST_CHECK(false);
|
||||
}
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ void wait_for_downloading(lt::session& ses, char const* name)
|
|||
} while (a);
|
||||
if (!downloading_done)
|
||||
{
|
||||
fprintf(stderr, "%s: did not receive a state_changed_alert indicating "
|
||||
fprintf(stdout, "%s: did not receive a state_changed_alert indicating "
|
||||
"the torrent is downloading. waited: %d ms\n"
|
||||
, name, int(total_milliseconds(clock_type::now() - start)));
|
||||
}
|
||||
|
@ -376,7 +376,7 @@ void print_ses_rate(float time
|
|||
{
|
||||
if (st1)
|
||||
{
|
||||
fprintf(stderr, "%3.1fs | %dkB/s %dkB/s %d%% %d cc:%d%s", time
|
||||
fprintf(stdout, "%3.1fs | %dkB/s %dkB/s %d%% %d cc:%d%s", time
|
||||
, int(st1->download_payload_rate / 1000)
|
||||
, int(st1->upload_payload_rate / 1000)
|
||||
, int(st1->progress * 100)
|
||||
|
@ -385,7 +385,7 @@ void print_ses_rate(float time
|
|||
, st1->errc ? (" [" + st1->errc.message() + "]").c_str() : "");
|
||||
}
|
||||
if (st2)
|
||||
fprintf(stderr, " : %3.1fs | %dkB/s %dkB/s %d%% %d cc:%d%s", time
|
||||
fprintf(stdout, " : %3.1fs | %dkB/s %dkB/s %d%% %d cc:%d%s", time
|
||||
, int(st2->download_payload_rate / 1000)
|
||||
, int(st2->upload_payload_rate / 1000)
|
||||
, int(st2->progress * 100)
|
||||
|
@ -393,7 +393,7 @@ void print_ses_rate(float time
|
|||
, st2->connect_candidates
|
||||
, st2->errc ? (" [" + st1->errc.message() + "]").c_str() : "");
|
||||
if (st3)
|
||||
fprintf(stderr, " : %3.1fs | %dkB/s %dkB/s %d%% %d cc:%d%s", time
|
||||
fprintf(stdout, " : %3.1fs | %dkB/s %dkB/s %d%% %d cc:%d%s", time
|
||||
, int(st3->download_payload_rate / 1000)
|
||||
, int(st3->upload_payload_rate / 1000)
|
||||
, int(st3->progress * 100)
|
||||
|
@ -401,7 +401,7 @@ void print_ses_rate(float time
|
|||
, st3->connect_candidates
|
||||
, st3->errc ? (" [" + st1->errc.message() + "]").c_str() : "");
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
||||
void test_sleep(int milliseconds)
|
||||
|
@ -432,7 +432,7 @@ static std::map<int, proxy_t> running_proxies;
|
|||
|
||||
void stop_proxy(int port)
|
||||
{
|
||||
fprintf(stderr, "stopping proxy on port %d\n", port);
|
||||
fprintf(stdout, "stopping proxy on port %d\n", port);
|
||||
// don't shut down proxies until the test is
|
||||
// completely done. This saves a lot of time.
|
||||
// they're closed at the end of main() by
|
||||
|
@ -458,7 +458,7 @@ pid_type async_run(char const* cmdline)
|
|||
if (ret == 0)
|
||||
{
|
||||
int error = GetLastError();
|
||||
fprintf(stderr, "failed (%d) %s\n", error, error_code(error, system_category()).message().c_str());
|
||||
fprintf(stdout, "failed (%d) %s\n", error, error_code(error, system_category()).message().c_str());
|
||||
return 0;
|
||||
}
|
||||
return pi.dwProcessId;
|
||||
|
@ -572,13 +572,13 @@ int start_proxy(int proxy_type)
|
|||
char buf[512];
|
||||
snprintf(buf, sizeof(buf), "%s --port %d%s", cmd, port, auth);
|
||||
|
||||
fprintf(stderr, "%s starting proxy on port %d (%s %s)...\n", time_now_string(), port, type, auth);
|
||||
fprintf(stderr, "%s\n", buf);
|
||||
fprintf(stdout, "%s starting proxy on port %d (%s %s)...\n", time_now_string(), port, type, auth);
|
||||
fprintf(stdout, "%s\n", buf);
|
||||
pid_type r = async_run(buf);
|
||||
if (r == 0) abort();
|
||||
proxy_t t = { r, proxy_type };
|
||||
running_proxies.insert(std::make_pair(port, t));
|
||||
fprintf(stderr, "%s launched\n", time_now_string());
|
||||
fprintf(stdout, "%s launched\n", time_now_string());
|
||||
test_sleep(500);
|
||||
return port;
|
||||
}
|
||||
|
@ -769,7 +769,7 @@ setup_transfer(lt::session* ses1, lt::session* ses2, lt::session* ses3
|
|||
}
|
||||
char ih_hex[41];
|
||||
to_hex((char const*)&t->info_hash()[0], 20, ih_hex);
|
||||
fprintf(stderr, "generated torrent: %s tmp1%s/temporary\n", ih_hex, suffix.c_str());
|
||||
fprintf(stdout, "generated torrent: %s tmp1%s/temporary\n", ih_hex, suffix.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -790,7 +790,7 @@ setup_transfer(lt::session* ses1, lt::session* ses2, lt::session* ses3
|
|||
torrent_handle tor1 = ses1->add_torrent(param, ec);
|
||||
if (ec)
|
||||
{
|
||||
fprintf(stderr, "ses1.add_torrent: %s\n", ec.message().c_str());
|
||||
fprintf(stdout, "ses1.add_torrent: %s\n", ec.message().c_str());
|
||||
return boost::make_tuple(torrent_handle(), torrent_handle(), torrent_handle());
|
||||
}
|
||||
tor1.super_seeding(super_seeding);
|
||||
|
@ -843,16 +843,16 @@ setup_transfer(lt::session* ses1, lt::session* ses2, lt::session* ses3
|
|||
if (use_ssl_ports)
|
||||
{
|
||||
port = ses2->ssl_listen_port();
|
||||
fprintf(stderr, "%s: ses2->ssl_listen_port(): %d\n", time_now_string(), port);
|
||||
fprintf(stdout, "%s: ses2->ssl_listen_port(): %d\n", time_now_string(), port);
|
||||
}
|
||||
|
||||
if (port == 0)
|
||||
{
|
||||
port = ses2->listen_port();
|
||||
fprintf(stderr, "%s: ses2->listen_port(): %d\n", time_now_string(), port);
|
||||
fprintf(stdout, "%s: ses2->listen_port(): %d\n", time_now_string(), port);
|
||||
}
|
||||
|
||||
fprintf(stderr, "%s: ses1: connecting peer port: %d\n"
|
||||
fprintf(stdout, "%s: ses1: connecting peer port: %d\n"
|
||||
, time_now_string(), port);
|
||||
tor1.connect_peer(tcp::endpoint(address::from_string("127.0.0.1", ec)
|
||||
, port));
|
||||
|
@ -875,10 +875,10 @@ setup_transfer(lt::session* ses1, lt::session* ses2, lt::session* ses3
|
|||
if (port == 0) port = ses2->listen_port();
|
||||
if (port2 == 0) port2 = ses1->listen_port();
|
||||
|
||||
fprintf(stderr, "ses3: connecting peer port: %d\n", port);
|
||||
fprintf(stdout, "ses3: connecting peer port: %d\n", port);
|
||||
tor3.connect_peer(tcp::endpoint(
|
||||
address::from_string("127.0.0.1", ec), port));
|
||||
fprintf(stderr, "ses3: connecting peer port: %d\n", port2);
|
||||
fprintf(stdout, "ses3: connecting peer port: %d\n", port2);
|
||||
tor3.connect_peer(tcp::endpoint(
|
||||
address::from_string("127.0.0.1", ec)
|
||||
, port2));
|
||||
|
@ -909,13 +909,13 @@ int start_web_server(bool ssl, bool chunked_encoding, bool keepalive)
|
|||
snprintf(buf, sizeof(buf), "python ../web_server.py %d %d %d %d"
|
||||
, port, chunked_encoding , ssl, keepalive);
|
||||
|
||||
fprintf(stderr, "%s starting web_server on port %d...\n", time_now_string(), port);
|
||||
fprintf(stdout, "%s starting web_server on port %d...\n", time_now_string(), port);
|
||||
|
||||
fprintf(stderr, "%s\n", buf);
|
||||
fprintf(stdout, "%s\n", buf);
|
||||
pid_type r = async_run(buf);
|
||||
if (r == 0) abort();
|
||||
web_server_pid = r;
|
||||
fprintf(stderr, "%s launched\n", time_now_string());
|
||||
fprintf(stdout, "%s launched\n", time_now_string());
|
||||
test_sleep(500);
|
||||
return port;
|
||||
}
|
||||
|
@ -923,7 +923,7 @@ int start_web_server(bool ssl, bool chunked_encoding, bool keepalive)
|
|||
void stop_web_server()
|
||||
{
|
||||
if (web_server_pid == 0) return;
|
||||
fprintf(stderr, "stopping web server\n");
|
||||
fprintf(stdout, "stopping web server\n");
|
||||
stop_process(web_server_pid);
|
||||
web_server_pid = 0;
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ void peer_connection::assign_bandwidth(int channel, int amount)
|
|||
{
|
||||
m_quota += amount;
|
||||
#ifdef VERBOSE_LOGGING
|
||||
std::cerr << " [" << m_name
|
||||
std::cout << " [" << m_name
|
||||
<< "] assign bandwidth, " << amount << std::endl;
|
||||
#endif
|
||||
TEST_CHECK(amount > 0);
|
||||
|
@ -152,8 +152,8 @@ void run_test(connections_t& v
|
|||
, bandwidth_manager& manager
|
||||
, boost::function<void()> f = &nop)
|
||||
{
|
||||
std::cerr << "-------------" << std::endl;
|
||||
|
||||
std::cout << "-------------" << std::endl;
|
||||
|
||||
std::for_each(v.begin(), v.end()
|
||||
, boost::bind(&peer_connection::start, _1));
|
||||
|
||||
|
@ -186,7 +186,7 @@ void spawn_connections(connections_t& v, bandwidth_manager& bwm
|
|||
|
||||
void test_equal_connections(int num, int limit)
|
||||
{
|
||||
std::cerr << "\ntest equal connections " << num << " " << limit << std::endl;
|
||||
std::cout << "\ntest equal connections " << num << " " << limit << std::endl;
|
||||
bandwidth_manager manager(0);
|
||||
global_bwc.throttle(limit);
|
||||
|
||||
|
@ -203,19 +203,19 @@ void test_equal_connections(int num, int limit)
|
|||
{
|
||||
sum += (*i)->m_quota;
|
||||
|
||||
std::cerr << (*i)->m_quota / sample_time
|
||||
std::cout << (*i)->m_quota / sample_time
|
||||
<< " target: " << (limit / num) << " eps: " << err << std::endl;
|
||||
TEST_CHECK(close_to((*i)->m_quota / sample_time, limit / num, err));
|
||||
}
|
||||
sum /= sample_time;
|
||||
std::cerr << "sum: " << sum << " target: " << limit << std::endl;
|
||||
std::cout << "sum: " << sum << " target: " << limit << std::endl;
|
||||
TEST_CHECK(sum > 0);
|
||||
TEST_CHECK(close_to(sum, limit, 50));
|
||||
}
|
||||
|
||||
void test_connections_variable_rate(int num, int limit, int torrent_limit)
|
||||
{
|
||||
std::cerr << "\ntest connections variable rate" << num
|
||||
std::cout << "\ntest connections variable rate" << num
|
||||
<< " l: " << limit
|
||||
<< " t: " << torrent_limit
|
||||
<< std::endl;
|
||||
|
@ -236,7 +236,7 @@ void test_connections_variable_rate(int num, int limit, int torrent_limit)
|
|||
|
||||
if (torrent_limit > 0 && limit * num > torrent_limit)
|
||||
limit = torrent_limit / num;
|
||||
|
||||
|
||||
float sum = 0.f;
|
||||
float err = limit * 0.3f;
|
||||
for (connections_t::iterator i = v.begin()
|
||||
|
@ -244,19 +244,19 @@ void test_connections_variable_rate(int num, int limit, int torrent_limit)
|
|||
{
|
||||
sum += (*i)->m_quota;
|
||||
|
||||
std::cerr << (*i)->m_quota / sample_time
|
||||
std::cout << (*i)->m_quota / sample_time
|
||||
<< " target: " << limit << " eps: " << err << std::endl;
|
||||
TEST_CHECK(close_to((*i)->m_quota / sample_time, limit, err));
|
||||
}
|
||||
sum /= sample_time;
|
||||
std::cerr << "sum: " << sum << " target: " << (limit * num) << std::endl;
|
||||
std::cout << "sum: " << sum << " target: " << (limit * num) << std::endl;
|
||||
TEST_CHECK(sum > 0);
|
||||
TEST_CHECK(close_to(sum, limit * num, limit * 0.3f * num));
|
||||
}
|
||||
|
||||
void test_single_peer(int limit, bool torrent_limit)
|
||||
{
|
||||
std::cerr << "\ntest single peer " << limit << " " << torrent_limit << std::endl;
|
||||
std::cout << "\ntest single peer " << limit << " " << torrent_limit << std::endl;
|
||||
bandwidth_manager manager(0);
|
||||
bandwidth_channel t1;
|
||||
global_bwc.throttle(0);
|
||||
|
@ -277,14 +277,14 @@ void test_single_peer(int limit, bool torrent_limit)
|
|||
sum += (*i)->m_quota;
|
||||
}
|
||||
sum /= sample_time;
|
||||
std::cerr << sum << " target: " << limit << std::endl;
|
||||
std::cout << sum << " target: " << limit << std::endl;
|
||||
TEST_CHECK(sum > 0);
|
||||
TEST_CHECK(close_to(sum, limit, 1000));
|
||||
}
|
||||
|
||||
void test_torrents(int num, int limit1, int limit2, int global_limit)
|
||||
{
|
||||
std::cerr << "\ntest equal torrents " << num
|
||||
std::cout << "\ntest equal torrents " << num
|
||||
<< " l1: " << limit1
|
||||
<< " l2: " << limit2
|
||||
<< " g: " << global_limit << std::endl;
|
||||
|
@ -318,7 +318,7 @@ void test_torrents(int num, int limit1, int limit2, int global_limit)
|
|||
sum += (*i)->m_quota;
|
||||
}
|
||||
sum /= sample_time;
|
||||
std::cerr << sum << " target: " << limit1 << std::endl;
|
||||
std::cout << sum << " target: " << limit1 << std::endl;
|
||||
TEST_CHECK(sum > 0);
|
||||
TEST_CHECK(close_to(sum, limit1, 1000));
|
||||
|
||||
|
@ -329,14 +329,14 @@ void test_torrents(int num, int limit1, int limit2, int global_limit)
|
|||
sum += (*i)->m_quota;
|
||||
}
|
||||
sum /= sample_time;
|
||||
std::cerr << sum << " target: " << limit2 << std::endl;
|
||||
std::cout << sum << " target: " << limit2 << std::endl;
|
||||
TEST_CHECK(sum > 0);
|
||||
TEST_CHECK(close_to(sum, limit2, 1000));
|
||||
}
|
||||
|
||||
void test_torrents_variable_rate(int num, int limit, int global_limit)
|
||||
{
|
||||
std::cerr << "\ntest torrents variable rate" << num
|
||||
std::cout << "\ntest torrents variable rate" << num
|
||||
<< " l: " << limit
|
||||
<< " g: " << global_limit << std::endl;
|
||||
bandwidth_manager manager(0);
|
||||
|
@ -368,7 +368,7 @@ void test_torrents_variable_rate(int num, int limit, int global_limit)
|
|||
sum += (*i)->m_quota;
|
||||
}
|
||||
sum /= sample_time;
|
||||
std::cerr << sum << " target: " << limit << std::endl;
|
||||
std::cout << sum << " target: " << limit << std::endl;
|
||||
TEST_CHECK(sum > 0);
|
||||
TEST_CHECK(close_to(sum, limit, 1000));
|
||||
|
||||
|
@ -379,14 +379,14 @@ void test_torrents_variable_rate(int num, int limit, int global_limit)
|
|||
sum += (*i)->m_quota;
|
||||
}
|
||||
sum /= sample_time;
|
||||
std::cerr << sum << " target: " << limit << std::endl;
|
||||
std::cout << sum << " target: " << limit << std::endl;
|
||||
TEST_CHECK(sum > 0);
|
||||
TEST_CHECK(close_to(sum, limit, 1000));
|
||||
}
|
||||
|
||||
void test_peer_priority(int limit, bool torrent_limit)
|
||||
{
|
||||
std::cerr << "\ntest peer priority " << limit << " " << torrent_limit << std::endl;
|
||||
std::cout << "\ntest peer priority " << limit << " " << torrent_limit << std::endl;
|
||||
bandwidth_manager manager(0);
|
||||
bandwidth_channel t1;
|
||||
global_bwc.throttle(0);
|
||||
|
@ -412,18 +412,18 @@ void test_peer_priority(int limit, bool torrent_limit)
|
|||
sum += (*i)->m_quota;
|
||||
}
|
||||
sum /= sample_time;
|
||||
std::cerr << sum << " target: " << limit << std::endl;
|
||||
std::cout << sum << " target: " << limit << std::endl;
|
||||
TEST_CHECK(sum > 0);
|
||||
TEST_CHECK(close_to(sum, limit, 50));
|
||||
|
||||
std::cerr << "non-prioritized rate: " << p->m_quota / sample_time
|
||||
std::cout << "non-prioritized rate: " << p->m_quota / sample_time
|
||||
<< " target: " << (limit / 200 / 10) << std::endl;
|
||||
TEST_CHECK(close_to(p->m_quota / sample_time, limit / 200 / 10, 5));
|
||||
}
|
||||
|
||||
void test_no_starvation(int limit)
|
||||
{
|
||||
std::cerr << "\ntest no starvation " << limit << std::endl;
|
||||
std::cout << "\ntest no starvation " << limit << std::endl;
|
||||
bandwidth_manager manager(0);
|
||||
bandwidth_channel t1;
|
||||
bandwidth_channel t2;
|
||||
|
@ -448,11 +448,11 @@ void test_no_starvation(int limit)
|
|||
sum += (*i)->m_quota;
|
||||
}
|
||||
sum /= sample_time;
|
||||
std::cerr << sum << " target: " << limit << std::endl;
|
||||
std::cout << sum << " target: " << limit << std::endl;
|
||||
TEST_CHECK(sum > 0);
|
||||
TEST_CHECK(close_to(sum, limit, 50));
|
||||
|
||||
std::cerr << "non-prioritized rate: " << p->m_quota / sample_time
|
||||
std::cout << "non-prioritized rate: " << p->m_quota / sample_time
|
||||
<< " target: " << (limit / 200 / num_peers) << std::endl;
|
||||
TEST_CHECK(close_to(p->m_quota / sample_time, limit / 200 / num_peers, 5));
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ void test_checking(int flags = read_only_files)
|
|||
using namespace libtorrent;
|
||||
namespace lt = libtorrent;
|
||||
|
||||
fprintf(stderr, "\n==== TEST CHECKING %s%s%s=====\n\n"
|
||||
fprintf(stdout, "\n==== TEST CHECKING %s%s%s=====\n\n"
|
||||
, (flags & read_only_files) ? "read-only-files ":""
|
||||
, (flags & corrupt_files) ? "corrupt ":""
|
||||
, (flags & incomplete_files) ? "incomplete ":"");
|
||||
|
@ -85,14 +85,14 @@ void test_checking(int flags = read_only_files)
|
|||
// in case the previous run was terminated
|
||||
error_code ec;
|
||||
remove_all("tmp1_checking", ec);
|
||||
if (ec) fprintf(stderr, "ERROR: removing tmp1_checking: (%d) %s\n"
|
||||
if (ec) fprintf(stdout, "ERROR: removing tmp1_checking: (%d) %s\n"
|
||||
, ec.value(), ec.message().c_str());
|
||||
|
||||
create_directory("tmp1_checking", ec);
|
||||
if (ec) fprintf(stderr, "ERROR: creating directory tmp1_checking: (%d) %s\n"
|
||||
if (ec) fprintf(stdout, "ERROR: creating directory tmp1_checking: (%d) %s\n"
|
||||
, ec.value(), ec.message().c_str());
|
||||
create_directory(combine_path("tmp1_checking", "test_torrent_dir"), ec);
|
||||
if (ec) fprintf(stderr, "ERROR: creating directory test_torrent_dir: (%d) %s\n"
|
||||
if (ec) fprintf(stdout, "ERROR: creating directory test_torrent_dir: (%d) %s\n"
|
||||
, ec.value(), ec.message().c_str());
|
||||
|
||||
file_storage fs;
|
||||
|
@ -108,14 +108,14 @@ void test_checking(int flags = read_only_files)
|
|||
|
||||
// calculate the hash for all pieces
|
||||
set_piece_hashes(t, "tmp1_checking", ec);
|
||||
if (ec) fprintf(stderr, "ERROR: set_piece_hashes: (%d) %s\n"
|
||||
if (ec) fprintf(stdout, "ERROR: set_piece_hashes: (%d) %s\n"
|
||||
, ec.value(), ec.message().c_str());
|
||||
|
||||
std::vector<char> buf;
|
||||
bencode(std::back_inserter(buf), t.generate());
|
||||
boost::shared_ptr<torrent_info> ti(new torrent_info(&buf[0], buf.size(), ec));
|
||||
|
||||
fprintf(stderr, "generated torrent: %s tmp1_checking/test_torrent_dir\n"
|
||||
fprintf(stdout, "generated torrent: %s tmp1_checking/test_torrent_dir\n"
|
||||
, to_hex(ti->info_hash().to_string()).c_str());
|
||||
|
||||
// truncate every file in half
|
||||
|
@ -132,10 +132,10 @@ void test_checking(int flags = read_only_files)
|
|||
|
||||
error_code ec;
|
||||
file f(path, file::read_write, ec);
|
||||
if (ec) fprintf(stderr, "ERROR: opening file \"%s\": (%d) %s\n"
|
||||
if (ec) fprintf(stdout, "ERROR: opening file \"%s\": (%d) %s\n"
|
||||
, path.c_str(), ec.value(), ec.message().c_str());
|
||||
f.set_size(file_sizes[i] / 2, ec);
|
||||
if (ec) fprintf(stderr, "ERROR: truncating file \"%s\": (%d) %s\n"
|
||||
if (ec) fprintf(stdout, "ERROR: truncating file \"%s\": (%d) %s\n"
|
||||
, path.c_str(), ec.value(), ec.message().c_str());
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ void test_checking(int flags = read_only_files)
|
|||
// overwrite the files with new random data
|
||||
if (flags & corrupt_files)
|
||||
{
|
||||
fprintf(stderr, "corrupt file test. overwriting files\n");
|
||||
fprintf(stdout, "corrupt file test. overwriting files\n");
|
||||
// increase the size of some files. When they're read only that forces
|
||||
// the checker to open them in write-mode to truncate them
|
||||
static const int file_sizes2[] =
|
||||
|
@ -155,7 +155,7 @@ void test_checking(int flags = read_only_files)
|
|||
// make the files read only
|
||||
if (flags & read_only_files)
|
||||
{
|
||||
fprintf(stderr, "making files read-only\n");
|
||||
fprintf(stdout, "making files read-only\n");
|
||||
for (int i = 0; i < num_files; ++i)
|
||||
{
|
||||
char name[1024];
|
||||
|
@ -165,7 +165,7 @@ void test_checking(int flags = read_only_files)
|
|||
|
||||
std::string path = combine_path(combine_path("tmp1_checking", "test_torrent_dir"), dirname);
|
||||
path = combine_path(path, name);
|
||||
fprintf(stderr, " %s\n", path.c_str());
|
||||
fprintf(stdout, " %s\n", path.c_str());
|
||||
|
||||
#ifdef TORRENT_WINDOWS
|
||||
SetFileAttributesA(path.c_str(), FILE_ATTRIBUTE_READONLY);
|
||||
|
@ -236,7 +236,7 @@ void test_checking(int flags = read_only_files)
|
|||
// read-only here, we expect the checking to fail.
|
||||
TEST_CHECK(st.errc);
|
||||
if (st.errc)
|
||||
fprintf(stderr, "error: %s\n", st.errc.message().c_str());
|
||||
fprintf(stdout, "error: %s\n", st.errc.message().c_str());
|
||||
|
||||
// wait a while to make sure libtorrent survived the error
|
||||
test_sleep(1000);
|
||||
|
@ -245,13 +245,13 @@ void test_checking(int flags = read_only_files)
|
|||
TEST_CHECK(!st.is_seeding);
|
||||
TEST_CHECK(st.errc);
|
||||
if (st.errc)
|
||||
fprintf(stderr, "error: %s\n", st.errc.message().c_str());
|
||||
fprintf(stdout, "error: %s\n", st.errc.message().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
TEST_CHECK(!st.errc);
|
||||
if (st.errc)
|
||||
fprintf(stderr, "error: %s\n", st.errc.message().c_str());
|
||||
fprintf(stdout, "error: %s\n", st.errc.message().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ void test_checking(int flags = read_only_files)
|
|||
{
|
||||
TEST_CHECK(st.is_seeding);
|
||||
if (st.errc)
|
||||
fprintf(stderr, "error: %s\n", st.errc.message().c_str());
|
||||
fprintf(stdout, "error: %s\n", st.errc.message().c_str());
|
||||
}
|
||||
|
||||
// make the files writable again
|
||||
|
@ -283,7 +283,7 @@ void test_checking(int flags = read_only_files)
|
|||
}
|
||||
|
||||
remove_all("tmp1_checking", ec);
|
||||
if (ec) fprintf(stderr, "ERROR: removing tmp1_checking: (%d) %s\n"
|
||||
if (ec) fprintf(stdout, "ERROR: removing tmp1_checking: (%d) %s\n"
|
||||
, ec.value(), ec.message().c_str());
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ void send_dht_request(node& node, char const* msg, udp::endpoint const& ep
|
|||
int size = bencode(msg_buf, e);
|
||||
#if defined TORRENT_DEBUG && TORRENT_USE_IOSTREAM
|
||||
// this yields a lot of output. too much
|
||||
// std::cerr << "sending: " << e << "\n";
|
||||
// std::cout << "sending: " << e << "\n";
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_USE_VALGRIND
|
||||
|
@ -236,7 +236,7 @@ void send_dht_request(node& node, char const* msg, udp::endpoint const& ep
|
|||
bdecode_node decoded;
|
||||
error_code ec;
|
||||
bdecode(msg_buf, msg_buf + size, decoded, ec);
|
||||
if (ec) fprintf(stderr, "bdecode failed: %s\n", ec.message().c_str());
|
||||
if (ec) fprintf(stdout, "bdecode failed: %s\n", ec.message().c_str());
|
||||
|
||||
dht::msg m(decoded, ep);
|
||||
node.incoming(m);
|
||||
|
@ -285,7 +285,7 @@ void send_dht_response(node& node, bdecode_node const& request, udp::endpoint co
|
|||
bdecode_node decoded;
|
||||
error_code ec;
|
||||
bdecode(msg_buf, msg_buf + size, decoded, ec);
|
||||
if (ec) fprintf(stderr, "bdecode failed: %s\n", ec.message().c_str());
|
||||
if (ec) fprintf(stdout, "bdecode failed: %s\n", ec.message().c_str());
|
||||
|
||||
dht::msg m(decoded, ep);
|
||||
node.incoming(m);
|
||||
|
@ -337,19 +337,19 @@ void announce_immutable_items(node& node, udp::endpoint const* eps
|
|||
bdecode_node parsed[5];
|
||||
char error_string[200];
|
||||
|
||||
// fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
|
||||
// fprintf(stdout, "msg: %s\n", print_entry(response).c_str());
|
||||
int ret = verify_message(response, desc, parsed, error_string
|
||||
, sizeof(error_string));
|
||||
if (ret)
|
||||
{
|
||||
TEST_EQUAL(parsed[4].string_value(), "r");
|
||||
token = parsed[2].string_value();
|
||||
// fprintf(stderr, "got token: %s\n", token.c_str());
|
||||
// fprintf(stdout, "got token: %s\n", token.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stderr, " invalid get response: %s\n", error_string);
|
||||
fprintf(stdout, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid get response: %s\n", error_string);
|
||||
TEST_ERROR(error_string);
|
||||
}
|
||||
|
||||
|
@ -378,14 +378,14 @@ void announce_immutable_items(node& node, udp::endpoint const* eps
|
|||
if (ret)
|
||||
{
|
||||
if (parsed2[0].string_value() != "r")
|
||||
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, "msg: %s\n", print_entry(response).c_str());
|
||||
|
||||
TEST_EQUAL(parsed2[0].string_value(), "r");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stderr, " invalid put response: %s\n", error_string);
|
||||
fprintf(stdout, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid put response: %s\n", error_string);
|
||||
TEST_ERROR(error_string);
|
||||
}
|
||||
}
|
||||
|
@ -538,7 +538,7 @@ TORRENT_TEST(dht)
|
|||
|
||||
bdecode_node pong_keys[4];
|
||||
|
||||
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, "msg: %s\n", print_entry(response).c_str());
|
||||
ret = dht::verify_message(response, pong_desc, pong_keys, error_string
|
||||
, sizeof(error_string));
|
||||
TEST_CHECK(ret);
|
||||
|
@ -549,7 +549,7 @@ TORRENT_TEST(dht)
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " invalid ping response: %s\n", error_string);
|
||||
fprintf(stdout, " invalid ping response: %s\n", error_string);
|
||||
}
|
||||
|
||||
// ====== invalid message ======
|
||||
|
@ -563,7 +563,7 @@ TORRENT_TEST(dht)
|
|||
|
||||
bdecode_node err_keys[2];
|
||||
|
||||
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, "msg: %s\n", print_entry(response).c_str());
|
||||
ret = dht::verify_message(response, err_desc, err_keys, error_string
|
||||
, sizeof(error_string));
|
||||
TEST_CHECK(ret);
|
||||
|
@ -582,7 +582,7 @@ TORRENT_TEST(dht)
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " invalid error response: %s\n", error_string);
|
||||
fprintf(stdout, " invalid error response: %s\n", error_string);
|
||||
}
|
||||
|
||||
// ====== get_peers ======
|
||||
|
@ -600,7 +600,7 @@ TORRENT_TEST(dht)
|
|||
bdecode_node peer1_keys[4];
|
||||
|
||||
std::string token;
|
||||
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, "msg: %s\n", print_entry(response).c_str());
|
||||
ret = dht::verify_message(response, peer1_desc, peer1_keys, error_string
|
||||
, sizeof(error_string));
|
||||
TEST_CHECK(ret);
|
||||
|
@ -608,12 +608,12 @@ TORRENT_TEST(dht)
|
|||
{
|
||||
TEST_CHECK(peer1_keys[0].string_value() == "r");
|
||||
token = peer1_keys[2].string_value();
|
||||
// fprintf(stderr, "got token: %s\n", token.c_str());
|
||||
// fprintf(stdout, "got token: %s\n", token.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stderr, " invalid get_peers response: %s\n", error_string);
|
||||
fprintf(stdout, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid get_peers response: %s\n", error_string);
|
||||
}
|
||||
|
||||
// ====== announce ======
|
||||
|
@ -634,7 +634,7 @@ TORRENT_TEST(dht)
|
|||
|
||||
bdecode_node ann_keys[3];
|
||||
|
||||
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, "msg: %s\n", print_entry(response).c_str());
|
||||
ret = dht::verify_message(response, ann_desc, ann_keys, error_string
|
||||
, sizeof(error_string));
|
||||
TEST_CHECK(ret);
|
||||
|
@ -644,7 +644,7 @@ TORRENT_TEST(dht)
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " invalid announce response: %s\n", error_string);
|
||||
fprintf(stdout, " invalid announce response: %s\n", error_string);
|
||||
}
|
||||
|
||||
init_rand_address();
|
||||
|
@ -664,12 +664,12 @@ TORRENT_TEST(dht)
|
|||
{
|
||||
TEST_CHECK(peer1_keys[0].string_value() == "r");
|
||||
token = peer1_keys[2].string_value();
|
||||
// fprintf(stderr, "got token: %s\n", token.c_str());
|
||||
// fprintf(stdout, "got token: %s\n", token.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stderr, " invalid get_peers response: %s\n", error_string);
|
||||
fprintf(stdout, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid get_peers response: %s\n", error_string);
|
||||
}
|
||||
response.clear();
|
||||
send_dht_request(node, "announce_peer", source, &response
|
||||
|
@ -698,7 +698,7 @@ TORRENT_TEST(dht)
|
|||
|
||||
bdecode_node peer2_keys[5];
|
||||
|
||||
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, "msg: %s\n", print_entry(response).c_str());
|
||||
ret = dht::verify_message(response, peer2_desc, peer2_keys, error_string
|
||||
, sizeof(error_string));
|
||||
TEST_CHECK(ret);
|
||||
|
@ -712,15 +712,15 @@ TORRENT_TEST(dht)
|
|||
downloaders.from_string(peer2_keys[2].string_ptr());
|
||||
seeds.from_string(peer2_keys[3].string_ptr());
|
||||
|
||||
fprintf(stderr, "seeds: %f\n", seeds.size());
|
||||
fprintf(stderr, "downloaders: %f\n", downloaders.size());
|
||||
fprintf(stdout, "seeds: %f\n", seeds.size());
|
||||
fprintf(stdout, "downloaders: %f\n", downloaders.size());
|
||||
|
||||
TEST_CHECK(fabs(seeds.size() - 50.f) <= 3.f);
|
||||
TEST_CHECK(fabs(downloaders.size() - 50.f) <= 3.f);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " invalid get_peers response: %s\n", error_string);
|
||||
fprintf(stdout, " invalid get_peers response: %s\n", error_string);
|
||||
}
|
||||
|
||||
// ====== test node ID testing =====
|
||||
|
@ -767,14 +767,14 @@ TORRENT_TEST(dht)
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, "msg: %s\n", print_entry(response).c_str());
|
||||
TEST_ERROR("invalid error response");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stderr, " invalid error response: %s\n", error_string);
|
||||
fprintf(stdout, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid error response: %s\n", error_string);
|
||||
}
|
||||
|
||||
// a node with invalid node-id shouldn't be added to routing table.
|
||||
|
@ -793,7 +793,7 @@ TORRENT_TEST(dht)
|
|||
|
||||
bdecode_node nodes_keys[3];
|
||||
|
||||
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, "msg: %s\n", print_entry(response).c_str());
|
||||
ret = dht::verify_message(response, nodes_desc, nodes_keys, error_string
|
||||
, sizeof(error_string));
|
||||
TEST_CHECK(ret);
|
||||
|
@ -803,8 +803,8 @@ TORRENT_TEST(dht)
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stderr, " invalid error response: %s\n", error_string);
|
||||
fprintf(stdout, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid error response: %s\n", error_string);
|
||||
}
|
||||
// node with valid node-id should be added to routing table.
|
||||
TEST_EQUAL(node.size().get<0>(), nodes_num + 1);
|
||||
|
@ -839,8 +839,8 @@ TORRENT_TEST(dht)
|
|||
|
||||
// these are test vectors from BEP 33
|
||||
// http://www.bittorrent.org/beps/bep_0033.html
|
||||
fprintf(stderr, "test.size: %f\n", test.size());
|
||||
fprintf(stderr, "%s\n", to_hex(test.to_string()).c_str());
|
||||
fprintf(stdout, "test.size: %f\n", test.size());
|
||||
fprintf(stdout, "%s\n", to_hex(test.to_string()).c_str());
|
||||
if (supports_ipv6())
|
||||
{
|
||||
TEST_CHECK(fabs(test.size() - 1224.93f) < 0.001);
|
||||
|
@ -910,13 +910,13 @@ TORRENT_TEST(dht)
|
|||
for (int with_salt = 0; with_salt < 2; ++with_salt)
|
||||
{
|
||||
seq = 4;
|
||||
fprintf(stderr, "\nTEST GET/PUT%s \ngenerating ed25519 keys\n\n"
|
||||
fprintf(stdout, "\nTEST GET/PUT%s \ngenerating ed25519 keys\n\n"
|
||||
, with_salt ? " with-salt" : " no-salt");
|
||||
unsigned char seed[32];
|
||||
ed25519_create_seed(seed);
|
||||
|
||||
ed25519_create_keypair((unsigned char*)public_key, (unsigned char*)private_key, seed);
|
||||
fprintf(stderr, "pub: %s priv: %s\n"
|
||||
fprintf(stdout, "pub: %s priv: %s\n"
|
||||
, to_hex(std::string(public_key, item_pk_len)).c_str()
|
||||
, to_hex(std::string(private_key, item_sk_len)).c_str());
|
||||
|
||||
|
@ -930,7 +930,7 @@ TORRENT_TEST(dht)
|
|||
if (with_salt) h.update(salt.first, salt.second);
|
||||
sha1_hash target_id = h.final();
|
||||
|
||||
fprintf(stderr, "target_id: %s\n"
|
||||
fprintf(stdout, "target_id: %s\n"
|
||||
, to_hex(target_id.to_string()).c_str());
|
||||
|
||||
send_dht_request(node, "get", source, &response
|
||||
|
@ -953,14 +953,14 @@ TORRENT_TEST(dht)
|
|||
{
|
||||
TEST_EQUAL(desc_keys[4].string_value(), "r");
|
||||
token = desc_keys[2].string_value();
|
||||
fprintf(stderr, "get response: %s\n"
|
||||
fprintf(stdout, "get response: %s\n"
|
||||
, print_entry(response).c_str());
|
||||
fprintf(stderr, "got token: %s\n", to_hex(token).c_str());
|
||||
fprintf(stdout, "got token: %s\n", to_hex(token).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stderr, " invalid get response: %s\n%s\n"
|
||||
fprintf(stdout, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid get response: %s\n%s\n"
|
||||
, error_string, print_entry(response).c_str());
|
||||
TEST_ERROR(error_string);
|
||||
}
|
||||
|
@ -985,13 +985,13 @@ TORRENT_TEST(dht)
|
|||
, sizeof(error_string));
|
||||
if (ret)
|
||||
{
|
||||
fprintf(stderr, "put response: %s\n"
|
||||
fprintf(stdout, "put response: %s\n"
|
||||
, print_entry(response).c_str());
|
||||
TEST_EQUAL(desc2_keys[0].string_value(), "r");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " invalid put response: %s\n%s\n"
|
||||
fprintf(stdout, " invalid put response: %s\n%s\n"
|
||||
, error_string, print_entry(response).c_str());
|
||||
TEST_ERROR(error_string);
|
||||
}
|
||||
|
@ -999,7 +999,7 @@ TORRENT_TEST(dht)
|
|||
send_dht_request(node, "get", source, &response
|
||||
, msg_args().target((char*)&target_id[0]));
|
||||
|
||||
fprintf(stderr, "target_id: %s\n"
|
||||
fprintf(stdout, "target_id: %s\n"
|
||||
, to_hex(target_id.to_string()).c_str());
|
||||
|
||||
key_desc_t desc3[] =
|
||||
|
@ -1019,14 +1019,14 @@ TORRENT_TEST(dht)
|
|||
, sizeof(error_string));
|
||||
if (ret == 0)
|
||||
{
|
||||
fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stderr, " invalid get response: %s\n%s\n"
|
||||
fprintf(stdout, "msg: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid get response: %s\n%s\n"
|
||||
, error_string, print_entry(response).c_str());
|
||||
TEST_ERROR(error_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "get response: %s\n"
|
||||
fprintf(stdout, "get response: %s\n"
|
||||
, print_entry(response).c_str());
|
||||
char value[1020];
|
||||
char* ptr = value;
|
||||
|
@ -1048,7 +1048,7 @@ TORRENT_TEST(dht)
|
|||
// break the signature
|
||||
signature[2] ^= 0xaa;
|
||||
|
||||
fprintf(stderr, "PUT broken signature\n");
|
||||
fprintf(stdout, "PUT broken signature\n");
|
||||
|
||||
TEST_CHECK(verify_mutable_item(itemv, salt, seq, public_key, signature) != 1);
|
||||
|
||||
|
@ -1065,14 +1065,14 @@ TORRENT_TEST(dht)
|
|||
, sizeof(error_string));
|
||||
if (ret)
|
||||
{
|
||||
fprintf(stderr, "put response: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, "put response: %s\n", print_entry(response).c_str());
|
||||
TEST_EQUAL(desc_error_keys[1].string_value(), "e");
|
||||
// 206 is the code for invalid signature
|
||||
TEST_EQUAL(desc_error_keys[0].list_int_value_at(0), 206);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " invalid put response: %s\n%s\n"
|
||||
fprintf(stdout, " invalid put response: %s\n%s\n"
|
||||
, error_string, print_entry(response).c_str());
|
||||
TEST_ERROR(error_string);
|
||||
}
|
||||
|
@ -1116,7 +1116,7 @@ TORRENT_TEST(dht)
|
|||
|
||||
TEST_CHECK(item_target_id(salt, public_key) == target_id);
|
||||
|
||||
fprintf(stderr, "PUT CAS 1\n");
|
||||
fprintf(stdout, "PUT CAS 1\n");
|
||||
|
||||
send_dht_request(node, "put", source, &response
|
||||
, msg_args()
|
||||
|
@ -1132,18 +1132,18 @@ TORRENT_TEST(dht)
|
|||
, sizeof(error_string));
|
||||
if (ret)
|
||||
{
|
||||
fprintf(stderr, "put response: %s\n"
|
||||
fprintf(stdout, "put response: %s\n"
|
||||
, print_entry(response).c_str());
|
||||
TEST_EQUAL(desc2_keys[0].string_value(), "r");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " invalid put response: %s\n%s\n"
|
||||
fprintf(stdout, " invalid put response: %s\n%s\n"
|
||||
, error_string, print_entry(response).c_str());
|
||||
TEST_ERROR(error_string);
|
||||
}
|
||||
|
||||
fprintf(stderr, "PUT CAS 2\n");
|
||||
fprintf(stdout, "PUT CAS 2\n");
|
||||
|
||||
// put the same message again. This should fail because the
|
||||
// CAS hash is outdated, it's not the hash of the value that's
|
||||
|
@ -1162,7 +1162,7 @@ TORRENT_TEST(dht)
|
|||
, sizeof(error_string));
|
||||
if (ret)
|
||||
{
|
||||
fprintf(stderr, "put response: %s\n"
|
||||
fprintf(stdout, "put response: %s\n"
|
||||
, print_entry(response).c_str());
|
||||
TEST_EQUAL(desc_error_keys[1].string_value(), "e");
|
||||
// 301 is the error code for CAS hash mismatch
|
||||
|
@ -1170,7 +1170,7 @@ TORRENT_TEST(dht)
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " invalid put response: %s\n%s\nExpected failure 301 (CAS hash mismatch)\n"
|
||||
fprintf(stdout, " invalid put response: %s\n%s\nExpected failure 301 (CAS hash mismatch)\n"
|
||||
, error_string, print_entry(response).c_str());
|
||||
TEST_ERROR(error_string);
|
||||
}
|
||||
|
@ -1354,7 +1354,7 @@ TORRENT_TEST(dht)
|
|||
//#error test need_refresh
|
||||
|
||||
#if defined TORRENT_DEBUG
|
||||
table.print_state(std::cerr);
|
||||
table.print_state(std::cout);
|
||||
#endif
|
||||
|
||||
table.for_each_node(node_push_back, nop, &nodes);
|
||||
|
@ -1438,7 +1438,7 @@ TORRENT_TEST(dht)
|
|||
TEST_CHECK((id[2] & 0xf8) == (prefixes[i][2] & 0xf8));
|
||||
|
||||
TEST_CHECK(id[19] == rs[i]);
|
||||
fprintf(stderr, "IP address: %s r: %d node ID: %s\n", ips[i]
|
||||
fprintf(stdout, "IP address: %s r: %d node ID: %s\n", ips[i]
|
||||
, rs[i], to_hex(id.to_string()).c_str());
|
||||
}
|
||||
}
|
||||
|
@ -1511,7 +1511,7 @@ TORRENT_TEST(dht)
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " invalid find_node request: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid find_node request: %s\n", print_entry(response).c_str());
|
||||
TEST_ERROR(error_string);
|
||||
break;
|
||||
}
|
||||
|
@ -1539,7 +1539,7 @@ TORRENT_TEST(dht)
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " invalid find_node request: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid find_node request: %s\n", print_entry(response).c_str());
|
||||
TEST_ERROR(error_string);
|
||||
break;
|
||||
}
|
||||
|
@ -1580,7 +1580,7 @@ TORRENT_TEST(dht)
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " invalid get_peers request: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid get_peers request: %s\n", print_entry(response).c_str());
|
||||
TEST_ERROR(error_string);
|
||||
break;
|
||||
}
|
||||
|
@ -1614,7 +1614,7 @@ TORRENT_TEST(dht)
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " invalid get_peers request: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid get_peers request: %s\n", print_entry(response).c_str());
|
||||
TEST_ERROR(error_string);
|
||||
break;
|
||||
}
|
||||
|
@ -1630,7 +1630,7 @@ TORRENT_TEST(dht)
|
|||
for (std::list<std::pair<udp::endpoint, entry> >::iterator i = g_sent_packets.begin()
|
||||
, end(g_sent_packets.end()); i != end; ++i)
|
||||
{
|
||||
// fprintf(stderr, " %s:%d: %s\n", i->first.address().to_string(ec).c_str()
|
||||
// fprintf(stdout, " %s:%d: %s\n", i->first.address().to_string(ec).c_str()
|
||||
// , i->first.port(), i->second.to_string().c_str());
|
||||
TEST_EQUAL(i->second["q"].string(), "announce_peer");
|
||||
}
|
||||
|
@ -1675,7 +1675,7 @@ TORRENT_TEST(dht)
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " invalid get request: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid get request: %s\n", print_entry(response).c_str());
|
||||
TEST_ERROR(error_string);
|
||||
break;
|
||||
}
|
||||
|
@ -1720,7 +1720,7 @@ TORRENT_TEST(dht)
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " invalid get request: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid get request: %s\n", print_entry(response).c_str());
|
||||
TEST_ERROR(error_string);
|
||||
break;
|
||||
}
|
||||
|
@ -1823,7 +1823,7 @@ TORRENT_TEST(dht)
|
|||
, sizeof(error_string));
|
||||
if (!ret)
|
||||
{
|
||||
fprintf(stderr, " invalid get request: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid get request: %s\n", print_entry(response).c_str());
|
||||
TEST_ERROR(error_string);
|
||||
continue;
|
||||
}
|
||||
|
@ -1866,7 +1866,7 @@ TORRENT_TEST(dht)
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " invalid immutable put request: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid immutable put request: %s\n", print_entry(response).c_str());
|
||||
TEST_ERROR(error_string);
|
||||
continue;
|
||||
}
|
||||
|
@ -1920,7 +1920,7 @@ TORRENT_TEST(dht)
|
|||
, sizeof(error_string));
|
||||
if (!ret)
|
||||
{
|
||||
fprintf(stderr, " invalid get request: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid get request: %s\n", print_entry(response).c_str());
|
||||
TEST_ERROR(error_string);
|
||||
continue;
|
||||
}
|
||||
|
@ -1968,7 +1968,7 @@ TORRENT_TEST(dht)
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " invalid put request: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid put request: %s\n", print_entry(response).c_str());
|
||||
TEST_ERROR(error_string);
|
||||
continue;
|
||||
}
|
||||
|
@ -2035,7 +2035,7 @@ TORRENT_TEST(dht)
|
|||
, sizeof(error_string));
|
||||
if (!ret)
|
||||
{
|
||||
fprintf(stderr, " invalid get request: %s\n", print_entry(response).c_str());
|
||||
fprintf(stdout, " invalid get request: %s\n", print_entry(response).c_str());
|
||||
TEST_ERROR(error_string);
|
||||
continue;
|
||||
}
|
||||
|
@ -2161,7 +2161,7 @@ TORRENT_TEST(verify_message)
|
|||
error_code ec;
|
||||
char const test_msg[] = "d1:A4:test1:Bd2:B15:test22:B25:test3ee";
|
||||
bdecode(test_msg, test_msg + sizeof(test_msg)-1, ent, ec);
|
||||
fprintf(stderr, "%s\n", print_entry(ent).c_str());
|
||||
fprintf(stdout, "%s\n", print_entry(ent).c_str());
|
||||
|
||||
bool ret = verify_message(ent, msg_desc, msg_keys, error_string
|
||||
, sizeof(error_string));
|
||||
|
@ -2179,7 +2179,7 @@ TORRENT_TEST(verify_message)
|
|||
|
||||
char const test_msg2[] = "d1:A4:test1:Cd2:C15:test22:C25:test3ee";
|
||||
bdecode(test_msg2, test_msg2 + sizeof(test_msg2)-1, ent, ec);
|
||||
fprintf(stderr, "%s\n", print_entry(ent).c_str());
|
||||
fprintf(stdout, "%s\n", print_entry(ent).c_str());
|
||||
|
||||
ret = verify_message(ent, msg_desc, msg_keys, error_string
|
||||
, sizeof(error_string));
|
||||
|
@ -2198,38 +2198,38 @@ TORRENT_TEST(verify_message)
|
|||
|
||||
char const test_msg3[] = "d1:Cd2:C15:test22:C25:test3ee";
|
||||
bdecode(test_msg3, test_msg3 + sizeof(test_msg3)-1, ent, ec);
|
||||
fprintf(stderr, "%s\n", print_entry(ent).c_str());
|
||||
fprintf(stdout, "%s\n", print_entry(ent).c_str());
|
||||
|
||||
ret = verify_message(ent, msg_desc, msg_keys, error_string
|
||||
, sizeof(error_string));
|
||||
TEST_CHECK(!ret);
|
||||
fprintf(stderr, "%s\n", error_string);
|
||||
fprintf(stdout, "%s\n", error_string);
|
||||
TEST_EQUAL(error_string, std::string("missing 'A' key"));
|
||||
|
||||
char const test_msg4[] = "d1:A6:foobare";
|
||||
bdecode(test_msg4, test_msg4 + sizeof(test_msg4)-1, ent, ec);
|
||||
fprintf(stderr, "%s\n", print_entry(ent).c_str());
|
||||
fprintf(stdout, "%s\n", print_entry(ent).c_str());
|
||||
|
||||
ret = verify_message(ent, msg_desc, msg_keys, error_string
|
||||
, sizeof(error_string));
|
||||
TEST_CHECK(!ret);
|
||||
fprintf(stderr, "%s\n", error_string);
|
||||
fprintf(stdout, "%s\n", error_string);
|
||||
TEST_EQUAL(error_string, std::string("invalid value for 'A'"));
|
||||
|
||||
char const test_msg5[] = "d1:A4:test1:Cd2:C15:test2ee";
|
||||
bdecode(test_msg5, test_msg5 + sizeof(test_msg5)-1, ent, ec);
|
||||
fprintf(stderr, "%s\n", print_entry(ent).c_str());
|
||||
fprintf(stdout, "%s\n", print_entry(ent).c_str());
|
||||
|
||||
ret = verify_message(ent, msg_desc, msg_keys, error_string
|
||||
, sizeof(error_string));
|
||||
TEST_CHECK(!ret);
|
||||
fprintf(stderr, "%s\n", error_string);
|
||||
fprintf(stdout, "%s\n", error_string);
|
||||
TEST_EQUAL(error_string, std::string("missing 'C2' key"));
|
||||
|
||||
// test empty strings [ { "":1 }, "" ]
|
||||
char const test_msg6[] = "ld0:i1ee0:e";
|
||||
bdecode(test_msg6, test_msg6 + sizeof(test_msg6)-1, ent, ec);
|
||||
fprintf(stderr, "%s\n", print_entry(ent).c_str());
|
||||
fprintf(stdout, "%s\n", print_entry(ent).c_str());
|
||||
TEST_CHECK(ent.type() == bdecode_node::list_t);
|
||||
if (ent.type() == bdecode_node::list_t)
|
||||
{
|
||||
|
@ -2283,7 +2283,7 @@ TORRENT_TEST(routing_table_uniform)
|
|||
TEST_EQUAL(tbl.num_active_buckets(), 5);
|
||||
|
||||
#if defined TORRENT_DHT_VERBOSE_LOGGING || defined TORRENT_DEBUG
|
||||
tbl.print_state(std::cerr);
|
||||
tbl.print_state(std::cout);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2308,7 +2308,7 @@ TORRENT_TEST(routing_table_balance)
|
|||
TEST_EQUAL(tbl.num_active_buckets(), 2);
|
||||
|
||||
#if defined TORRENT_DEBUG
|
||||
tbl.print_state(std::cerr);
|
||||
tbl.print_state(std::cout);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2337,7 +2337,7 @@ TORRENT_TEST(routing_table_extended)
|
|||
TEST_EQUAL(tbl.num_active_buckets(), 6);
|
||||
|
||||
#if defined TORRENT_DEBUG
|
||||
tbl.print_state(std::cerr);
|
||||
tbl.print_state(std::cout);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2372,7 +2372,7 @@ TORRENT_TEST(routing_table_set_id)
|
|||
tbl.for_each_node(boost::bind(&inserter, &original_nodes, _1));
|
||||
|
||||
#if defined TORRENT_DEBUG
|
||||
tbl.print_state(std::cerr);
|
||||
tbl.print_state(std::cout);
|
||||
#endif
|
||||
|
||||
id = to_hash("ffffffffffffffffffffffffffffffffffffffff");
|
||||
|
@ -2392,7 +2392,7 @@ TORRENT_TEST(routing_table_set_id)
|
|||
TEST_EQUAL(intersection.size(), remaining_nodes.size());
|
||||
|
||||
#if defined TORRENT_DEBUG
|
||||
tbl.print_state(std::cerr);
|
||||
tbl.print_state(std::cout);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2504,7 +2504,7 @@ TORRENT_TEST(invalid_error_msg)
|
|||
bdecode_node decoded;
|
||||
error_code ec;
|
||||
bdecode(msg_buf, msg_buf + size, decoded, ec);
|
||||
if (ec) fprintf(stderr, "bdecode failed: %s\n", ec.message().c_str());
|
||||
if (ec) fprintf(stdout, "bdecode failed: %s\n", ec.message().c_str());
|
||||
|
||||
dht::msg m(decoded, source);
|
||||
node.incoming(m);
|
||||
|
@ -2563,7 +2563,7 @@ TORRENT_TEST(rpc_invalid_error_msg)
|
|||
bdecode_node decoded;
|
||||
error_code ec;
|
||||
bdecode(msg_buf, msg_buf + size, decoded, ec);
|
||||
if (ec) fprintf(stderr, "bdecode failed: %s\n", ec.message().c_str());
|
||||
if (ec) fprintf(stdout, "bdecode failed: %s\n", ec.message().c_str());
|
||||
|
||||
dht::msg m(decoded, source);
|
||||
node_id nid;
|
||||
|
|
|
@ -97,7 +97,7 @@ TORRENT_TEST(file_status)
|
|||
TEST_CHECK(!ec);
|
||||
|
||||
int diff = int(st2.mtime - st1.mtime);
|
||||
fprintf(stderr, "timestamp difference: %d seconds. expected approx. 3 seconds\n"
|
||||
fprintf(stdout, "timestamp difference: %d seconds. expected approx. 3 seconds\n"
|
||||
, diff);
|
||||
|
||||
TEST_CHECK(diff >= 2 && diff <= 4);
|
||||
|
@ -108,7 +108,7 @@ TORRENT_TEST(directory)
|
|||
error_code ec;
|
||||
|
||||
create_directory("file_test_dir", ec);
|
||||
if (ec) fprintf(stderr, "create_directory: %s\n", ec.message().c_str());
|
||||
if (ec) fprintf(stdout, "create_directory: %s\n", ec.message().c_str());
|
||||
TEST_CHECK(!ec);
|
||||
|
||||
std::string cwd = current_working_directory();
|
||||
|
@ -123,7 +123,7 @@ TORRENT_TEST(directory)
|
|||
std::string f = i.file();
|
||||
TEST_CHECK(files.count(f) == 0);
|
||||
files.insert(f);
|
||||
fprintf(stderr, " %s\n", f.c_str());
|
||||
fprintf(stdout, " %s\n", f.c_str());
|
||||
}
|
||||
|
||||
TEST_CHECK(files.count("abc") == 1);
|
||||
|
@ -140,13 +140,13 @@ TORRENT_TEST(directory)
|
|||
std::string f = i.file();
|
||||
TEST_CHECK(files.count(f) == 0);
|
||||
files.insert(f);
|
||||
fprintf(stderr, " %s\n", f.c_str());
|
||||
fprintf(stdout, " %s\n", f.c_str());
|
||||
}
|
||||
|
||||
remove_all("file_test_dir", ec);
|
||||
if (ec) fprintf(stderr, "remove_all: %s\n", ec.message().c_str());
|
||||
if (ec) fprintf(stdout, "remove_all: %s\n", ec.message().c_str());
|
||||
remove_all("file_test_dir2", ec);
|
||||
if (ec) fprintf(stderr, "remove_all: %s\n", ec.message().c_str());
|
||||
if (ec) fprintf(stdout, "remove_all: %s\n", ec.message().c_str());
|
||||
}
|
||||
|
||||
// test path functions
|
||||
|
@ -289,20 +289,20 @@ TORRENT_TEST(file)
|
|||
TEST_CHECK(f.open("test_file", file::read_write, ec));
|
||||
#endif
|
||||
if (ec)
|
||||
fprintf(stderr, "open failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
fprintf(stdout, "open failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
TEST_EQUAL(ec, error_code());
|
||||
if (ec) fprintf(stderr, "%s\n", ec.message().c_str());
|
||||
if (ec) fprintf(stdout, "%s\n", ec.message().c_str());
|
||||
file::iovec_t b = {(void*)"test", 4};
|
||||
TEST_EQUAL(f.writev(0, &b, 1, ec), 4);
|
||||
if (ec)
|
||||
fprintf(stderr, "writev failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
fprintf(stdout, "writev failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
TEST_CHECK(!ec);
|
||||
char test_buf[5] = {0};
|
||||
b.iov_base = test_buf;
|
||||
b.iov_len = 4;
|
||||
TEST_EQUAL(f.readv(0, &b, 1, ec), 4);
|
||||
if (ec)
|
||||
fprintf(stderr, "readv failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
fprintf(stdout, "readv failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
TEST_EQUAL(ec, error_code());
|
||||
TEST_CHECK(strcmp(test_buf, "test") == 0);
|
||||
f.close();
|
||||
|
@ -319,26 +319,26 @@ TORRENT_TEST(hard_link)
|
|||
file f;
|
||||
TEST_CHECK(f.open("original_file", file::read_write, ec));
|
||||
if (ec)
|
||||
fprintf(stderr, "open failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
fprintf(stdout, "open failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
TEST_EQUAL(ec, error_code());
|
||||
|
||||
file::iovec_t b = {(void*)"abcdefghijklmnopqrstuvwxyz", 26};
|
||||
TEST_EQUAL(f.writev(0, &b, 1, ec), 26);
|
||||
if (ec)
|
||||
fprintf(stderr, "writev failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
fprintf(stdout, "writev failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
TEST_EQUAL(ec, error_code());
|
||||
f.close();
|
||||
|
||||
hard_link("original_file", "second_link", ec);
|
||||
|
||||
if (ec)
|
||||
fprintf(stderr, "hard_link failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
fprintf(stdout, "hard_link failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
TEST_EQUAL(ec, error_code());
|
||||
|
||||
|
||||
TEST_CHECK(f.open("second_link", file::read_write, ec));
|
||||
if (ec)
|
||||
fprintf(stderr, "open failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
fprintf(stdout, "open failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
TEST_EQUAL(ec, error_code());
|
||||
|
||||
char test_buf[27] = {0};
|
||||
|
@ -346,18 +346,18 @@ TORRENT_TEST(hard_link)
|
|||
b.iov_len = 27;
|
||||
TEST_EQUAL(f.readv(0, &b, 1, ec), 26);
|
||||
if (ec)
|
||||
fprintf(stderr, "readv failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
fprintf(stdout, "readv failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
TEST_EQUAL(ec, error_code());
|
||||
TEST_CHECK(strcmp(test_buf, "abcdefghijklmnopqrstuvwxyz") == 0);
|
||||
f.close();
|
||||
|
||||
remove("original_file", ec);
|
||||
if (ec)
|
||||
fprintf(stderr, "remove failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
fprintf(stdout, "remove failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
|
||||
remove("second_link", ec);
|
||||
if (ec)
|
||||
fprintf(stderr, "remove failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
fprintf(stdout, "remove failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
}
|
||||
|
||||
TORRENT_TEST(coalesce_buffer)
|
||||
|
@ -366,13 +366,13 @@ TORRENT_TEST(coalesce_buffer)
|
|||
file f;
|
||||
TEST_CHECK(f.open("test_file", file::read_write, ec));
|
||||
if (ec)
|
||||
fprintf(stderr, "open failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
fprintf(stdout, "open failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
TEST_EQUAL(ec, error_code());
|
||||
if (ec) fprintf(stderr, "%s\n", ec.message().c_str());
|
||||
if (ec) fprintf(stdout, "%s\n", ec.message().c_str());
|
||||
file::iovec_t b[2] = {{(void*)"test", 4}, {(void*)"foobar", 6}};
|
||||
TEST_EQUAL(f.writev(0, b, 2, ec, file::coalesce_buffers), 4 + 6);
|
||||
if (ec)
|
||||
fprintf(stderr, "writev failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
fprintf(stdout, "writev failed: [%s] %s\n", ec.category().name(), ec.message().c_str());
|
||||
TEST_CHECK(!ec);
|
||||
char test_buf1[5] = {0};
|
||||
char test_buf2[7] = {0};
|
||||
|
@ -383,7 +383,7 @@ TORRENT_TEST(coalesce_buffer)
|
|||
TEST_EQUAL(f.readv(0, b, 2, ec), 4 + 6);
|
||||
if (ec)
|
||||
{
|
||||
fprintf(stderr, "readv failed: [%s] %s\n"
|
||||
fprintf(stdout, "readv failed: [%s] %s\n"
|
||||
, ec.category().name(), ec.message().c_str());
|
||||
}
|
||||
TEST_EQUAL(ec, error_code());
|
||||
|
|
|
@ -57,12 +57,12 @@ char data_buffer[4000];
|
|||
|
||||
void print_http_header(http_parser const& p)
|
||||
{
|
||||
std::cerr << time_now_string() << " < " << p.status_code() << " " << p.message() << std::endl;
|
||||
std::cout << time_now_string() << " < " << p.status_code() << " " << p.message() << std::endl;
|
||||
|
||||
for (std::multimap<std::string, std::string>::const_iterator i
|
||||
= p.headers().begin(), end(p.headers().end()); i != end; ++i)
|
||||
{
|
||||
std::cerr << time_now_string() << " < " << i->first << ": " << i->second << std::endl;
|
||||
std::cout << time_now_string() << " < " << i->first << ": " << i->second << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ void http_connect_handler(http_connection& c)
|
|||
++connect_handler_called;
|
||||
TEST_CHECK(c.socket().is_open());
|
||||
error_code ec;
|
||||
std::cerr << time_now_string() << " connected to: " << print_endpoint(c.socket().remote_endpoint(ec))
|
||||
std::cout << time_now_string() << " connected to: " << print_endpoint(c.socket().remote_endpoint(ec))
|
||||
<< std::endl;
|
||||
// this is not necessarily true when using a proxy and proxying hostnames
|
||||
// TEST_CHECK(c.socket().remote_endpoint(ec).address() == address::from_string("127.0.0.1", ec));
|
||||
|
@ -111,9 +111,9 @@ void run_test(std::string const& url, int size, int status, int connected
|
|||
{
|
||||
reset_globals();
|
||||
|
||||
std::cerr << " ===== TESTING: " << url << " =====" << std::endl;
|
||||
std::cout << " ===== TESTING: " << url << " =====" << std::endl;
|
||||
|
||||
std::cerr << time_now_string()
|
||||
std::cout << time_now_string()
|
||||
<< " expecting: size: " << size
|
||||
<< " status: " << status
|
||||
<< " connected: " << connected
|
||||
|
@ -126,14 +126,14 @@ void run_test(std::string const& url, int size, int status, int connected
|
|||
ios.reset();
|
||||
error_code e;
|
||||
ios.run(e);
|
||||
if (e) std::cerr << time_now_string() << " run failed: " << e.message() << std::endl;
|
||||
if (e) std::cout << time_now_string() << " run failed: " << e.message() << std::endl;
|
||||
|
||||
std::cerr << time_now_string() << " connect_handler_called: " << connect_handler_called << std::endl;
|
||||
std::cerr << time_now_string() << " handler_called: " << handler_called << std::endl;
|
||||
std::cerr << time_now_string() << " status: " << http_status << std::endl;
|
||||
std::cerr << time_now_string() << " size: " << data_size << std::endl;
|
||||
std::cerr << time_now_string() << " expected-size: " << size << std::endl;
|
||||
std::cerr << time_now_string() << " error_code: " << g_error_code.message() << std::endl;
|
||||
std::cout << time_now_string() << " connect_handler_called: " << connect_handler_called << std::endl;
|
||||
std::cout << time_now_string() << " handler_called: " << handler_called << std::endl;
|
||||
std::cout << time_now_string() << " status: " << http_status << std::endl;
|
||||
std::cout << time_now_string() << " size: " << data_size << std::endl;
|
||||
std::cout << time_now_string() << " expected-size: " << size << std::endl;
|
||||
std::cout << time_now_string() << " error_code: " << g_error_code.message() << std::endl;
|
||||
TEST_CHECK(connect_handler_called == connected);
|
||||
TEST_CHECK(handler_called == 1);
|
||||
TEST_CHECK(data_size == size || size == -1);
|
||||
|
@ -148,11 +148,11 @@ void write_test_file()
|
|||
error_code ec;
|
||||
file test_file("test_file", file::write_only, ec);
|
||||
TEST_CHECK(!ec);
|
||||
if (ec) fprintf(stderr, "file error: %s\n", ec.message().c_str());
|
||||
if (ec) fprintf(stdout, "file error: %s\n", ec.message().c_str());
|
||||
file::iovec_t b = { data_buffer, 3216};
|
||||
test_file.writev(0, &b, 1, ec);
|
||||
TEST_CHECK(!ec);
|
||||
if (ec) fprintf(stderr, "file error: %s\n", ec.message().c_str());
|
||||
if (ec) fprintf(stdout, "file error: %s\n", ec.message().c_str());
|
||||
test_file.close();
|
||||
}
|
||||
|
||||
|
|
|
@ -45,12 +45,12 @@ using namespace libtorrent;
|
|||
bool cast_vote(ip_voter& ipv, address ext_ip, address voter)
|
||||
{
|
||||
bool new_ip = ipv.cast_vote(ext_ip, 1, voter);
|
||||
fprintf(stderr, "%15s -> %-15s\n"
|
||||
fprintf(stdout, "%15s -> %-15s\n"
|
||||
, print_address(voter).c_str()
|
||||
, print_address(ext_ip).c_str());
|
||||
if (new_ip)
|
||||
{
|
||||
fprintf(stderr, " \x1b[1mnew external IP: %s\x1b[0m\n"
|
||||
fprintf(stdout, " \x1b[1mnew external IP: %s\x1b[0m\n"
|
||||
, print_address(ipv.external_address()).c_str());
|
||||
}
|
||||
return new_ip;
|
||||
|
|
|
@ -92,12 +92,12 @@ TORRENT_TEST(insert)
|
|||
{
|
||||
int index = (i + 0xfff0) & 0xffff;
|
||||
pb.insert(index, reinterpret_cast<int*>(index + 1));
|
||||
fprintf(stderr, "insert: %u (mask: %x)\n", index, int(pb.capacity() - 1));
|
||||
fprintf(stdout, "insert: %u (mask: %x)\n", index, int(pb.capacity() - 1));
|
||||
TEST_EQUAL(pb.capacity(), 512);
|
||||
if (i >= 14)
|
||||
{
|
||||
index = (index - 14) & 0xffff;
|
||||
fprintf(stderr, "remove: %u\n", index);
|
||||
fprintf(stdout, "remove: %u\n", index);
|
||||
TEST_CHECK(pb.remove(index) == reinterpret_cast<int*>(index + 1));
|
||||
TEST_EQUAL(pb.size(), 14);
|
||||
}
|
||||
|
|
|
@ -207,7 +207,7 @@ bool verify_pick(boost::shared_ptr<piece_picker> p
|
|||
std::set<piece_block> blocks;
|
||||
std::copy(picked.begin(), picked.end()
|
||||
, std::insert_iterator<std::set<piece_block> >(blocks, blocks.end()));
|
||||
std::cerr << " verify: " << picked.size() << " " << blocks.size() << std::endl;
|
||||
std::cout << " verify: " << picked.size() << " " << blocks.size() << std::endl;
|
||||
return picked.size() == blocks.size();
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ void print_pick(std::vector<piece_block> const& picked)
|
|||
|
||||
void print_title(char const* name)
|
||||
{
|
||||
std::cerr << "==== " << name << " ====\n";
|
||||
std::cout << "==== " << name << " ====\n";
|
||||
}
|
||||
|
||||
std::vector<piece_block> pick_pieces(boost::shared_ptr<piece_picker> const& p
|
||||
|
@ -453,12 +453,12 @@ TORRENT_TEST(piece_picker)
|
|||
|
||||
p->mark_as_downloading(piece_block(0, 0), &tmp2);
|
||||
|
||||
fprintf(stderr, "num_peers: %d\n", p->num_peers(piece_block(0, 0)));
|
||||
fprintf(stdout, "num_peers: %d\n", p->num_peers(piece_block(0, 0)));
|
||||
TEST_EQUAL(p->num_peers(piece_block(0, 0)), 2);
|
||||
|
||||
p->abort_download(piece_block(0, 0), &tmp1);
|
||||
|
||||
fprintf(stderr, "num_peers: %d\n", p->num_peers(piece_block(0, 0)));
|
||||
fprintf(stdout, "num_peers: %d\n", p->num_peers(piece_block(0, 0)));
|
||||
TEST_EQUAL(p->num_peers(piece_block(0, 0)), 1);
|
||||
|
||||
// ========================================================
|
||||
|
@ -468,7 +468,7 @@ TORRENT_TEST(piece_picker)
|
|||
print_title("test pick lowest availability");
|
||||
p = setup_picker("2223333", "* * * ", "", "");
|
||||
TEST_CHECK(test_pick(p) == 1);
|
||||
|
||||
|
||||
// ========================================================
|
||||
|
||||
// make sure pieces with equal priority and availability
|
||||
|
@ -554,7 +554,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_CHECK(dc == std::make_pair(2, 5000 / 7));
|
||||
|
||||
// ========================================================
|
||||
|
||||
|
||||
// make sure filtered pieces are ignored
|
||||
print_title("test filtered pieces");
|
||||
p = setup_picker("1111111", " ", "0010000", "");
|
||||
|
@ -564,7 +564,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_CHECK(test_pick(p, piece_picker::sequential | piece_picker::reverse) == 2);
|
||||
|
||||
// ========================================================
|
||||
|
||||
|
||||
// make sure we_dont_have works
|
||||
print_title("test we_dont_have");
|
||||
p = setup_picker("1111111", "*******", "0100000", "");
|
||||
|
@ -606,7 +606,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_CHECK(avail[4] != 0);
|
||||
|
||||
// ========================================================
|
||||
|
||||
|
||||
// make sure init preserves priorities
|
||||
print_title("test init");
|
||||
p = setup_picker("1111111", " ", "1111111", "");
|
||||
|
@ -619,7 +619,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_CHECK(p->num_filtered() == 1);
|
||||
TEST_CHECK(p->num_have_filtered() == 0);
|
||||
TEST_CHECK(p->num_have() == 0);
|
||||
|
||||
|
||||
p->we_have(0);
|
||||
|
||||
TEST_CHECK(p->num_filtered() == 0);
|
||||
|
@ -633,7 +633,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_CHECK(p->num_have() == 0);
|
||||
|
||||
// ========================================================
|
||||
|
||||
|
||||
// make sure requested blocks aren't picked
|
||||
print_title("test don't pick requested blocks");
|
||||
p = setup_picker("1111111", " ", "", "");
|
||||
|
@ -974,7 +974,7 @@ TORRENT_TEST(piece_picker)
|
|||
p->we_have(0);
|
||||
TEST_CHECK(p->num_filtered() == 0);
|
||||
TEST_CHECK(p->num_have_filtered() == 1);
|
||||
|
||||
|
||||
p->we_dont_have(0);
|
||||
p->set_piece_priority(0, 7);
|
||||
|
||||
|
@ -984,7 +984,7 @@ TORRENT_TEST(piece_picker)
|
|||
|
||||
for (int i = 0; i < int(picked.size()); ++i)
|
||||
TEST_CHECK(picked[i] == piece_block(i / blocks_per_piece, i % blocks_per_piece));
|
||||
|
||||
|
||||
// test changing priority on a piece we have
|
||||
p->we_have(0);
|
||||
p->set_piece_priority(0, 0);
|
||||
|
@ -996,7 +996,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_CHECK(prios.size() == 7);
|
||||
int prio_comp[] = {0, 6, 5, 4, 3, 2, 1};
|
||||
TEST_CHECK(std::equal(prios.begin(), prios.end(), prio_comp));
|
||||
|
||||
|
||||
std::vector<bool> filter;
|
||||
p->filtered_pieces(filter);
|
||||
TEST_CHECK(prios.size() == 7);
|
||||
|
@ -1017,7 +1017,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_CHECK(int(picked.size()) >= 1);
|
||||
TEST_CHECK(picked.front().piece_index == 1);
|
||||
|
||||
p->restore_piece(0);
|
||||
p->restore_piece(0);
|
||||
picked = pick_pieces(p, "*******", 1, 0, 0, options, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) >= 1);
|
||||
TEST_CHECK(picked.front().piece_index == 0);
|
||||
|
@ -1032,7 +1032,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_CHECK(int(picked.size()) >= 1);
|
||||
TEST_CHECK(picked.front().piece_index == 1);
|
||||
|
||||
p->restore_piece(0);
|
||||
p->restore_piece(0);
|
||||
picked = pick_pieces(p, "*******", 1, 0, 0, options, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) >= 1);
|
||||
TEST_CHECK(picked.front().piece_index == 1);
|
||||
|
@ -1159,7 +1159,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_EQUAL(picked.size(), 1);
|
||||
|
||||
// ========================================================
|
||||
|
||||
|
||||
// test clear_peer
|
||||
print_title("test clear_peer");
|
||||
p = setup_picker("1123333", " ", "", "");
|
||||
|
@ -1190,7 +1190,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_CHECK(std::equal(dls.begin(), dls.end(), expected_dls5));
|
||||
|
||||
// ========================================================
|
||||
|
||||
|
||||
// test have_all and have_none
|
||||
print_title("test have_all and have_none");
|
||||
p = setup_picker("0123333", "* ", "", "");
|
||||
|
@ -1212,7 +1212,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_CHECK(test_pick(p) == 2);
|
||||
|
||||
// ========================================================
|
||||
|
||||
|
||||
// test have_all and have_none
|
||||
print_title("test have_all and have_none with sequential download");
|
||||
p = setup_picker("0123333", "* ", "", "");
|
||||
|
@ -1360,7 +1360,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_CHECK(std::equal(picked_pieces.begin(), picked_pieces.end(), expected_pieces))
|
||||
|
||||
//#error test picking with partial pieces and other peers present so that both backup_pieces and backup_pieces2 are used
|
||||
|
||||
|
||||
// ========================================================
|
||||
|
||||
// test parole mode
|
||||
|
@ -1368,7 +1368,7 @@ TORRENT_TEST(piece_picker)
|
|||
p = setup_picker("3333133", " ", "", "");
|
||||
p->mark_as_finished(piece_block(0, 0), 0);
|
||||
picked = pick_pieces(p, "*******", 1, blocks_per_piece, 0
|
||||
|
||||
|
||||
, options | piece_picker::on_parole | piece_picker::prioritize_partials, empty_vector);
|
||||
TEST_EQUAL(int(picked.size()), blocks_per_piece - 1);
|
||||
for (int i = 1; i < int(picked.size()); ++i)
|
||||
|
@ -1390,7 +1390,7 @@ TORRENT_TEST(piece_picker)
|
|||
p = setup_picker("1111222233334444", " ", "", "");
|
||||
int v[] = {1, 5};
|
||||
const std::vector<int> suggested_pieces(v, v + 2);
|
||||
|
||||
|
||||
picked = pick_pieces(p, "****************", 1, blocks_per_piece
|
||||
, 0, options, suggested_pieces);
|
||||
TEST_CHECK(int(picked.size()) >= blocks_per_piece);
|
||||
|
@ -1413,7 +1413,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_CHECK(int(picked.size()) >= blocks_per_piece);
|
||||
for (int i = 1; i < int(picked.size()); ++i)
|
||||
TEST_CHECK(picked[i] == piece_block(5, i));
|
||||
|
||||
|
||||
// ========================================================
|
||||
|
||||
// test bitfield optimization
|
||||
|
|
|
@ -78,9 +78,9 @@ TORRENT_TEST(primitives)
|
|||
int delay = ae.next_announce_in();
|
||||
TEST_CHECK(delay > last);
|
||||
last = delay;
|
||||
fprintf(stderr, "%d, ", delay);
|
||||
fprintf(stdout, "%d, ", delay);
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stdout, "\n");
|
||||
|
||||
// test error codes
|
||||
TEST_CHECK(error_code(errors::http_error).message() == "HTTP error");
|
||||
|
|
|
@ -95,14 +95,14 @@ TORRENT_TEST(resolve_links)
|
|||
test_torrent_t const& e = test_torrents[i];
|
||||
|
||||
std::string p = combine_path(path, e.filename1) + ".torrent";
|
||||
fprintf(stderr, "loading %s\n", p.c_str());
|
||||
fprintf(stdout, "loading %s\n", p.c_str());
|
||||
boost::shared_ptr<torrent_info> ti1 = boost::make_shared<torrent_info>(p);
|
||||
|
||||
p = combine_path(path, e.filename2) + ".torrent";
|
||||
fprintf(stderr, "loading %s\n", p.c_str());
|
||||
fprintf(stdout, "loading %s\n", p.c_str());
|
||||
boost::shared_ptr<torrent_info> ti2 = boost::make_shared<torrent_info>(p);
|
||||
|
||||
fprintf(stderr, "resolving\n");
|
||||
fprintf(stdout, "resolving\n");
|
||||
resolve_links l(ti1);
|
||||
l.match(ti2, ".");
|
||||
|
||||
|
@ -118,7 +118,7 @@ TORRENT_TEST(resolve_links)
|
|||
for (int i = 0; i < int(links.size()); ++i)
|
||||
{
|
||||
TORRENT_ASSERT(i < fs.num_files());
|
||||
fprintf(stderr, "%s --> %s : %d\n", fs.file_name(i).c_str()
|
||||
fprintf(stdout, "%s --> %s : %d\n", fs.file_name(i).c_str()
|
||||
, links[i].ti ? to_hex(links[i].ti->info_hash()
|
||||
.to_string()).c_str() : "", links[i].file_idx);
|
||||
}
|
||||
|
|
|
@ -46,11 +46,11 @@ using namespace libtorrent;
|
|||
|
||||
void fun(condition_variable* s, libtorrent::mutex* m, int* waiting, int i)
|
||||
{
|
||||
fprintf(stderr, "thread %d waiting\n", i);
|
||||
fprintf(stdout, "thread %d waiting\n", i);
|
||||
libtorrent::mutex::scoped_lock l(*m);
|
||||
*waiting += 1;
|
||||
s->wait(l);
|
||||
fprintf(stderr, "thread %d done\n", i);
|
||||
fprintf(stdout, "thread %d done\n", i);
|
||||
}
|
||||
|
||||
void increment(condition_variable* s, libtorrent::mutex* m, int* waiting, boost::atomic<int>* c)
|
||||
|
|
|
@ -75,7 +75,7 @@ void test_running_torrent(boost::shared_ptr<torrent_info> info, boost::int64_t f
|
|||
torrent_handle h = ses.add_torrent(p, ec);
|
||||
if (ec)
|
||||
{
|
||||
fprintf(stderr, "add_torrent: %s\n", ec.message().c_str());
|
||||
fprintf(stdout, "add_torrent: %s\n", ec.message().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -503,70 +503,70 @@ TORRENT_TEST(verify_encoding)
|
|||
// valid 2-byte sequence
|
||||
test = "filename\xc2\xa1";
|
||||
TEST_CHECK(verify_encoding(test));
|
||||
fprintf(stderr, "%s\n", test.c_str());
|
||||
fprintf(stdout, "%s\n", test.c_str());
|
||||
TEST_CHECK(test == "filename\xc2\xa1");
|
||||
|
||||
// truncated 2-byte sequence
|
||||
test = "filename\xc2";
|
||||
TEST_CHECK(!verify_encoding(test));
|
||||
fprintf(stderr, "%s\n", test.c_str());
|
||||
fprintf(stdout, "%s\n", test.c_str());
|
||||
TEST_CHECK(test == "filename_");
|
||||
|
||||
// valid 3-byte sequence
|
||||
test = "filename\xe2\x9f\xb9";
|
||||
TEST_CHECK(verify_encoding(test));
|
||||
fprintf(stderr, "%s\n", test.c_str());
|
||||
fprintf(stdout, "%s\n", test.c_str());
|
||||
TEST_CHECK(test == "filename\xe2\x9f\xb9");
|
||||
|
||||
// truncated 3-byte sequence
|
||||
test = "filename\xe2\x9f";
|
||||
TEST_CHECK(!verify_encoding(test));
|
||||
fprintf(stderr, "%s\n", test.c_str());
|
||||
fprintf(stdout, "%s\n", test.c_str());
|
||||
TEST_CHECK(test == "filename_");
|
||||
|
||||
// truncated 3-byte sequence
|
||||
test = "filename\xe2";
|
||||
TEST_CHECK(!verify_encoding(test));
|
||||
fprintf(stderr, "%s\n", test.c_str());
|
||||
fprintf(stdout, "%s\n", test.c_str());
|
||||
TEST_CHECK(test == "filename_");
|
||||
|
||||
// valid 4-byte sequence
|
||||
test = "filename\xf0\x9f\x92\x88";
|
||||
TEST_CHECK(verify_encoding(test));
|
||||
fprintf(stderr, "%s\n", test.c_str());
|
||||
fprintf(stdout, "%s\n", test.c_str());
|
||||
TEST_CHECK(test == "filename\xf0\x9f\x92\x88");
|
||||
|
||||
// truncated 4-byte sequence
|
||||
test = "filename\xf0\x9f\x92";
|
||||
TEST_CHECK(!verify_encoding(test));
|
||||
fprintf(stderr, "%s\n", test.c_str());
|
||||
fprintf(stdout, "%s\n", test.c_str());
|
||||
TEST_CHECK(test == "filename_");
|
||||
|
||||
// 5-byte utf-8 sequence (not allowed)
|
||||
test = "filename\xf8\x9f\x9f\x9f\x9f""foobar";
|
||||
TEST_CHECK(!verify_encoding(test));
|
||||
fprintf(stderr, "%s\n", test.c_str());
|
||||
fprintf(stdout, "%s\n", test.c_str());
|
||||
TEST_CHECK(test == "filename_____foobar");
|
||||
|
||||
// redundant (overlong) 2-byte sequence
|
||||
// ascii code 0x2e encoded with a leading 0
|
||||
test = "filename\xc0\xae";
|
||||
TEST_CHECK(!verify_encoding(test));
|
||||
fprintf(stderr, "%s\n", test.c_str());
|
||||
fprintf(stdout, "%s\n", test.c_str());
|
||||
TEST_CHECK(test == "filename__");
|
||||
|
||||
// redundant (overlong) 3-byte sequence
|
||||
// ascii code 0x2e encoded with two leading 0s
|
||||
test = "filename\xe0\x80\xae";
|
||||
TEST_CHECK(!verify_encoding(test));
|
||||
fprintf(stderr, "%s\n", test.c_str());
|
||||
fprintf(stdout, "%s\n", test.c_str());
|
||||
TEST_CHECK(test == "filename___");
|
||||
|
||||
// redundant (overlong) 4-byte sequence
|
||||
// ascii code 0x2e encoded with three leading 0s
|
||||
test = "filename\xf0\x80\x80\xae";
|
||||
TEST_CHECK(!verify_encoding(test));
|
||||
fprintf(stderr, "%s\n", test.c_str());
|
||||
fprintf(stdout, "%s\n", test.c_str());
|
||||
TEST_CHECK(test == "filename____");
|
||||
}
|
||||
|
||||
|
@ -618,12 +618,12 @@ TORRENT_TEST(parse_torrents)
|
|||
std::string root_dir = parent_path(current_working_directory());
|
||||
for (int i = 0; i < int(sizeof(test_torrents)/sizeof(test_torrents[0])); ++i)
|
||||
{
|
||||
fprintf(stderr, "loading %s\n", test_torrents[i].file);
|
||||
fprintf(stdout, "loading %s\n", test_torrents[i].file);
|
||||
std::string filename = combine_path(combine_path(root_dir, "test_torrents")
|
||||
, test_torrents[i].file);
|
||||
boost::shared_ptr<torrent_info> ti(new torrent_info(filename, ec));
|
||||
TEST_CHECK(!ec);
|
||||
if (ec) fprintf(stderr, " loading(\"%s\") -> failed %s\n", filename.c_str()
|
||||
if (ec) fprintf(stdout, " loading(\"%s\") -> failed %s\n", filename.c_str()
|
||||
, ec.message().c_str());
|
||||
|
||||
if (std::string(test_torrents[i].file) == "whitespace_url.torrent")
|
||||
|
@ -737,7 +737,7 @@ TORRENT_TEST(parse_torrents)
|
|||
int first = ti->map_file(i, 0, 0).piece;
|
||||
int last = ti->map_file(i, (std::max)(fs.file_size(i)-1, boost::int64_t(0)), 0).piece;
|
||||
int flags = fs.file_flags(i);
|
||||
fprintf(stderr, " %11" PRId64 " %c%c%c%c [ %4d, %4d ] %7u %s %s %s%s\n"
|
||||
fprintf(stdout, " %11" PRId64 " %c%c%c%c [ %4d, %4d ] %7u %s %s %s%s\n"
|
||||
, fs.file_size(i)
|
||||
, (flags & file_storage::flag_pad_file)?'p':'-'
|
||||
, (flags & file_storage::flag_executable)?'x':'-'
|
||||
|
@ -769,10 +769,10 @@ TORRENT_TEST(parse_torrents)
|
|||
for (int i = 0; i < int(sizeof(test_error_torrents)/sizeof(test_error_torrents[0])); ++i)
|
||||
{
|
||||
error_code ec;
|
||||
fprintf(stderr, "loading %s\n", test_error_torrents[i].file);
|
||||
fprintf(stdout, "loading %s\n", test_error_torrents[i].file);
|
||||
boost::shared_ptr<torrent_info> ti(new torrent_info(combine_path(
|
||||
combine_path(root_dir, "test_torrents"), test_error_torrents[i].file), ec));
|
||||
fprintf(stderr, "E: \"%s\"\nexpected: \"%s\"\n", ec.message().c_str()
|
||||
fprintf(stdout, "E: \"%s\"\nexpected: \"%s\"\n", ec.message().c_str()
|
||||
, test_error_torrents[i].error.message().c_str());
|
||||
TEST_CHECK(ec.message() == test_error_torrents[i].error.message());
|
||||
}
|
||||
|
@ -861,7 +861,7 @@ void test_resolve_duplicates(int test_case)
|
|||
{
|
||||
std::string p = ti.files().file_path(i);
|
||||
convert_path_to_posix(p);
|
||||
fprintf(stderr, "%s == %s\n", p.c_str(), filenames[test_case][i]);
|
||||
fprintf(stdout, "%s == %s\n", p.c_str(), filenames[test_case][i]);
|
||||
|
||||
TEST_EQUAL(p, filenames[test_case][i]);
|
||||
}
|
||||
|
@ -920,7 +920,7 @@ TORRENT_TEST(copy)
|
|||
std::string p = a->files().file_path(i);
|
||||
convert_path_to_posix(p);
|
||||
TEST_EQUAL(p, expected_files[i]);
|
||||
fprintf(stderr, "%s\n", p.c_str());
|
||||
fprintf(stdout, "%s\n", p.c_str());
|
||||
|
||||
TEST_EQUAL(a->files().hash(i), file_hashes[i]);
|
||||
}
|
||||
|
@ -942,7 +942,7 @@ TORRENT_TEST(copy)
|
|||
std::string p = b->files().file_path(i);
|
||||
convert_path_to_posix(p);
|
||||
TEST_EQUAL(p, expected_files[i]);
|
||||
fprintf(stderr, "%s\n", p.c_str());
|
||||
fprintf(stdout, "%s\n", p.c_str());
|
||||
|
||||
TEST_EQUAL(b->files().hash(i), file_hashes[i]);
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ void test_parse(char const* in, char const* expected)
|
|||
std::string out;
|
||||
xml_parse(in, in + strlen(in), boost::bind(&parser_callback
|
||||
, boost::ref(out), _1, _2, _3, _4, _5));
|
||||
fprintf(stderr, "in: %s\n out: %s\nexpected: %s\n"
|
||||
fprintf(stdout, "in: %s\n out: %s\nexpected: %s\n"
|
||||
, in, out.c_str(), expected);
|
||||
TEST_EQUAL(out, expected);
|
||||
}
|
||||
|
@ -280,10 +280,10 @@ TORRENT_TEST(upnp_parser1)
|
|||
xml_parse(upnp_xml, upnp_xml + sizeof(upnp_xml)
|
||||
, boost::bind(&find_control_url, _1, _2, _3, boost::ref(xml_s)));
|
||||
|
||||
std::cerr << "namespace " << xml_s.service_type << std::endl;
|
||||
std::cerr << "url_base: " << xml_s.url_base << std::endl;
|
||||
std::cerr << "control_url: " << xml_s.control_url << std::endl;
|
||||
std::cerr << "model: " << xml_s.model << std::endl;
|
||||
std::cout << "namespace " << xml_s.service_type << std::endl;
|
||||
std::cout << "url_base: " << xml_s.url_base << std::endl;
|
||||
std::cout << "control_url: " << xml_s.control_url << std::endl;
|
||||
std::cout << "model: " << xml_s.model << std::endl;
|
||||
TEST_EQUAL(xml_s.url_base, "http://192.168.0.1:5678");
|
||||
TEST_EQUAL(xml_s.control_url, "/WANIPConnection");
|
||||
TEST_EQUAL(xml_s.model, "D-Link Router");
|
||||
|
@ -295,10 +295,10 @@ TORRENT_TEST(upnp_parser2)
|
|||
xml_parse(upnp_xml2, upnp_xml2 + sizeof(upnp_xml2)
|
||||
, boost::bind(&find_control_url, _1, _2, _3, boost::ref(xml_s)));
|
||||
|
||||
std::cerr << "namespace " << xml_s.service_type << std::endl;
|
||||
std::cerr << "url_base: " << xml_s.url_base << std::endl;
|
||||
std::cerr << "control_url: " << xml_s.control_url << std::endl;
|
||||
std::cerr << "model: " << xml_s.model << std::endl;
|
||||
std::cout << "namespace " << xml_s.service_type << std::endl;
|
||||
std::cout << "url_base: " << xml_s.url_base << std::endl;
|
||||
std::cout << "control_url: " << xml_s.control_url << std::endl;
|
||||
std::cout << "model: " << xml_s.model << std::endl;
|
||||
TEST_EQUAL(xml_s.url_base, "http://192.168.1.1:49152");
|
||||
TEST_EQUAL(xml_s.control_url, "/upnp/control/WANPPPConn1");
|
||||
TEST_EQUAL(xml_s.model, "Wireless-G ADSL Home Gateway");
|
||||
|
|
|
@ -92,7 +92,7 @@ void test_transfer(lt::session& ses, boost::shared_ptr<torrent_info> torrent_fil
|
|||
|
||||
static char const* test_name[] = {"no", "SOCKS4", "SOCKS5", "SOCKS5 password", "HTTP", "HTTP password"};
|
||||
|
||||
fprintf(stderr, "\n\n ==== TESTING === proxy: %s ==== protocol: %s "
|
||||
fprintf(stdout, "\n\n ==== TESTING === proxy: %s ==== protocol: %s "
|
||||
"==== seed: %s === transfer-encoding: %s === corruption: %s "
|
||||
"==== keepalive: %s\n\n\n"
|
||||
, test_name[proxy], protocol, url_seed ? "URL seed" : "HTTP seed"
|
||||
|
@ -171,17 +171,17 @@ void test_transfer(lt::session& ses, boost::shared_ptr<torrent_info> torrent_fil
|
|||
|
||||
if (test_ban && th.url_seeds().empty() && th.http_seeds().empty())
|
||||
{
|
||||
fprintf(stderr, "testing ban: URL seed removed\n");
|
||||
fprintf(stdout, "testing ban: URL seed removed\n");
|
||||
// when we don't have any web seeds left, we know we successfully banned it
|
||||
break;
|
||||
}
|
||||
|
||||
if (s.is_seeding)
|
||||
{
|
||||
fprintf(stderr, "SEEDING\n");
|
||||
fprintf(stderr, "session.payload: %d session.redundant: %d\n"
|
||||
fprintf(stdout, "SEEDING\n");
|
||||
fprintf(stdout, "session.payload: %d session.redundant: %d\n"
|
||||
, int(cnt["net.recv_payload_bytes"]), int(cnt["net.recv_redundant_bytes"]));
|
||||
fprintf(stderr, "torrent.payload: %d torrent.redundant: %d\n"
|
||||
fprintf(stdout, "torrent.payload: %d torrent.redundant: %d\n"
|
||||
, int(s.total_payload_download), int(s.total_redundant_bytes));
|
||||
|
||||
TEST_EQUAL(s.total_payload_download - s.total_redundant_bytes, total_size - pad_file_size);
|
||||
|
@ -228,7 +228,7 @@ void test_transfer(lt::session& ses, boost::shared_ptr<torrent_info> torrent_fil
|
|||
&& cnt["disk.disk_blocks_in_use"]
|
||||
== (torrent_file->total_size() + 0x3fff) / 0x4000)
|
||||
break;
|
||||
fprintf(stderr, "cache_size: %d/%d\n", int(cnt["disk.read_cache_blocks"])
|
||||
fprintf(stdout, "cache_size: %d/%d\n", int(cnt["disk.read_cache_blocks"])
|
||||
, int(cnt["disk.disk_blocks_in_use"]));
|
||||
test_sleep(100);
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ void test_transfer(lt::session& ses, boost::shared_ptr<torrent_info> torrent_fil
|
|||
{
|
||||
bool const expect = !fs.pad_file_at(i);
|
||||
std::string file_path = combine_path(save_path, fs.file_path(i));
|
||||
fprintf(stderr, "checking file: %s\n", file_path.c_str());
|
||||
fprintf(stdout, "checking file: %s\n", file_path.c_str());
|
||||
TEST_EQUAL(exists(file_path), expect);
|
||||
}
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ int EXPORT run_http_suite(int proxy, char const* protocol, bool test_url_seed
|
|||
{
|
||||
char url[512];
|
||||
snprintf(url, sizeof(url), ("%s://127.0.0.1:%d/" + save_path).c_str(), protocol, port);
|
||||
fprintf(stderr, "testing: %s\n", url);
|
||||
fprintf(stdout, "testing: %s\n", url);
|
||||
|
||||
create_directories(combine_path(save_path, "torrent_dir"), ec);
|
||||
|
||||
|
@ -368,7 +368,7 @@ int EXPORT run_http_suite(int proxy, char const* protocol, bool test_url_seed
|
|||
{
|
||||
char url[512];
|
||||
snprintf(url, sizeof(url), "%s://127.0.0.1:%d/%s/seed", protocol, port, save_path.c_str());
|
||||
fprintf(stderr, "testing: %s\n", url);
|
||||
fprintf(stdout, "testing: %s\n", url);
|
||||
|
||||
// there's really just one test case for http seeds
|
||||
test_cases.push_back(torrent_args().file("589824,name=seed")
|
||||
|
@ -377,7 +377,7 @@ int EXPORT run_http_suite(int proxy, char const* protocol, bool test_url_seed
|
|||
|
||||
for (int a = 0; a < int(test_cases.size()); ++a)
|
||||
{
|
||||
fprintf(stderr, "\n\n ==== test case %d ====\n\n\n", a);
|
||||
fprintf(stdout, "\n\n ==== test case %d ====\n\n\n", a);
|
||||
|
||||
boost::shared_ptr<torrent_info> torrent_file = make_test_torrent(test_cases[a]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue