forked from premiere/premiere-libtorrent
improve some tests
This commit is contained in:
parent
99c0542289
commit
db76ba759d
|
@ -242,7 +242,7 @@ namespace libtorrent
|
|||
// piece, and returned it. This is set to one
|
||||
boost::uint32_t hashing_done:1;
|
||||
|
||||
// if this is true, whenever refcount hits 0,
|
||||
// if this is true, whenever refcount hits 0,
|
||||
// this piece should be deleted
|
||||
boost::uint32_t marked_for_deletion:1;
|
||||
|
||||
|
@ -309,10 +309,10 @@ namespace libtorrent
|
|||
// the number of blocks that have >= 1 refcount
|
||||
boost::uint32_t pinned:16;
|
||||
|
||||
// ---- 32 bit boundary ---
|
||||
// ---- 32 bit boundary ---
|
||||
|
||||
// the sum of all refcounts in all blocks
|
||||
boost::uint32_t refcount;
|
||||
boost::uint32_t refcount;
|
||||
|
||||
#if TORRENT_USE_ASSERTS
|
||||
// the number of times this piece has finished hashing
|
||||
|
|
|
@ -69,7 +69,7 @@ void test_swarm(int flags)
|
|||
session_proxy p2;
|
||||
session_proxy p3;
|
||||
|
||||
int mask = alert::all_categories
|
||||
const int mask = alert::all_categories
|
||||
& ~(alert::progress_notification
|
||||
| alert::performance_warning
|
||||
| alert::stats_notification);
|
||||
|
|
|
@ -171,8 +171,17 @@ void test_checking(int flags = read_only_files)
|
|||
}
|
||||
}
|
||||
|
||||
int mask = alert::all_categories
|
||||
& ~(alert::progress_notification
|
||||
| alert::performance_warning
|
||||
| alert::stats_notification);
|
||||
|
||||
settings_pack pack;
|
||||
pack.set_int(settings_pack::alert_mask, alert::all_categories);
|
||||
pack.set_bool(settings_pack::enable_lsd, false);
|
||||
pack.set_bool(settings_pack::enable_natpmp, false);
|
||||
pack.set_bool(settings_pack::enable_upnp, false);
|
||||
pack.set_bool(settings_pack::enable_dht, false);
|
||||
pack.set_int(settings_pack::alert_mask, mask);
|
||||
pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48000");
|
||||
pack.set_int(settings_pack::max_retry_port_bind, 1000);
|
||||
lt::session ses1(pack);
|
||||
|
@ -184,7 +193,7 @@ void test_checking(int flags = read_only_files)
|
|||
TEST_CHECK(!ec);
|
||||
|
||||
torrent_status st;
|
||||
for (int i = 0; i < 5; ++i)
|
||||
for (int i = 0; i < 20; ++i)
|
||||
{
|
||||
print_alerts(ses1, "ses1");
|
||||
|
||||
|
@ -201,7 +210,7 @@ void test_checking(int flags = read_only_files)
|
|||
break;
|
||||
|
||||
if (!st.error.empty()) break;
|
||||
test_sleep(1000);
|
||||
test_sleep(500);
|
||||
}
|
||||
if (flags & incomplete_files)
|
||||
{
|
||||
|
@ -227,7 +236,7 @@ void test_checking(int flags = read_only_files)
|
|||
|
||||
// wait a while to make sure libtorrent survived the error
|
||||
test_sleep(1000);
|
||||
|
||||
|
||||
st = tor1.status();
|
||||
TEST_CHECK(!st.is_seeding);
|
||||
TEST_CHECK(!st.error.empty());
|
||||
|
@ -278,9 +287,25 @@ void test_checking(int flags = read_only_files)
|
|||
TORRENT_TEST(checking)
|
||||
{
|
||||
test_checking();
|
||||
}
|
||||
|
||||
TORRENT_TEST(read_only_corrupt)
|
||||
{
|
||||
test_checking(read_only_files | corrupt_files);
|
||||
}
|
||||
|
||||
TORRENT_TEST(read_only)
|
||||
{
|
||||
test_checking(read_only_files);
|
||||
}
|
||||
|
||||
TORRENT_TEST(incomplete)
|
||||
{
|
||||
test_checking(incomplete_files);
|
||||
}
|
||||
|
||||
TORRENT_TEST(corrupt)
|
||||
{
|
||||
test_checking(corrupt_files);
|
||||
}
|
||||
|
||||
|
|
|
@ -81,8 +81,8 @@ int read_message(tcp::socket& s, char* buffer, int max_size)
|
|||
, boost::asio::transfer_all(), ec);
|
||||
if (ec)
|
||||
{
|
||||
if (ec) TEST_ERROR(ec.message());
|
||||
return 0;
|
||||
TEST_ERROR(ec.message());
|
||||
return -1;
|
||||
}
|
||||
char* ptr = buffer;
|
||||
int length = read_int32(ptr);
|
||||
|
@ -97,8 +97,8 @@ int read_message(tcp::socket& s, char* buffer, int max_size)
|
|||
, boost::asio::transfer_all(), ec);
|
||||
if (ec)
|
||||
{
|
||||
if (ec) TEST_ERROR(ec.message());
|
||||
return 0;
|
||||
TEST_ERROR(ec.message());
|
||||
return -1;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
@ -454,6 +454,7 @@ TORRENT_TEST(reject_fast)
|
|||
{
|
||||
print_session_log(*ses);
|
||||
int len = read_message(s, recv_buffer, sizeof(recv_buffer));
|
||||
if (len == -1) break;
|
||||
print_message(recv_buffer, len);
|
||||
int msg = recv_buffer[0];
|
||||
if (msg != 0x6) continue;
|
||||
|
@ -529,6 +530,7 @@ TORRENT_TEST(reject_suggest)
|
|||
{
|
||||
print_session_log(*ses);
|
||||
int len = read_message(s, recv_buffer, sizeof(recv_buffer));
|
||||
if (len == -1) break;
|
||||
print_message(recv_buffer, len);
|
||||
int msg = recv_buffer[0];
|
||||
fail_counter--;
|
||||
|
@ -673,6 +675,7 @@ TORRENT_TEST(dont_have)
|
|||
print_session_log(*ses);
|
||||
|
||||
int len = read_message(s, recv_buffer, sizeof(recv_buffer));
|
||||
if (len == -1) break;
|
||||
print_message(recv_buffer, len);
|
||||
if (len == 0) continue;
|
||||
int msg = recv_buffer[0];
|
||||
|
@ -792,3 +795,6 @@ TORRENT_TEST(invalid_metadata_request)
|
|||
print_session_log(*ses);
|
||||
}
|
||||
|
||||
// TODO: test sending invalid requests (out of bound piece index, offsets and
|
||||
// sizes)
|
||||
|
||||
|
|
|
@ -87,7 +87,17 @@ void test_read_piece(int flags)
|
|||
fprintf(stderr, "generated torrent: %s tmp1_read_piece/test_torrent\n"
|
||||
, to_hex(ti->info_hash().to_string()).c_str());
|
||||
|
||||
const int mask = alert::all_categories
|
||||
& ~(alert::progress_notification
|
||||
| alert::performance_warning
|
||||
| alert::stats_notification);
|
||||
|
||||
settings_pack sett;
|
||||
sett.set_bool(settings_pack::enable_lsd, false);
|
||||
sett.set_bool(settings_pack::enable_natpmp, false);
|
||||
sett.set_bool(settings_pack::enable_upnp, false);
|
||||
sett.set_bool(settings_pack::enable_dht, false);
|
||||
sett.set_int(settings_pack::alert_mask, mask);
|
||||
sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:48000");
|
||||
sett.set_int(settings_pack::alert_mask, alert::all_categories);
|
||||
lt::session ses(sett);
|
||||
|
@ -138,7 +148,15 @@ void test_read_piece(int flags)
|
|||
TORRENT_TEST(read_piece)
|
||||
{
|
||||
test_read_piece(0);
|
||||
}
|
||||
|
||||
TORRENT_TEST(seed_mode)
|
||||
{
|
||||
test_read_piece(seed_mode);
|
||||
}
|
||||
|
||||
TORRENT_TEST(time_critical)
|
||||
{
|
||||
test_read_piece(time_critical);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
||||
char const* time_now_string()
|
||||
{
|
||||
static const time_point start = clock_type::now();
|
||||
|
|
Loading…
Reference in New Issue