diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index 80f69f8ef..e7911daba 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -71,6 +71,28 @@ void report_failure(char const* err, char const* file, int line) tests_failure = true; } +std::auto_ptr wait_for_alert(session& ses, int type) +{ + std::auto_ptr ret; + while (!ret.get()) + { + ses.wait_for_alert(milliseconds(5000)); + std::deque alerts; + ses.pop_alerts(&alerts); + for (std::deque::iterator i = alerts.begin() + , end(alerts.end()); i != end; ++i) + { + if (!ret.get() && (*i)->type() == type) + { + ret = std::auto_ptr(*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) diff --git a/test/setup_transfer.hpp b/test/setup_transfer.hpp index ecb775938..244458eae 100644 --- a/test/setup_transfer.hpp +++ b/test/setup_transfer.hpp @@ -43,6 +43,8 @@ namespace libtorrent struct session_status; } +std::auto_ptr 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); diff --git a/test/test_storage.cpp b/test/test_storage.cpp index 4bab7e7f5..266dc93a8 100644 --- a/test/test_storage.cpp +++ b/test/test_storage.cpp @@ -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 ra = wait_for_alert(ses, save_resume_data_alert::alert_type); + TEST_CHECK(ra.get()); + if (ra.get()) resume = *alert_cast(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 ra = wait_for_alert(ses, save_resume_data_alert::alert_type); + TEST_CHECK(ra.get()); + if (ra.get()) resume = *alert_cast(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 ra = wait_for_alert(ses, save_resume_data_alert::alert_type); + TEST_CHECK(ra.get()); + if (ra.get()) resume = *alert_cast(ra.get())->resume_data; ses.remove_torrent(h); } TEST_CHECK(resume.dict().find("mapped_files") != resume.dict().end()); diff --git a/tools/parse_test_results.py b/tools/parse_test_results.py index 06add4e21..409806855 100755 --- a/tools/parse_test_results.py +++ b/tools/parse_test_results.py @@ -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, '%s' % (len(tests[f]), f) + print >>html, '%s' % (len(tests[f]), len(tests[f])*9 - 3, f) print >>html, '' for p in platforms: @@ -266,3 +266,5 @@ for d in details: sys.stdout.write('.') sys.stdout.flush() +print '' +