updates to test_storage
This commit is contained in:
parent
dacb1ac48d
commit
090502390f
|
@ -51,9 +51,11 @@ using boost::filesystem::create_directory;
|
|||
using namespace libtorrent;
|
||||
namespace sf = boost::filesystem;
|
||||
|
||||
void print_alerts(libtorrent::session& ses, char const* name
|
||||
, bool allow_disconnects, bool allow_no_torrents, bool allow_failed_fastresume)
|
||||
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 ret = false;
|
||||
std::vector<torrent_handle> handles = ses.get_torrents();
|
||||
TEST_CHECK(!handles.empty() || allow_no_torrents);
|
||||
torrent_handle h;
|
||||
|
@ -62,6 +64,7 @@ void print_alerts(libtorrent::session& ses, char const* name
|
|||
a = ses.pop_alert();
|
||||
while (a.get())
|
||||
{
|
||||
if (predicate && predicate(a.get())) ret = true;
|
||||
if (peer_disconnected_alert* p = dynamic_cast<peer_disconnected_alert*>(a.get()))
|
||||
{
|
||||
std::cerr << name << "(" << p->ip << "): " << p->message() << "\n";
|
||||
|
@ -85,6 +88,7 @@ void print_alerts(libtorrent::session& ses, char const* name
|
|||
|| (allow_disconnects && a->message() == "End of file."));
|
||||
a = ses.pop_alert();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void test_sleep(int millisec)
|
||||
|
|
|
@ -36,11 +36,17 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/session.hpp"
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
class alert;
|
||||
}
|
||||
|
||||
void print_alerts(libtorrent::session& ses, char const* name
|
||||
bool print_alerts(libtorrent::session& ses, char const* name
|
||||
, bool allow_disconnects = false
|
||||
, bool allow_no_torrents = false
|
||||
, bool allow_failed_fastresume = false);
|
||||
, bool allow_failed_fastresume = false
|
||||
, bool (*)(libtorrent::alert*) = 0);
|
||||
|
||||
void test_sleep(int millisec);
|
||||
|
||||
boost::intrusive_ptr<libtorrent::torrent_info> create_torrent(std::ostream* file = 0, int piece_size = 16 * 1024, int num_pieces = 1024 / 8);
|
||||
|
|
|
@ -478,6 +478,12 @@ void test_fastresume()
|
|||
remove_all("tmp1");
|
||||
}
|
||||
|
||||
bool got_file_rename_alert(alert* a)
|
||||
{
|
||||
return dynamic_cast<libtorrent::file_renamed_alert*>(a)
|
||||
|| dynamic_cast<libtorrent::file_rename_failed_alert*>(a);
|
||||
}
|
||||
|
||||
void test_rename_file_in_fastresume()
|
||||
{
|
||||
std::cout << "\n\n=== test rename file in fastresume ===" << std::endl;
|
||||
|
@ -498,12 +504,14 @@ void test_rename_file_in_fastresume()
|
|||
, storage_mode_compact);
|
||||
|
||||
h.rename_file(0, "testing_renamed_files");
|
||||
for (int i = 0; i < 10; ++i)
|
||||
std::cout << "renaming file" << std::endl;
|
||||
for (int i = 0; i < 100; ++i)
|
||||
{
|
||||
print_alerts(ses, "ses");
|
||||
if (print_alerts(ses, "ses", true, true, true, &got_file_rename_alert)) break;
|
||||
test_sleep(1000);
|
||||
torrent_status s = h.status();
|
||||
}
|
||||
std::cout << "stop loop" << std::endl;
|
||||
resume = h.write_resume_data();
|
||||
ses.remove_torrent(h);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue