From d64d12e50dc4dae47aedfb73a3a298cb05d4a420 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 24 Nov 2013 01:32:51 +0000 Subject: [PATCH] merge test_read_piece from RC_0_16 --- src/torrent.cpp | 3 +- test/Jamfile | 1 + test/Makefile.am | 4 ++ test/setup_transfer.cpp | 9 ++- test/setup_transfer.hpp | 3 +- test/test_checking.cpp | 2 - test/test_read_piece.cpp | 140 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 156 insertions(+), 6 deletions(-) create mode 100644 test/test_read_piece.cpp diff --git a/src/torrent.cpp b/src/torrent.cpp index 98ecafb3f..a7d7136e3 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1168,7 +1168,8 @@ namespace libtorrent pause(); } - void torrent::on_disk_read_complete(int ret, disk_io_job const& j, peer_request r, read_piece_struct* rp) + void torrent::on_disk_read_complete(int ret, disk_io_job const& j + , peer_request r, read_piece_struct* rp) { TORRENT_ASSERT(m_ses.is_network_thread()); diff --git a/test/Jamfile b/test/Jamfile index a9ff18bf8..be73dee21 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -126,6 +126,7 @@ test-suite libtorrent : [ run test_torrent_parse.cpp ] [ run test_session.cpp ] [ run test_upnp.cpp ] + [ run test_read_piece.cpp ] [ run test_ssl.cpp ] [ run test_tracker.cpp ] diff --git a/test/Makefile.am b/test/Makefile.am index f9ab02b81..c7cb514dc 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,6 +1,7 @@ test_programs = \ test_file \ test_file_storage \ + test_privacy \ test_auto_unchoke \ test_bandwidth_limiter \ test_bdecode_performance \ @@ -25,12 +26,15 @@ test_programs = \ test_http_parser \ test_magnet \ test_packet_buffer \ + test_read_piece \ test_rss \ + test_ssl \ test_storage \ test_swarm \ test_threads \ test_torrent \ test_torrent_parse \ + test_tracker \ test_trackers_extension \ test_transfer \ test_upnp \ diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index b6d316cbe..69ec9d1c6 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -92,15 +92,20 @@ int print_failures() std::auto_ptr wait_for_alert(session& ses, int type, char const* name) { std::auto_ptr ret; + ptime end = time_now() + seconds(10); while (!ret.get()) { - ses.wait_for_alert(milliseconds(5000)); + ptime now = time_now(); + if (now > end) return std::auto_ptr(); + + ses.wait_for_alert(end - now); std::deque alerts; ses.pop_alerts(&alerts); for (std::deque::iterator i = alerts.begin() , end(alerts.end()); i != end; ++i) { - fprintf(stderr, "%s: %s: [%s] %s\n", time_now_string(), name, (*i)->what(), (*i)->message().c_str()); + fprintf(stderr, "%s: %s: [%s] %s\n", time_now_string(), name + , (*i)->what(), (*i)->message().c_str()); if (!ret.get() && (*i)->type() == type) { ret = std::auto_ptr(*i); diff --git a/test/setup_transfer.hpp b/test/setup_transfer.hpp index 6af5c4cfe..720cc5784 100644 --- a/test/setup_transfer.hpp +++ b/test/setup_transfer.hpp @@ -51,7 +51,8 @@ void EXPORT save_file(char const* filename, char const* data, int size); void EXPORT report_failure(char const* err, char const* file, int line); -std::auto_ptr EXPORT wait_for_alert(libtorrent::session& sHTTP/1.1 200 OK Connection: close Transfer-Encoding: chunked Cache-Control: max-age=0, private, must-revalidate, no-transform Set-Cookie: i_like_gitea=f7d0225524c91996; Path=/; HttpOnly; Secure; SameSite=Lax Set-Cookie: _csrf=UdtIW7ABpK5hmVlciHpg6QTG5UA6MTc1MzI1NDc2ODk5ODE3OTgxOA; Path=/; Max-Age=86400; HttpOnly; Secure; SameSite=Lax X-Frame-Options: SAMEORIGIN Date: Wed, 23 Jul 2025 07:12:49 GMT Content-Type: text/plain; charset=utf-8 X-Cache-Status: HIT X-Cache-Age: 0 2374 From d64d12e50dc4dae47aedfb73a3a298cb05d4a420 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 24 Nov 2013 01:32:51 +0000 Subject: [PATCH] merge test_read_piece from RC_0_16 --- src/torrent.cpp | 3 +- test/Jamfile | 1 + test/Makefile.am | 4 ++ test/setup_transfer.cpp | 9 ++- test/setup_transfer.hpp | 3 +- test/test_checking.cpp | 2 - test/test_read_piece.cpp | 140 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 156 insertions(+), 6 deletions(-) create mode 100644 test/test_read_piece.cpp diff --git a/src/torrent.cpp b/src/torrent.cpp index 98ecafb3f..a7d7136e3 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1168,7 +1168,8 @@ namespace libtorrent pause(); } - void torrent::on_disk_read_complete(int ret, disk_io_job const& j, peer_request r, read_piece_struct* rp) + void torrent::on_disk_read_complete(int ret, disk_io_job const& j + , peer_request r, read_piece_struct* rp) { TORRENT_ASSERT(m_ses.is_network_thread()); diff --git a/test/Jamfile b/test/Jamfile index a9ff18bf8..be73dee21 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -126,6 +126,7 @@ test-suite libtorrent : [ run test_torrent_parse.cpp ] [ run test_session.cpp ] [ run test_upnp.cpp ] + [ run test_read_piece.cpp ] [ run test_ssl.cpp ] [ run test_tracker.cpp ] diff --git a/test/Makefile.am b/test/Makefile.am index f9ab02b81..c7cb514dc 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,6 +1,7 @@ test_programs = \ test_file \ test_file_storage \ + test_privacy \ test_auto_unchoke \ test_bandwidth_limiter \ test_bdecode_performance \ @@ -25,12 +26,15 @@ test_programs = \ test_http_parser \ test_magnet \ test_packet_buffer \ + test_read_piece \ test_rss \ + test_ssl \ test_storage \ test_swarm \ test_threads \ test_torrent \ test_torrent_parse \ + test_tracker \ test_trackers_extension \ test_transfer \ test_upnp \ diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index b6d316cbe..69ec9d1c6 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -92,15 +92,20 @@ int print_failures() std::auto_ptr wait_for_alert(session& ses, int type, char const* name) { std::auto_ptr ret; + ptime end = time_now() + seconds(10); while (!ret.get()) { - ses.wait_for_alert(milliseconds(5000)); + ptime now = time_now(); + if (now > end) return std::auto_ptr(); + + ses.wait_for_alert(end - now); std::deque alerts; ses.pop_alerts(&alerts); for (std::deque::iterator i = alerts.begin() , end(alerts.end()); i != end; ++i) { - fprintf(stderr, "%s: %s: [%s] %s\n", time_now_string(), name, (*i)->what(), (*i)->message().c_str()); + fprintf(stderr, "%s: %s: [%s] %s\n", time_now_string(), name + , (*i)->what(), (*i)->message().c_str()); if (!ret.get() && (*i)->type() == type) { ret = std::auto_ptr(*i); diff --git a/test/setup_transfer.hpp b/test/setup_transfer.hpp index 6af5c4cfe..720cc5784 100644 --- a/test/setup_transfer.hpp +++ b/test/setup_transfer.hpp @@ -51,7 +51,8 @@ void EXPORT save_file(char const* filename, char const* data, int size); void EXPORT report_failure(char const* err, char const* file, int line); -std::auto_ptr EXPORT wait_for_alert(libtorrent::session& s 0