fixing warnings in tests code, part2 (#2718)
This commit is contained in:
parent
abbbcf52c1
commit
7262118177
|
@ -45,6 +45,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace lt;
|
using namespace lt;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
struct test_storage_impl : storage_interface
|
struct test_storage_impl : storage_interface
|
||||||
{
|
{
|
||||||
explicit test_storage_impl(file_storage const& fs) : storage_interface(fs) {}
|
explicit test_storage_impl(file_storage const& fs) : storage_interface(fs) {}
|
||||||
|
@ -463,6 +465,8 @@ void test_unaligned_read()
|
||||||
bc.clear(jobs);
|
bc.clear(jobs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
TORRENT_TEST(block_cache)
|
TORRENT_TEST(block_cache)
|
||||||
{
|
{
|
||||||
test_write();
|
test_write();
|
||||||
|
|
|
@ -54,6 +54,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
using namespace lt;
|
using namespace lt;
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
void log(char const* fmt, ...)
|
void log(char const* fmt, ...)
|
||||||
{
|
{
|
||||||
va_list v;
|
va_list v;
|
||||||
|
@ -469,6 +471,8 @@ std::shared_ptr<torrent_info> setup_peer(tcp::socket& s, sha1_hash& ih
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
// makes sure that pieces that are allowed and then
|
// makes sure that pieces that are allowed and then
|
||||||
// rejected aren't requested again
|
// rejected aren't requested again
|
||||||
TORRENT_TEST(reject_fast)
|
TORRENT_TEST(reject_fast)
|
||||||
|
|
|
@ -42,6 +42,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace lt;
|
using namespace lt;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
bool cast_vote(ip_voter& ipv, address ext_ip, address voter)
|
bool cast_vote(ip_voter& ipv, address ext_ip, address voter)
|
||||||
{
|
{
|
||||||
bool new_ip = ipv.cast_vote(ext_ip, aux::session_interface::source_dht, voter);
|
bool new_ip = ipv.cast_vote(ext_ip, aux::session_interface::source_dht, voter);
|
||||||
|
@ -56,6 +58,8 @@ bool cast_vote(ip_voter& ipv, address ext_ip, address voter)
|
||||||
return new_ip;
|
return new_ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
// test the case where every time we get a new IP. Make sure
|
// test the case where every time we get a new IP. Make sure
|
||||||
// we don't flap
|
// we don't flap
|
||||||
TORRENT_TEST(test_random)
|
TORRENT_TEST(test_random)
|
||||||
|
|
|
@ -41,6 +41,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "setup_transfer.hpp"
|
#include "setup_transfer.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
void test_lsd()
|
void test_lsd()
|
||||||
{
|
{
|
||||||
using namespace lt;
|
using namespace lt;
|
||||||
|
@ -97,6 +99,8 @@ void test_lsd()
|
||||||
p2 = ses2.abort();
|
p2 = ses2.abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
TORRENT_TEST(lsd)
|
TORRENT_TEST(lsd)
|
||||||
{
|
{
|
||||||
using namespace lt;
|
using namespace lt;
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace {
|
||||||
|
|
||||||
bool all_of(std::vector<bool> const& v)
|
bool all_of(std::vector<bool> const& v)
|
||||||
{
|
{
|
||||||
return std::all_of(v.begin(), v.end(), [](bool v){ return v; });
|
return std::all_of(v.begin(), v.end(), [](bool val){ return val; });
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_remap_files(storage_mode_t storage_mode = storage_mode_sparse)
|
void test_remap_files(storage_mode_t storage_mode = storage_mode_sparse)
|
||||||
|
@ -109,9 +109,9 @@ void test_remap_files(storage_mode_t storage_mode = storage_mode_sparse)
|
||||||
|
|
||||||
// wait for all alerts to come back and verify the data against the expected
|
// wait for all alerts to come back and verify the data against the expected
|
||||||
// piece data
|
// piece data
|
||||||
aux::vector<bool, piece_index_t> pieces(fs.num_pieces(), false);
|
aux::vector<bool, piece_index_t> pieces(std::size_t(fs.num_pieces()), false);
|
||||||
aux::vector<bool, piece_index_t> passed(fs.num_pieces(), false);
|
aux::vector<bool, piece_index_t> passed(std::size_t(fs.num_pieces()), false);
|
||||||
aux::vector<bool, file_index_t> files(fs.num_files(), false);
|
aux::vector<bool, file_index_t> files(std::size_t(fs.num_files()), false);
|
||||||
|
|
||||||
while (!all_of(pieces) || !all_of(passed) || !all_of(files))
|
while (!all_of(pieces) || !all_of(passed) || !all_of(files))
|
||||||
{
|
{
|
||||||
|
@ -132,7 +132,7 @@ void test_remap_files(storage_mode_t storage_mode = storage_mode_sparse)
|
||||||
TEST_EQUAL(t->piece_size(idx), rp->size);
|
TEST_EQUAL(t->piece_size(idx), rp->size);
|
||||||
|
|
||||||
std::vector<char> const piece = generate_piece(idx, t->piece_size(idx));
|
std::vector<char> const piece = generate_piece(idx, t->piece_size(idx));
|
||||||
TEST_CHECK(memcmp(rp->buffer.get(), piece.data(), rp->size) == 0);
|
TEST_CHECK(std::memcmp(rp->buffer.get(), piece.data(), std::size_t(rp->size)) == 0);
|
||||||
TEST_CHECK(pieces[idx] == false);
|
TEST_CHECK(pieces[idx] == false);
|
||||||
pieces[idx] = true;
|
pieces[idx] = true;
|
||||||
}
|
}
|
||||||
|
@ -187,8 +187,8 @@ void test_remap_files(storage_mode_t storage_mode = storage_mode_sparse)
|
||||||
|
|
||||||
for (int i = 0; i < 50; ++i)
|
for (int i = 0; i < 50; ++i)
|
||||||
{
|
{
|
||||||
torrent_status st = tor1.status();
|
torrent_status st1 = tor1.status();
|
||||||
if (st.is_seeding) break;
|
if (st1.is_seeding) break;
|
||||||
std::this_thread::sleep_for(lt::milliseconds(100));
|
std::this_thread::sleep_for(lt::milliseconds(100));
|
||||||
print_alerts(ses, "ses");
|
print_alerts(ses, "ses");
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,8 @@ using namespace libtorrent;
|
||||||
namespace lt = libtorrent;
|
namespace lt = libtorrent;
|
||||||
using std::ignore;
|
using std::ignore;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
enum test_case {
|
enum test_case {
|
||||||
complete_download,
|
complete_download,
|
||||||
partial_download,
|
partial_download,
|
||||||
|
@ -167,6 +169,8 @@ void test_remove_torrent(remove_flags_t const remove_options
|
||||||
sp.push_back(ses2.abort());
|
sp.push_back(ses2.abort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
TORRENT_TEST(remove_torrent)
|
TORRENT_TEST(remove_torrent)
|
||||||
{
|
{
|
||||||
test_remove_torrent({});
|
test_remove_torrent({});
|
||||||
|
|
|
@ -119,15 +119,15 @@ TORRENT_TEST(resolve_links)
|
||||||
if (num_matches > e.expected_matches)
|
if (num_matches > e.expected_matches)
|
||||||
{
|
{
|
||||||
file_storage const& fs = ti1->files();
|
file_storage const& fs = ti1->files();
|
||||||
for (file_index_t i{0}; i != links.end_index(); ++i)
|
for (file_index_t idx{0}; idx != links.end_index(); ++idx)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(i < file_index_t{fs.num_files()});
|
TORRENT_ASSERT(idx < file_index_t{fs.num_files()});
|
||||||
std::printf("%*s --> %s : %d\n"
|
std::printf("%*s --> %s : %d\n"
|
||||||
, int(fs.file_name(i).size())
|
, int(fs.file_name(idx).size())
|
||||||
, fs.file_name(i).data()
|
, fs.file_name(idx).data()
|
||||||
, links[i].ti
|
, links[idx].ti
|
||||||
? aux::to_hex(links[i].ti->info_hash()).c_str()
|
? aux::to_hex(links[idx].ti->info_hash()).c_str()
|
||||||
: "", static_cast<int>(links[i].file_idx));
|
: "", static_cast<int>(links[idx].file_idx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace lt;
|
using namespace lt;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
torrent_flags_t const flags_mask
|
torrent_flags_t const flags_mask
|
||||||
= torrent_flags::sequential_download
|
= torrent_flags::sequential_download
|
||||||
| torrent_flags::paused
|
| torrent_flags::paused
|
||||||
|
@ -77,7 +79,7 @@ std::shared_ptr<torrent_info> generate_torrent()
|
||||||
for (piece_index_t i(0); i < fs.end_piece(); ++i)
|
for (piece_index_t i(0); i < fs.end_piece(); ++i)
|
||||||
{
|
{
|
||||||
sha1_hash ph;
|
sha1_hash ph;
|
||||||
for (int k = 0; k < 20; ++k) ph[k] = lt::random(0xff);
|
aux::random_bytes(ph);
|
||||||
t.set_hash(i, ph);
|
t.set_hash(i, ph);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,8 +96,8 @@ std::vector<char> generate_resume_data(torrent_info* ti
|
||||||
rd["file-format"] = "libtorrent resume file";
|
rd["file-format"] = "libtorrent resume file";
|
||||||
rd["file-version"] = 1;
|
rd["file-version"] = 1;
|
||||||
rd["info-hash"] = ti->info_hash().to_string();
|
rd["info-hash"] = ti->info_hash().to_string();
|
||||||
rd["blocks per piece"] = (std::max)(1, ti->piece_length() / 0x4000);
|
rd["blocks per piece"] = std::max(1, ti->piece_length() / 0x4000);
|
||||||
rd["pieces"] = std::string(ti->num_pieces(), '\x01');
|
rd["pieces"] = std::string(std::size_t(ti->num_pieces()), '\x01');
|
||||||
|
|
||||||
rd["total_uploaded"] = 1337;
|
rd["total_uploaded"] = 1337;
|
||||||
rd["total_downloaded"] = 1338;
|
rd["total_downloaded"] = 1338;
|
||||||
|
@ -117,7 +119,7 @@ std::vector<char> generate_resume_data(torrent_info* ti
|
||||||
file_prio.push_back(entry(file_priorities[i] - '0'));
|
file_prio.push_back(entry(file_priorities[i] - '0'));
|
||||||
}
|
}
|
||||||
|
|
||||||
rd["piece_priority"] = std::string(ti->num_pieces(), '\x01');
|
rd["piece_priority"] = std::string(std::size_t(ti->num_pieces()), '\x01');
|
||||||
rd["auto_managed"] = 0;
|
rd["auto_managed"] = 0;
|
||||||
rd["sequential_download"] = 0;
|
rd["sequential_download"] = 0;
|
||||||
rd["paused"] = 0;
|
rd["paused"] = 0;
|
||||||
|
@ -187,7 +189,7 @@ torrent_handle test_resume_flags(lt::session& ses
|
||||||
{
|
{
|
||||||
aux::vector<download_priority_t, file_index_t> priorities_vector;
|
aux::vector<download_priority_t, file_index_t> priorities_vector;
|
||||||
for (int i = 0; file_priorities[i]; ++i)
|
for (int i = 0; file_priorities[i]; ++i)
|
||||||
priorities_vector.push_back(download_priority_t(file_priorities[i] - '0'));
|
priorities_vector.push_back(download_priority_t(aux::numeric_cast<std::uint8_t>(file_priorities[i] - '0')));
|
||||||
|
|
||||||
p.file_priorities = priorities_vector;
|
p.file_priorities = priorities_vector;
|
||||||
}
|
}
|
||||||
|
@ -274,6 +276,8 @@ void test_piece_priorities(bool test_deprecated = false)
|
||||||
TEST_EQUAL(h.piece_priority(piece_index_t(ti->num_pieces()-1)), 0_pri);
|
TEST_EQUAL(h.piece_priority(piece_index_t(ti->num_pieces()-1)), 0_pri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
TORRENT_TEST(piece_priorities_deprecated)
|
TORRENT_TEST(piece_priorities_deprecated)
|
||||||
{
|
{
|
||||||
|
@ -296,9 +300,9 @@ TORRENT_TEST(piece_slots)
|
||||||
{
|
{
|
||||||
std::vector<char> a(128 * 1024 * 8);
|
std::vector<char> a(128 * 1024 * 8);
|
||||||
std::vector<char> b(128 * 1024);
|
std::vector<char> b(128 * 1024);
|
||||||
std::ofstream("add_torrent_params_test/test_resume/tmp1").write(a.data(), a.size());
|
std::ofstream("add_torrent_params_test/test_resume/tmp1").write(a.data(), std::streamsize(a.size()));
|
||||||
std::ofstream("add_torrent_params_test/test_resume/tmp2").write(b.data(), b.size());
|
std::ofstream("add_torrent_params_test/test_resume/tmp2").write(b.data(), std::streamsize(b.size()));
|
||||||
std::ofstream("add_torrent_params_test/test_resume/tmp3").write(b.data(), b.size());
|
std::ofstream("add_torrent_params_test/test_resume/tmp3").write(b.data(), std::streamsize(b.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
add_torrent_params p;
|
add_torrent_params p;
|
||||||
|
@ -353,9 +357,9 @@ void test_piece_slots_seed(settings_pack const& sett)
|
||||||
{
|
{
|
||||||
std::vector<char> a(128 * 1024 * 8);
|
std::vector<char> a(128 * 1024 * 8);
|
||||||
std::vector<char> b(128 * 1024);
|
std::vector<char> b(128 * 1024);
|
||||||
std::ofstream("add_torrent_params_test/test_resume/tmp1").write(a.data(), a.size());
|
std::ofstream("add_torrent_params_test/test_resume/tmp1").write(a.data(), std::streamsize(a.size()));
|
||||||
std::ofstream("add_torrent_params_test/test_resume/tmp2").write(b.data(), b.size());
|
std::ofstream("add_torrent_params_test/test_resume/tmp2").write(b.data(), std::streamsize(b.size()));
|
||||||
std::ofstream("add_torrent_params_test/test_resume/tmp3").write(b.data(), b.size());
|
std::ofstream("add_torrent_params_test/test_resume/tmp3").write(b.data(), std::streamsize(b.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
add_torrent_params p;
|
add_torrent_params p;
|
||||||
|
@ -838,10 +842,10 @@ void test_zero_file_prio(bool test_deprecated = false)
|
||||||
file_prio.push_back(entry(0));
|
file_prio.push_back(entry(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string pieces(ti->num_pieces(), '\x01');
|
std::string pieces(std::size_t(ti->num_pieces()), '\x01');
|
||||||
rd["pieces"] = pieces;
|
rd["pieces"] = pieces;
|
||||||
|
|
||||||
std::string pieces_prio(ti->num_pieces(), '\x01');
|
std::string pieces_prio(std::size_t(ti->num_pieces()), '\x01');
|
||||||
rd["piece_priority"] = pieces_prio;
|
rd["piece_priority"] = pieces_prio;
|
||||||
|
|
||||||
std::vector<char> resume_data;
|
std::vector<char> resume_data;
|
||||||
|
@ -968,14 +972,14 @@ void test_seed_mode(test_mode_t const flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string pieces(ti->num_pieces(), '\x01');
|
std::string pieces(std::size_t(ti->num_pieces()), '\x01');
|
||||||
if (flags & test_mode::pieces_have)
|
if (flags & test_mode::pieces_have)
|
||||||
{
|
{
|
||||||
pieces[0] = '\0';
|
pieces[0] = '\0';
|
||||||
}
|
}
|
||||||
rd["pieces"] = pieces;
|
rd["pieces"] = pieces;
|
||||||
|
|
||||||
std::string pieces_prio(ti->num_pieces(), '\x01');
|
std::string pieces_prio(std::size_t(ti->num_pieces()), '\x01');
|
||||||
if (flags & test_mode::piece_prio)
|
if (flags & test_mode::piece_prio)
|
||||||
{
|
{
|
||||||
pieces_prio[0] = '\0';
|
pieces_prio[0] = '\0';
|
||||||
|
|
|
@ -217,7 +217,7 @@ TORRENT_TEST(session_stats)
|
||||||
// make sure every stat index is represented in the stats_metric vector
|
// make sure every stat index is represented in the stats_metric vector
|
||||||
for (int i = 0; i < int(stats.size()); ++i)
|
for (int i = 0; i < int(stats.size()); ++i)
|
||||||
{
|
{
|
||||||
TEST_EQUAL(stats[i].value_index, i);
|
TEST_EQUAL(stats[std::size_t(i)].value_index, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_EQUAL(lt::find_metric_idx("peer.incoming_connections")
|
TEST_EQUAL(lt::find_metric_idx("peer.incoming_connections")
|
||||||
|
@ -468,7 +468,6 @@ auto const count_dht_inits = [](session& ses)
|
||||||
}
|
}
|
||||||
if (num <= 0) return count;
|
if (num <= 0) return count;
|
||||||
}
|
}
|
||||||
return count;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TORRENT_TEST(init_dht_default_bootstrap)
|
TORRENT_TEST(init_dht_default_bootstrap)
|
||||||
|
|
|
@ -58,23 +58,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
using namespace lt;
|
using namespace lt;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
std::size_t const piece_size = 16 * 1024 * 16;
|
std::size_t const piece_size = 16 * 1024 * 16;
|
||||||
std::size_t const half = piece_size / 2;
|
std::size_t const half = piece_size / 2;
|
||||||
|
|
||||||
void signal_bool(bool* b, char const* string)
|
|
||||||
{
|
|
||||||
*b = true;
|
|
||||||
std::cout << time_now_string() << " " << string << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void on_read_piece(int ret, disk_io_job const& j, char const* data, int size)
|
|
||||||
{
|
|
||||||
std::cout << time_now_string() << " on_read_piece piece: " << j.piece << std::endl;
|
|
||||||
TEST_EQUAL(ret, size);
|
|
||||||
auto& buffer = boost::get<disk_buffer_holder>(j.argument);
|
|
||||||
if (ret > 0) TEST_CHECK(std::equal(buffer.get(), buffer.get() + ret, data));
|
|
||||||
}
|
|
||||||
|
|
||||||
void on_check_resume_data(status_t const status, storage_error const& error, bool* done)
|
void on_check_resume_data(status_t const status, storage_error const& error, bool* done)
|
||||||
{
|
{
|
||||||
std::cout << time_now_string() << " on_check_resume_data ret: "
|
std::cout << time_now_string() << " on_check_resume_data ret: "
|
||||||
|
@ -746,6 +734,8 @@ void test_fastresume(bool const test_deprecated)
|
||||||
<< "': " << ec.message() << std::endl;
|
<< "': " << ec.message() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
TORRENT_TEST(fastresume)
|
TORRENT_TEST(fastresume)
|
||||||
{
|
{
|
||||||
test_fastresume(false);
|
test_fastresume(false);
|
||||||
|
|
|
@ -830,24 +830,24 @@ TORRENT_TEST(parse_torrents)
|
||||||
}
|
}
|
||||||
|
|
||||||
file_storage const& fs = ti->files();
|
file_storage const& fs = ti->files();
|
||||||
for (file_index_t i{0}; i != file_index_t(fs.num_files()); ++i)
|
for (file_index_t idx{0}; idx != file_index_t(fs.num_files()); ++idx)
|
||||||
{
|
{
|
||||||
piece_index_t const first = ti->map_file(i, 0, 0).piece;
|
piece_index_t const first = ti->map_file(idx, 0, 0).piece;
|
||||||
piece_index_t const last = ti->map_file(i, std::max(fs.file_size(i)-1, std::int64_t(0)), 0).piece;
|
piece_index_t const last = ti->map_file(idx, std::max(fs.file_size(idx)-1, std::int64_t(0)), 0).piece;
|
||||||
file_flags_t const flags = fs.file_flags(i);
|
file_flags_t const flags = fs.file_flags(idx);
|
||||||
sha1_hash const ih = fs.hash(i);
|
sha1_hash const ih = fs.hash(idx);
|
||||||
std::printf(" %11" PRId64 " %c%c%c%c [ %4d, %4d ] %7u %s %s %s%s\n"
|
std::printf(" %11" PRId64 " %c%c%c%c [ %4d, %4d ] %7u %s %s %s%s\n"
|
||||||
, fs.file_size(i)
|
, fs.file_size(idx)
|
||||||
, (flags & file_storage::flag_pad_file)?'p':'-'
|
, (flags & file_storage::flag_pad_file)?'p':'-'
|
||||||
, (flags & file_storage::flag_executable)?'x':'-'
|
, (flags & file_storage::flag_executable)?'x':'-'
|
||||||
, (flags & file_storage::flag_hidden)?'h':'-'
|
, (flags & file_storage::flag_hidden)?'h':'-'
|
||||||
, (flags & file_storage::flag_symlink)?'l':'-'
|
, (flags & file_storage::flag_symlink)?'l':'-'
|
||||||
, static_cast<int>(first), static_cast<int>(last)
|
, static_cast<int>(first), static_cast<int>(last)
|
||||||
, std::uint32_t(fs.mtime(i))
|
, std::uint32_t(fs.mtime(idx))
|
||||||
, ih != sha1_hash(nullptr) ? aux::to_hex(ih).c_str() : ""
|
, ih != sha1_hash(nullptr) ? aux::to_hex(ih).c_str() : ""
|
||||||
, fs.file_path(i).c_str()
|
, fs.file_path(idx).c_str()
|
||||||
, flags & file_storage::flag_symlink ? "-> ": ""
|
, flags & file_storage::flag_symlink ? "-> ": ""
|
||||||
, flags & file_storage::flag_symlink ? fs.symlink(i).c_str() : "");
|
, flags & file_storage::flag_symlink ? fs.symlink(idx).c_str() : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -911,7 +911,7 @@ void test_resolve_duplicates(int test_case)
|
||||||
|
|
||||||
torrent_info ti(tmp, from_span);
|
torrent_info ti(tmp, from_span);
|
||||||
|
|
||||||
std::vector<aux::vector<char const*, file_index_t>> const filenames
|
aux::vector<aux::vector<char const*, file_index_t>> const filenames
|
||||||
{
|
{
|
||||||
{ // case 0
|
{ // case 0
|
||||||
"test/temporary.txt",
|
"test/temporary.txt",
|
||||||
|
@ -1017,7 +1017,7 @@ TORRENT_TEST(copy)
|
||||||
// clear out the buffer for a, just to make sure b doesn't have any
|
// clear out the buffer for a, just to make sure b doesn't have any
|
||||||
// references into it by mistake
|
// references into it by mistake
|
||||||
int s = a->metadata_size();
|
int s = a->metadata_size();
|
||||||
std::memset(a->metadata().get(), 0, s);
|
std::memset(a->metadata().get(), 0, std::size_t(s));
|
||||||
|
|
||||||
a.reset();
|
a.reset();
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,8 @@ using namespace lt;
|
||||||
|
|
||||||
using std::ignore;
|
using std::ignore;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
auto const mask = alert::all_categories
|
auto const mask = alert::all_categories
|
||||||
& ~(alert::performance_warning | alert::stats_notification);
|
& ~(alert::performance_warning | alert::stats_notification);
|
||||||
|
|
||||||
|
@ -77,8 +79,8 @@ struct test_storage : default_storage
|
||||||
, m_limit(16 * 1024 * 2)
|
, m_limit(16 * 1024 * 2)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void set_file_priority(aux::vector<download_priority_t, file_index_t> const& p
|
void set_file_priority(aux::vector<download_priority_t, file_index_t> const&
|
||||||
, storage_error& ec) override {}
|
, storage_error&) override {}
|
||||||
|
|
||||||
void set_limit(int lim)
|
void set_limit(int lim)
|
||||||
{
|
{
|
||||||
|
@ -175,21 +177,21 @@ void test_transfer(int proxy_type, settings_pack const& sett
|
||||||
{
|
{
|
||||||
proxy_port = start_proxy(proxy_type);
|
proxy_port = start_proxy(proxy_type);
|
||||||
|
|
||||||
settings_pack pack;
|
settings_pack pack_p;
|
||||||
pack.set_str(settings_pack::proxy_username, "testuser");
|
pack_p.set_str(settings_pack::proxy_username, "testuser");
|
||||||
pack.set_str(settings_pack::proxy_password, "testpass");
|
pack_p.set_str(settings_pack::proxy_password, "testpass");
|
||||||
pack.set_int(settings_pack::proxy_type, proxy_type);
|
pack_p.set_int(settings_pack::proxy_type, proxy_type);
|
||||||
pack.set_int(settings_pack::proxy_port, proxy_port);
|
pack_p.set_int(settings_pack::proxy_port, proxy_port);
|
||||||
pack.set_bool(settings_pack::force_proxy, true);
|
pack_p.set_bool(settings_pack::force_proxy, true);
|
||||||
|
|
||||||
// test resetting the proxy in quick succession.
|
// test resetting the proxy in quick succession.
|
||||||
// specifically the udp_socket connecting to a new
|
// specifically the udp_socket connecting to a new
|
||||||
// socks5 proxy while having one connection attempt
|
// socks5 proxy while having one connection attempt
|
||||||
// in progress.
|
// in progress.
|
||||||
pack.set_str(settings_pack::proxy_hostname, "5.6.7.8");
|
pack_p.set_str(settings_pack::proxy_hostname, "5.6.7.8");
|
||||||
ses1.apply_settings(pack);
|
ses1.apply_settings(pack_p);
|
||||||
pack.set_str(settings_pack::proxy_hostname, "127.0.0.1");
|
pack_p.set_str(settings_pack::proxy_hostname, "127.0.0.1");
|
||||||
ses1.apply_settings(pack);
|
ses1.apply_settings(pack_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
pack = sett;
|
pack = sett;
|
||||||
|
@ -264,7 +266,7 @@ void test_transfer(int proxy_type, settings_pack const& sett
|
||||||
, (flags & disk_full) ? &addp : ¶ms);
|
, (flags & disk_full) ? &addp : ¶ms);
|
||||||
|
|
||||||
int num_pieces = tor2.torrent_file()->num_pieces();
|
int num_pieces = tor2.torrent_file()->num_pieces();
|
||||||
std::vector<int> priorities(num_pieces, 1);
|
std::vector<int> priorities(std::size_t(num_pieces), 1);
|
||||||
|
|
||||||
int upload_mode_timer = 0;
|
int upload_mode_timer = 0;
|
||||||
|
|
||||||
|
@ -319,7 +321,7 @@ void test_transfer(int proxy_type, settings_pack const& sett
|
||||||
&& ++upload_mode_timer > 10)
|
&& ++upload_mode_timer > 10)
|
||||||
{
|
{
|
||||||
flags &= ~disk_full;
|
flags &= ~disk_full;
|
||||||
((test_storage*)tor2.get_storage_impl())->set_limit(16 * 1024 * 1024);
|
static_cast<test_storage*>(tor2.get_storage_impl())->set_limit(16 * 1024 * 1024);
|
||||||
|
|
||||||
// if we reset the upload mode too soon, there may be more disk
|
// if we reset the upload mode too soon, there may be more disk
|
||||||
// jobs failing right after, putting us back in upload mode. So,
|
// jobs failing right after, putting us back in upload mode. So,
|
||||||
|
@ -340,8 +342,8 @@ void test_transfer(int proxy_type, settings_pack const& sett
|
||||||
// at this point we probably disconnected the seed
|
// at this point we probably disconnected the seed
|
||||||
// so we need to reconnect as well
|
// so we need to reconnect as well
|
||||||
std::printf("%s: reconnecting peer\n", time_now_string());
|
std::printf("%s: reconnecting peer\n", time_now_string());
|
||||||
error_code ec;
|
error_code ec2;
|
||||||
tor2.connect_peer(tcp::endpoint(address::from_string("127.0.0.1", ec)
|
tor2.connect_peer(tcp::endpoint(address::from_string("127.0.0.1", ec2)
|
||||||
, ses1.listen_port()));
|
, ses1.listen_port()));
|
||||||
|
|
||||||
TEST_CHECK(tor2.status().is_finished == false);
|
TEST_CHECK(tor2.status().is_finished == false);
|
||||||
|
@ -387,6 +389,8 @@ void cleanup()
|
||||||
remove_all("tmp2_transfer_moved", ec);
|
remove_all("tmp2_transfer_moved", ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
TORRENT_TEST(no_contiguous_buffers)
|
TORRENT_TEST(no_contiguous_buffers)
|
||||||
{
|
{
|
||||||
|
|
|
@ -119,7 +119,7 @@ std::list<callback_info> callbacks;
|
||||||
|
|
||||||
namespace // TODO: remove this nested namespace
|
namespace // TODO: remove this nested namespace
|
||||||
{
|
{
|
||||||
struct upnp_callback : aux::portmap_callback
|
struct upnp_callback final : aux::portmap_callback
|
||||||
{
|
{
|
||||||
void on_port_mapping(port_mapping_t const mapping
|
void on_port_mapping(port_mapping_t const mapping
|
||||||
, address const& ip, int port
|
, address const& ip, int port
|
||||||
|
@ -134,12 +134,12 @@ namespace // TODO: remove this nested namespace
|
||||||
<< ", error: \"" << err.message() << "\"\n";
|
<< ", error: \"" << err.message() << "\"\n";
|
||||||
}
|
}
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
virtual bool should_log_portmap(portmap_transport) const override
|
bool should_log_portmap(portmap_transport) const override
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void log_portmap(portmap_transport, char const* msg) const override
|
void log_portmap(portmap_transport, char const* msg) const override
|
||||||
{
|
{
|
||||||
std::cout << "UPnP: " << msg << std::endl;
|
std::cout << "UPnP: " << msg << std::endl;
|
||||||
//TODO: store the log and verify that some key messages are there
|
//TODO: store the log and verify that some key messages are there
|
||||||
|
|
Loading…
Reference in New Issue