forked from premiere/premiere-libtorrent
fix test builds without deprecated functions
This commit is contained in:
parent
e2abfa8ab4
commit
bed6d5c233
|
@ -368,9 +368,10 @@ namespace libtorrent
|
||||||
// included. This flag is on by default. See add_torrent_params.
|
// included. This flag is on by default. See add_torrent_params.
|
||||||
void post_torrent_updates();
|
void post_torrent_updates();
|
||||||
|
|
||||||
// This function will post a session_stats_alert object, containing a snapshot of
|
// This function will post a session_stats_alert object, containing a
|
||||||
// the performance counters from the internals of libtorrent. To interpret these counters,
|
// snapshot of the performance counters from the internals of libtorrent.
|
||||||
// query the session via session_stats_metrics().
|
// To interpret these counters, query the session via
|
||||||
|
// session_stats_metrics().
|
||||||
//
|
//
|
||||||
// For more information, see the session-statistics_ section.
|
// For more information, see the session-statistics_ section.
|
||||||
void post_session_stats();
|
void post_session_stats();
|
||||||
|
|
|
@ -3331,7 +3331,7 @@ namespace libtorrent
|
||||||
|
|
||||||
// disconnect if the peer has the same peer-id as ourself
|
// disconnect if the peer has the same peer-id as ourself
|
||||||
// since it most likely is ourself then
|
// since it most likely is ourself then
|
||||||
if (pid == m_ses.get_peer_id())
|
if (pid == m_our_peer_id)
|
||||||
{
|
{
|
||||||
if (peer_info_struct()) t->ban_peer(peer_info_struct());
|
if (peer_info_struct()) t->ban_peer(peer_info_struct());
|
||||||
disconnect(errors::self_connection, op_bittorrent, 1);
|
disconnect(errors::self_connection, op_bittorrent, 1);
|
||||||
|
|
|
@ -121,6 +121,27 @@ int print_failures()
|
||||||
return tests_failure;
|
return tests_failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<std::string, boost::uint64_t> get_counters(libtorrent::session& s)
|
||||||
|
{
|
||||||
|
using namespace libtorrent;
|
||||||
|
s.post_session_stats();
|
||||||
|
|
||||||
|
std::map<std::string, boost::uint64_t> ret;
|
||||||
|
std::auto_ptr<alert> a = wait_for_alert(s, session_stats_alert::alert_type
|
||||||
|
, "get_counters()");
|
||||||
|
|
||||||
|
TEST_CHECK(a.get());
|
||||||
|
if (!a.get()) return ret;
|
||||||
|
|
||||||
|
session_stats_alert* sa = alert_cast<session_stats_alert>(a.get());
|
||||||
|
if (!sa) return ret;
|
||||||
|
|
||||||
|
static std::vector<stats_metric> metrics = session_stats_metrics();
|
||||||
|
for (int i = 0; i < metrics.size(); ++i)
|
||||||
|
ret[metrics[i].name] = sa->values[metrics[i].value_index];
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
std::auto_ptr<alert> wait_for_alert(lt::session& ses, int type, char const* name)
|
std::auto_ptr<alert> wait_for_alert(lt::session& ses, int type, char const* name)
|
||||||
{
|
{
|
||||||
std::auto_ptr<alert> ret;
|
std::auto_ptr<alert> ret;
|
||||||
|
|
|
@ -59,6 +59,8 @@ libtorrent::address EXPORT rand_v6();
|
||||||
libtorrent::tcp::endpoint EXPORT rand_tcp_ep();
|
libtorrent::tcp::endpoint EXPORT rand_tcp_ep();
|
||||||
libtorrent::udp::endpoint EXPORT rand_udp_ep();
|
libtorrent::udp::endpoint EXPORT rand_udp_ep();
|
||||||
|
|
||||||
|
std::map<std::string, boost::uint64_t> EXPORT get_counters(libtorrent::session& s);
|
||||||
|
|
||||||
std::auto_ptr<libtorrent::alert> EXPORT wait_for_alert(
|
std::auto_ptr<libtorrent::alert> EXPORT wait_for_alert(
|
||||||
libtorrent::session& ses, int type, char const* name = "");
|
libtorrent::session& ses, int type, char const* name = "");
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/block_cache.hpp"
|
#include "libtorrent/block_cache.hpp"
|
||||||
#include "libtorrent/io_service.hpp"
|
#include "libtorrent/io_service.hpp"
|
||||||
#include "libtorrent/alert.hpp"
|
#include "libtorrent/alert.hpp"
|
||||||
|
#include "libtorrent/alert_types.hpp"
|
||||||
#include "libtorrent/disk_io_thread.hpp"
|
#include "libtorrent/disk_io_thread.hpp"
|
||||||
#include "libtorrent/storage.hpp"
|
#include "libtorrent/storage.hpp"
|
||||||
#include "libtorrent/alert_dispatcher.hpp"
|
#include "libtorrent/alert_dispatcher.hpp"
|
||||||
|
#include "libtorrent/session.hpp"
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
@ -116,7 +118,6 @@ void nop() {}
|
||||||
wj.storage = pm; \
|
wj.storage = pm; \
|
||||||
cached_piece_entry* pe = NULL; \
|
cached_piece_entry* pe = NULL; \
|
||||||
int ret = 0; \
|
int ret = 0; \
|
||||||
cache_status status; \
|
|
||||||
file::iovec_t iov[1]
|
file::iovec_t iov[1]
|
||||||
|
|
||||||
#define WRITE_BLOCK(p, b) \
|
#define WRITE_BLOCK(p, b) \
|
||||||
|
@ -166,21 +167,23 @@ void test_write()
|
||||||
// write block (0,0)
|
// write block (0,0)
|
||||||
WRITE_BLOCK(0, 0);
|
WRITE_BLOCK(0, 0);
|
||||||
|
|
||||||
bc.get_stats(&status);
|
counters c;
|
||||||
TEST_EQUAL(status.blocks_read_hit, 0);
|
bc.update_stats_counters(c);
|
||||||
TEST_EQUAL(status.write_cache_size, 1);
|
TEST_EQUAL(c[counters::write_cache_blocks], 1);
|
||||||
TEST_EQUAL(status.read_cache_size, 0);
|
TEST_EQUAL(c[counters::read_cache_blocks], 0);
|
||||||
TEST_EQUAL(status.pinned_blocks, 0);
|
TEST_EQUAL(c[counters::pinned_blocks], 0);
|
||||||
TEST_EQUAL(status.arc_mru_size, 0);
|
TEST_EQUAL(c[counters::arc_mru_size], 0);
|
||||||
TEST_EQUAL(status.arc_mru_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mru_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_write_size, 1);
|
TEST_EQUAL(c[counters::arc_write_size], 1);
|
||||||
TEST_EQUAL(status.arc_volatile_size, 0);
|
TEST_EQUAL(c[counters::arc_volatile_size], 0);
|
||||||
|
|
||||||
// try to read it back
|
// try to read it back
|
||||||
READ_BLOCK(0, 0, 1);
|
READ_BLOCK(0, 0, 1);
|
||||||
TEST_EQUAL(bc.pinned_blocks(), 1);
|
TEST_EQUAL(bc.pinned_blocks(), 1);
|
||||||
|
bc.update_stats_counters(c);
|
||||||
|
TEST_EQUAL(c[counters::pinned_blocks], 1);
|
||||||
|
|
||||||
// it's supposed to be a cache hit
|
// it's supposed to be a cache hit
|
||||||
TEST_CHECK(ret >= 0);
|
TEST_CHECK(ret >= 0);
|
||||||
|
@ -188,6 +191,8 @@ void test_write()
|
||||||
// return the reference to the buffer we just read
|
// return the reference to the buffer we just read
|
||||||
RETURN_BUFFER;
|
RETURN_BUFFER;
|
||||||
TEST_EQUAL(bc.pinned_blocks(), 0);
|
TEST_EQUAL(bc.pinned_blocks(), 0);
|
||||||
|
bc.update_stats_counters(c);
|
||||||
|
TEST_EQUAL(c[counters::pinned_blocks], 0);
|
||||||
|
|
||||||
// try to read block (1, 0)
|
// try to read block (1, 0)
|
||||||
READ_BLOCK(1, 0, 1);
|
READ_BLOCK(1, 0, 1);
|
||||||
|
@ -195,6 +200,8 @@ void test_write()
|
||||||
// that's supposed to be a cache miss
|
// that's supposed to be a cache miss
|
||||||
TEST_CHECK(ret < 0);
|
TEST_CHECK(ret < 0);
|
||||||
TEST_EQUAL(bc.pinned_blocks(), 0);
|
TEST_EQUAL(bc.pinned_blocks(), 0);
|
||||||
|
bc.update_stats_counters(c);
|
||||||
|
TEST_EQUAL(c[counters::pinned_blocks], 0);
|
||||||
|
|
||||||
// just in case it wasn't we're supposed to return the reference
|
// just in case it wasn't we're supposed to return the reference
|
||||||
// to the buffer
|
// to the buffer
|
||||||
|
@ -225,17 +232,17 @@ void test_insert()
|
||||||
|
|
||||||
INSERT(0, 0);
|
INSERT(0, 0);
|
||||||
|
|
||||||
bc.get_stats(&status);
|
counters c;
|
||||||
TEST_EQUAL(status.blocks_read_hit, 0);
|
bc.update_stats_counters(c);
|
||||||
TEST_EQUAL(status.write_cache_size, 0);
|
TEST_EQUAL(c[counters::write_cache_blocks], 0);
|
||||||
TEST_EQUAL(status.read_cache_size, 1);
|
TEST_EQUAL(c[counters::read_cache_blocks], 1);
|
||||||
TEST_EQUAL(status.pinned_blocks, 0);
|
TEST_EQUAL(c[counters::pinned_blocks], 0);
|
||||||
TEST_EQUAL(status.arc_mru_size, 1);
|
TEST_EQUAL(c[counters::arc_mru_size], 1);
|
||||||
TEST_EQUAL(status.arc_mru_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mru_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_write_size, 0);
|
TEST_EQUAL(c[counters::arc_write_size], 0);
|
||||||
TEST_EQUAL(status.arc_volatile_size, 0);
|
TEST_EQUAL(c[counters::arc_volatile_size], 0);
|
||||||
|
|
||||||
tailqueue jobs;
|
tailqueue jobs;
|
||||||
bc.clear(jobs);
|
bc.clear(jobs);
|
||||||
|
@ -247,17 +254,17 @@ void test_evict()
|
||||||
|
|
||||||
INSERT(0, 0);
|
INSERT(0, 0);
|
||||||
|
|
||||||
bc.get_stats(&status);
|
counters c;
|
||||||
TEST_EQUAL(status.blocks_read_hit, 0);
|
bc.update_stats_counters(c);
|
||||||
TEST_EQUAL(status.write_cache_size, 0);
|
TEST_EQUAL(c[counters::write_cache_blocks], 0);
|
||||||
TEST_EQUAL(status.read_cache_size, 1);
|
TEST_EQUAL(c[counters::read_cache_blocks], 1);
|
||||||
TEST_EQUAL(status.pinned_blocks, 0);
|
TEST_EQUAL(c[counters::pinned_blocks], 0);
|
||||||
TEST_EQUAL(status.arc_mru_size, 1);
|
TEST_EQUAL(c[counters::arc_mru_size], 1);
|
||||||
TEST_EQUAL(status.arc_mru_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mru_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_write_size, 0);
|
TEST_EQUAL(c[counters::arc_write_size], 0);
|
||||||
TEST_EQUAL(status.arc_volatile_size, 0);
|
TEST_EQUAL(c[counters::arc_volatile_size], 0);
|
||||||
|
|
||||||
tailqueue jobs;
|
tailqueue jobs;
|
||||||
// this should make it not be evicted
|
// this should make it not be evicted
|
||||||
|
@ -265,32 +272,30 @@ void test_evict()
|
||||||
++pe->piece_refcount;
|
++pe->piece_refcount;
|
||||||
bc.evict_piece(pe, jobs);
|
bc.evict_piece(pe, jobs);
|
||||||
|
|
||||||
bc.get_stats(&status);
|
bc.update_stats_counters(c);
|
||||||
TEST_EQUAL(status.blocks_read_hit, 0);
|
TEST_EQUAL(c[counters::write_cache_blocks], 0);
|
||||||
TEST_EQUAL(status.write_cache_size, 0);
|
TEST_EQUAL(c[counters::read_cache_blocks], 0);
|
||||||
TEST_EQUAL(status.read_cache_size, 0);
|
TEST_EQUAL(c[counters::pinned_blocks], 0);
|
||||||
TEST_EQUAL(status.pinned_blocks, 0);
|
TEST_EQUAL(c[counters::arc_mru_size], 1);
|
||||||
TEST_EQUAL(status.arc_mru_size, 1);
|
TEST_EQUAL(c[counters::arc_mru_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_mru_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_write_size], 0);
|
||||||
TEST_EQUAL(status.arc_write_size, 0);
|
TEST_EQUAL(c[counters::arc_volatile_size], 0);
|
||||||
TEST_EQUAL(status.arc_volatile_size, 0);
|
|
||||||
|
|
||||||
--pe->piece_refcount;
|
--pe->piece_refcount;
|
||||||
bc.evict_piece(pe, jobs);
|
bc.evict_piece(pe, jobs);
|
||||||
|
|
||||||
bc.get_stats(&status);
|
bc.update_stats_counters(c);
|
||||||
TEST_EQUAL(status.blocks_read_hit, 0);
|
TEST_EQUAL(c[counters::write_cache_blocks], 0);
|
||||||
TEST_EQUAL(status.write_cache_size, 0);
|
TEST_EQUAL(c[counters::read_cache_blocks], 0);
|
||||||
TEST_EQUAL(status.read_cache_size, 0);
|
TEST_EQUAL(c[counters::pinned_blocks], 0);
|
||||||
TEST_EQUAL(status.pinned_blocks, 0);
|
TEST_EQUAL(c[counters::arc_mru_size], 0);
|
||||||
TEST_EQUAL(status.arc_mru_size, 0);
|
TEST_EQUAL(c[counters::arc_mru_ghost_size], 1);
|
||||||
TEST_EQUAL(status.arc_mru_ghost_size, 1);
|
TEST_EQUAL(c[counters::arc_mfu_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_write_size], 0);
|
||||||
TEST_EQUAL(status.arc_write_size, 0);
|
TEST_EQUAL(c[counters::arc_volatile_size], 0);
|
||||||
TEST_EQUAL(status.arc_volatile_size, 0);
|
|
||||||
|
|
||||||
bc.clear(jobs);
|
bc.clear(jobs);
|
||||||
}
|
}
|
||||||
|
@ -303,53 +308,59 @@ void test_arc_promote()
|
||||||
|
|
||||||
INSERT(0, 0);
|
INSERT(0, 0);
|
||||||
|
|
||||||
bc.get_stats(&status);
|
counters c;
|
||||||
TEST_EQUAL(status.blocks_read_hit, 0);
|
bc.update_stats_counters(c);
|
||||||
TEST_EQUAL(status.write_cache_size, 0);
|
TEST_EQUAL(c[counters::write_cache_blocks], 0);
|
||||||
TEST_EQUAL(status.read_cache_size, 1);
|
TEST_EQUAL(c[counters::read_cache_blocks], 1);
|
||||||
TEST_EQUAL(status.pinned_blocks, 0);
|
TEST_EQUAL(c[counters::pinned_blocks], 0);
|
||||||
TEST_EQUAL(status.arc_mru_size, 1);
|
TEST_EQUAL(c[counters::arc_mru_size], 1);
|
||||||
TEST_EQUAL(status.arc_mru_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mru_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_write_size, 0);
|
TEST_EQUAL(c[counters::arc_write_size], 0);
|
||||||
TEST_EQUAL(status.arc_volatile_size, 0);
|
TEST_EQUAL(c[counters::arc_volatile_size], 0);
|
||||||
|
|
||||||
READ_BLOCK(0, 0, 1);
|
READ_BLOCK(0, 0, 1);
|
||||||
TEST_EQUAL(bc.pinned_blocks(), 1);
|
TEST_EQUAL(bc.pinned_blocks(), 1);
|
||||||
|
bc.update_stats_counters(c);
|
||||||
|
TEST_EQUAL(c[counters::pinned_blocks], 1);
|
||||||
|
|
||||||
// it's supposed to be a cache hit
|
// it's supposed to be a cache hit
|
||||||
TEST_CHECK(ret >= 0);
|
TEST_CHECK(ret >= 0);
|
||||||
// return the reference to the buffer we just read
|
// return the reference to the buffer we just read
|
||||||
RETURN_BUFFER;
|
RETURN_BUFFER;
|
||||||
|
|
||||||
bc.get_stats(&status);
|
bc.update_stats_counters(c);
|
||||||
TEST_EQUAL(status.write_cache_size, 0);
|
TEST_EQUAL(c[counters::write_cache_blocks], 0);
|
||||||
TEST_EQUAL(status.read_cache_size, 1);
|
TEST_EQUAL(c[counters::read_cache_blocks], 1);
|
||||||
TEST_EQUAL(status.pinned_blocks, 0);
|
TEST_EQUAL(c[counters::pinned_blocks], 0);
|
||||||
TEST_EQUAL(status.arc_mru_size, 1);
|
TEST_EQUAL(c[counters::arc_mru_size], 1);
|
||||||
TEST_EQUAL(status.arc_mru_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mru_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_write_size, 0);
|
TEST_EQUAL(c[counters::arc_write_size], 0);
|
||||||
TEST_EQUAL(status.arc_volatile_size, 0);
|
TEST_EQUAL(c[counters::arc_volatile_size], 0);
|
||||||
|
|
||||||
READ_BLOCK(0, 0, 2);
|
READ_BLOCK(0, 0, 2);
|
||||||
TEST_EQUAL(bc.pinned_blocks(), 1);
|
TEST_EQUAL(bc.pinned_blocks(), 1);
|
||||||
|
bc.update_stats_counters(c);
|
||||||
|
TEST_EQUAL(c[counters::pinned_blocks], 1);
|
||||||
|
|
||||||
// it's supposed to be a cache hit
|
// it's supposed to be a cache hit
|
||||||
TEST_CHECK(ret >= 0);
|
TEST_CHECK(ret >= 0);
|
||||||
// return the reference to the buffer we just read
|
// return the reference to the buffer we just read
|
||||||
RETURN_BUFFER;
|
RETURN_BUFFER;
|
||||||
|
|
||||||
bc.get_stats(&status);
|
bc.update_stats_counters(c);
|
||||||
TEST_EQUAL(status.write_cache_size, 0);
|
TEST_EQUAL(c[counters::write_cache_blocks], 0);
|
||||||
TEST_EQUAL(status.read_cache_size, 1);
|
TEST_EQUAL(c[counters::read_cache_blocks], 1);
|
||||||
TEST_EQUAL(status.pinned_blocks, 0);
|
TEST_EQUAL(c[counters::pinned_blocks], 0);
|
||||||
TEST_EQUAL(status.arc_mru_size, 0);
|
TEST_EQUAL(c[counters::arc_mru_size], 0);
|
||||||
TEST_EQUAL(status.arc_mru_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mru_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_size, 1);
|
TEST_EQUAL(c[counters::arc_mfu_size], 1);
|
||||||
TEST_EQUAL(status.arc_mfu_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_write_size, 0);
|
TEST_EQUAL(c[counters::arc_write_size], 0);
|
||||||
TEST_EQUAL(status.arc_volatile_size, 0);
|
TEST_EQUAL(c[counters::arc_volatile_size], 0);
|
||||||
|
|
||||||
tailqueue jobs;
|
tailqueue jobs;
|
||||||
bc.clear(jobs);
|
bc.clear(jobs);
|
||||||
|
@ -361,47 +372,48 @@ void test_arc_unghost()
|
||||||
|
|
||||||
INSERT(0, 0);
|
INSERT(0, 0);
|
||||||
|
|
||||||
bc.get_stats(&status);
|
counters c;
|
||||||
TEST_EQUAL(status.write_cache_size, 0);
|
bc.update_stats_counters(c);
|
||||||
TEST_EQUAL(status.read_cache_size, 1);
|
TEST_EQUAL(c[counters::write_cache_blocks], 0);
|
||||||
TEST_EQUAL(status.pinned_blocks, 0);
|
TEST_EQUAL(c[counters::read_cache_blocks], 1);
|
||||||
TEST_EQUAL(status.arc_mru_size, 1);
|
TEST_EQUAL(c[counters::pinned_blocks], 0);
|
||||||
TEST_EQUAL(status.arc_mru_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mru_size], 1);
|
||||||
TEST_EQUAL(status.arc_mfu_size, 0);
|
TEST_EQUAL(c[counters::arc_mru_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_size], 0);
|
||||||
TEST_EQUAL(status.arc_write_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_volatile_size, 0);
|
TEST_EQUAL(c[counters::arc_write_size], 0);
|
||||||
|
TEST_EQUAL(c[counters::arc_volatile_size], 0);
|
||||||
|
|
||||||
tailqueue jobs;
|
tailqueue jobs;
|
||||||
bc.evict_piece(pe, jobs);
|
bc.evict_piece(pe, jobs);
|
||||||
|
|
||||||
bc.get_stats(&status);
|
bc.update_stats_counters(c);
|
||||||
TEST_EQUAL(status.write_cache_size, 0);
|
TEST_EQUAL(c[counters::write_cache_blocks], 0);
|
||||||
TEST_EQUAL(status.read_cache_size, 0);
|
TEST_EQUAL(c[counters::read_cache_blocks], 0);
|
||||||
TEST_EQUAL(status.pinned_blocks, 0);
|
TEST_EQUAL(c[counters::pinned_blocks], 0);
|
||||||
TEST_EQUAL(status.arc_mru_size, 0);
|
TEST_EQUAL(c[counters::arc_mru_size], 0);
|
||||||
TEST_EQUAL(status.arc_mru_ghost_size, 1);
|
TEST_EQUAL(c[counters::arc_mru_ghost_size], 1);
|
||||||
TEST_EQUAL(status.arc_mfu_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_write_size, 0);
|
TEST_EQUAL(c[counters::arc_write_size], 0);
|
||||||
TEST_EQUAL(status.arc_volatile_size, 0);
|
TEST_EQUAL(c[counters::arc_volatile_size], 0);
|
||||||
|
|
||||||
// the block is now a ghost. If we cache-hit it,
|
// the block is now a ghost. If we cache-hit it,
|
||||||
// it should be promoted back to the main list
|
// it should be promoted back to the main list
|
||||||
bc.cache_hit(pe, (void*)1, false);
|
bc.cache_hit(pe, (void*)1, false);
|
||||||
|
|
||||||
bc.get_stats(&status);
|
bc.update_stats_counters(c);
|
||||||
TEST_EQUAL(status.write_cache_size, 0);
|
TEST_EQUAL(c[counters::write_cache_blocks], 0);
|
||||||
// we didn't actually read in any blocks, so the cache size
|
// we didn't actually read in any blocks, so the cache size
|
||||||
// is still 0
|
// is still 0
|
||||||
TEST_EQUAL(status.read_cache_size, 0);
|
TEST_EQUAL(c[counters::read_cache_blocks], 0);
|
||||||
TEST_EQUAL(status.pinned_blocks, 0);
|
TEST_EQUAL(c[counters::pinned_blocks], 0);
|
||||||
TEST_EQUAL(status.arc_mru_size, 1);
|
TEST_EQUAL(c[counters::arc_mru_size], 1);
|
||||||
TEST_EQUAL(status.arc_mru_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mru_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_size], 0);
|
||||||
TEST_EQUAL(status.arc_mfu_ghost_size, 0);
|
TEST_EQUAL(c[counters::arc_mfu_ghost_size], 0);
|
||||||
TEST_EQUAL(status.arc_write_size, 0);
|
TEST_EQUAL(c[counters::arc_write_size], 0);
|
||||||
TEST_EQUAL(status.arc_volatile_size, 0);
|
TEST_EQUAL(c[counters::arc_volatile_size], 0);
|
||||||
|
|
||||||
bc.clear(jobs);
|
bc.clear(jobs);
|
||||||
}
|
}
|
||||||
|
@ -433,6 +445,10 @@ void test_unaligned_read()
|
||||||
// unaligned reads copies the data into a new buffer
|
// unaligned reads copies the data into a new buffer
|
||||||
// rather than
|
// rather than
|
||||||
TEST_EQUAL(bc.pinned_blocks(), 0);
|
TEST_EQUAL(bc.pinned_blocks(), 0);
|
||||||
|
counters c;
|
||||||
|
bc.update_stats_counters(c);
|
||||||
|
TEST_EQUAL(c[counters::pinned_blocks], 0);
|
||||||
|
|
||||||
// it's supposed to be a cache hit
|
// it's supposed to be a cache hit
|
||||||
TEST_CHECK(ret >= 0);
|
TEST_CHECK(ret >= 0);
|
||||||
// return the reference to the buffer we just read
|
// return the reference to the buffer we just read
|
||||||
|
|
|
@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
|
||||||
const int proxy = libtorrent::proxy_settings::none;
|
const int proxy = libtorrent::settings_pack::none;
|
||||||
|
|
||||||
//static unsigned char random_byte()
|
//static unsigned char random_byte()
|
||||||
//{ return std::rand() & 0xff; }
|
//{ return std::rand() & 0xff; }
|
||||||
|
@ -92,10 +92,10 @@ int test_main()
|
||||||
|
|
||||||
{
|
{
|
||||||
libtorrent::session ses(fingerprint(" ", 0,0,0,0), 0);
|
libtorrent::session ses(fingerprint(" ", 0,0,0,0), 0);
|
||||||
session_settings settings;
|
settings_pack settings;
|
||||||
settings.max_queued_disk_bytes = 256 * 1024;
|
settings.set_int(settings_pack::max_queued_disk_bytes, 256 * 1024);
|
||||||
ses.set_settings(settings);
|
settings.set_int(settings_pack::alert_mask, ~(alert::progress_notification | alert::stats_notification));
|
||||||
ses.set_alert_mask(~(alert::progress_notification | alert::stats_notification));
|
ses.apply_settings(settings);
|
||||||
|
|
||||||
// disable keep-alive because otherwise the test will choke on seeing
|
// disable keep-alive because otherwise the test will choke on seeing
|
||||||
// the disconnect (from the redirect)
|
// the disconnect (from the redirect)
|
||||||
|
|
|
@ -154,8 +154,6 @@ void test_transfer(lt::session& ses, boost::shared_ptr<torrent_info> torrent_fil
|
||||||
float rate_sum = 0.f;
|
float rate_sum = 0.f;
|
||||||
float ses_rate_sum = 0.f;
|
float ses_rate_sum = 0.f;
|
||||||
|
|
||||||
cache_status cs;
|
|
||||||
|
|
||||||
file_storage const& fs = torrent_file->files();
|
file_storage const& fs = torrent_file->files();
|
||||||
int pad_file_size = 0;
|
int pad_file_size = 0;
|
||||||
for (int i = 0; i < fs.num_files(); ++i)
|
for (int i = 0; i < fs.num_files(); ++i)
|
||||||
|
@ -173,10 +171,6 @@ void test_transfer(lt::session& ses, boost::shared_ptr<torrent_info> torrent_fil
|
||||||
rate_sum += s.download_payload_rate;
|
rate_sum += s.download_payload_rate;
|
||||||
ses_rate_sum += ss.payload_download_rate;
|
ses_rate_sum += ss.payload_download_rate;
|
||||||
|
|
||||||
ses.get_cache_info(&cs);
|
|
||||||
if (cs.blocks_read < 1) cs.blocks_read = 1;
|
|
||||||
if (cs.blocks_written < 1) cs.blocks_written = 1;
|
|
||||||
|
|
||||||
print_ses_rate(i / 10.f, &s, NULL);
|
print_ses_rate(i / 10.f, &s, NULL);
|
||||||
|
|
||||||
print_alerts(ses, " >> ses", test_ban, false, false, &on_alert);
|
print_alerts(ses, " >> ses", test_ban, false, false, &on_alert);
|
||||||
|
@ -215,6 +209,9 @@ void test_transfer(lt::session& ses, boost::shared_ptr<torrent_info> torrent_fil
|
||||||
// the url seed (i.e. banned it)
|
// the url seed (i.e. banned it)
|
||||||
TEST_CHECK(!test_ban || (th.url_seeds().empty() && th.http_seeds().empty()));
|
TEST_CHECK(!test_ban || (th.url_seeds().empty() && th.http_seeds().empty()));
|
||||||
|
|
||||||
|
cache_status cs;
|
||||||
|
ses.get_cache_info(&cs);
|
||||||
|
|
||||||
// if the web seed senr corrupt data and we banned it, we probably didn't
|
// if the web seed senr corrupt data and we banned it, we probably didn't
|
||||||
// end up using all the cache anyway
|
// end up using all the cache anyway
|
||||||
if (!test_ban)
|
if (!test_ban)
|
||||||
|
|
Loading…
Reference in New Issue