fix build of test_storage without deprecated functions
This commit is contained in:
parent
63ee0fd569
commit
3b9fd38c22
|
@ -71,6 +71,28 @@ void report_failure(char const* err, char const* file, int line)
|
|||
tests_failure = true;
|
||||
}
|
||||
|
||||
std::auto_ptr<alert> wait_for_alert(session& ses, int type)
|
||||
{
|
||||
std::auto_ptr<alert> ret;
|
||||
while (!ret.get())
|
||||
{
|
||||
ses.wait_for_alert(milliseconds(5000));
|
||||
std::deque<alert*> alerts;
|
||||
ses.pop_alerts(&alerts);
|
||||
for (std::deque<alert*>::iterator i = alerts.begin()
|
||||
, end(alerts.end()); i != end; ++i)
|
||||
{
|
||||
if (!ret.get() && (*i)->type() == type)
|
||||
{
|
||||
ret = std::auto_ptr<alert>(*i);
|
||||
}
|
||||
else
|
||||
delete *i;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool print_alerts(libtorrent::session& ses, char const* name
|
||||
, bool allow_disconnects, bool allow_no_torrents, bool allow_failed_fastresume
|
||||
, bool (*predicate)(libtorrent::alert*), bool no_output)
|
||||
|
|
|
@ -43,6 +43,8 @@ namespace libtorrent
|
|||
struct session_status;
|
||||
}
|
||||
|
||||
std::auto_ptr<libtorrent::alert> wait_for_alert(libtorrent::session& ses, int type);
|
||||
|
||||
void print_ses_rate(libtorrent::torrent_status const* st1
|
||||
, libtorrent::torrent_status const* st2
|
||||
, libtorrent::torrent_status const* st3 = NULL);
|
||||
|
|
|
@ -829,6 +829,7 @@ void run_test(std::string const& test_path, bool unbuffered)
|
|||
TEST_CHECK(exists(combine_path(base, "test4.tmp")));
|
||||
TEST_EQUAL(file_size(combine_path(base, "test5.tmp")), 3253);
|
||||
TEST_EQUAL(file_size(combine_path(base, "test6.tmp")), 841);
|
||||
printf("file: %d expected: %d last_file_size: %d, piece_size: %d\n", int(file_size(combine_path(base, "test7.tmp"))), int(last_file_size - piece_size), last_file_size, piece_size);
|
||||
TEST_EQUAL(file_size(combine_path(base, "test7.tmp")), last_file_size - piece_size);
|
||||
remove_all(combine_path(test_path, "temp_storage"), ec);
|
||||
if (ec) std::cerr << "remove_all '" << combine_path(test_path, "temp_storage")
|
||||
|
@ -940,8 +941,10 @@ void test_fastresume(std::string const& test_path)
|
|||
if (s.progress != 1.0f)
|
||||
return;
|
||||
|
||||
// TODO: 3 don't use this deprecated function
|
||||
resume = h.write_resume_data();
|
||||
h.save_resume_data();
|
||||
std::auto_ptr<alert> ra = wait_for_alert(ses, save_resume_data_alert::alert_type);
|
||||
TEST_CHECK(ra.get());
|
||||
if (ra.get()) resume = *alert_cast<save_resume_data_alert>(ra.get())->resume_data;
|
||||
ses.remove_torrent(h, session::delete_files);
|
||||
}
|
||||
TEST_CHECK(!exists(combine_path(test_path, "tmp1/temporary")));
|
||||
|
@ -1031,8 +1034,11 @@ void test_rename_file_in_fastresume(std::string const& test_path)
|
|||
std::cout << "stop loop" << std::endl;
|
||||
torrent_status s = h.status();
|
||||
TEST_CHECK(s.state == torrent_status::seeding);
|
||||
// TODO: 3 don't use this deprecated function
|
||||
resume = h.write_resume_data();
|
||||
|
||||
h.save_resume_data();
|
||||
std::auto_ptr<alert> ra = wait_for_alert(ses, save_resume_data_alert::alert_type);
|
||||
TEST_CHECK(ra.get());
|
||||
if (ra.get()) resume = *alert_cast<save_resume_data_alert>(ra.get())->resume_data;
|
||||
ses.remove_torrent(h);
|
||||
}
|
||||
TEST_CHECK(!exists(combine_path(test_path, "tmp2/temporary")));
|
||||
|
@ -1064,8 +1070,10 @@ void test_rename_file_in_fastresume(std::string const& test_path)
|
|||
torrent_status stat = h.status();
|
||||
TEST_CHECK(stat.state == torrent_status::seeding);
|
||||
|
||||
// TODO: 3 don't use this deprecated function
|
||||
resume = h.write_resume_data();
|
||||
h.save_resume_data();
|
||||
std::auto_ptr<alert> ra = wait_for_alert(ses, save_resume_data_alert::alert_type);
|
||||
TEST_CHECK(ra.get());
|
||||
if (ra.get()) resume = *alert_cast<save_resume_data_alert>(ra.get())->resume_data;
|
||||
ses.remove_torrent(h);
|
||||
}
|
||||
TEST_CHECK(resume.dict().find("mapped_files") != resume.dict().end());
|
||||
|
|
|
@ -217,7 +217,7 @@ for r in range(latest_rev, latest_rev - 20, -1):
|
|||
(platforms, tests) = parse_tests(rev_dir)
|
||||
|
||||
for f in tests:
|
||||
print >>html, '<th colspan="%d">%s</th>' % (len(tests[f]), f)
|
||||
print >>html, '<th colspan="%d" style="width: %dpx;">%s</th>' % (len(tests[f]), len(tests[f])*9 - 3, f)
|
||||
print >>html, '</tr>'
|
||||
|
||||
for p in platforms:
|
||||
|
@ -266,3 +266,5 @@ for d in details:
|
|||
sys.stdout.write('.')
|
||||
sys.stdout.flush()
|
||||
|
||||
print ''
|
||||
|
||||
|
|
Loading…
Reference in New Issue