forked from premiere/premiere-libtorrent
split up test_storage into smaller test cases to improve output on failures
This commit is contained in:
parent
8b66fbe194
commit
7d2deb01db
|
@ -477,8 +477,9 @@ void test_check_files(std::string const& test_path
|
|||
#define storage_mode_compact storage_mode_sparse
|
||||
#endif
|
||||
|
||||
void run_test(std::string const& test_path, bool unbuffered)
|
||||
void run_test(bool unbuffered)
|
||||
{
|
||||
std::string test_path = current_working_directory();
|
||||
std::cerr << "\n=== " << test_path << " ===\n" << std::endl;
|
||||
|
||||
boost::shared_ptr<torrent_info> info;
|
||||
|
@ -602,8 +603,9 @@ void run_test(std::string const& test_path, bool unbuffered)
|
|||
test_rename(test_path);
|
||||
}
|
||||
|
||||
void test_fastresume(std::string const& test_path)
|
||||
TORRENT_TEST(fastresume)
|
||||
{
|
||||
std::string test_path = current_working_directory();
|
||||
error_code ec;
|
||||
std::cout << "\n\n=== test fastresume ===" << std::endl;
|
||||
remove_all(combine_path(test_path, "tmp1"), ec);
|
||||
|
@ -622,8 +624,17 @@ void test_fastresume(std::string const& test_path)
|
|||
|
||||
entry resume;
|
||||
{
|
||||
const 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);
|
||||
lt::session ses(pack);
|
||||
|
||||
error_code ec;
|
||||
|
@ -674,8 +685,17 @@ void test_fastresume(std::string const& test_path)
|
|||
|
||||
// make sure the fast resume check fails! since we removed the file
|
||||
{
|
||||
const 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);
|
||||
lt::session ses(pack);
|
||||
|
||||
add_torrent_params p;
|
||||
|
@ -704,8 +724,9 @@ bool got_file_rename_alert(alert const* a)
|
|||
|| alert_cast<libtorrent::file_rename_failed_alert>(a);
|
||||
}
|
||||
|
||||
void test_rename_file_in_fastresume(std::string const& test_path)
|
||||
TORRENT_TEST(rename_file_fastresume)
|
||||
{
|
||||
std::string test_path = current_working_directory();
|
||||
error_code ec;
|
||||
std::cout << "\n\n=== test rename file in fastresume ===" << std::endl;
|
||||
remove_all(combine_path(test_path, "tmp2"), ec);
|
||||
|
@ -721,8 +742,17 @@ void test_rename_file_in_fastresume(std::string const& test_path)
|
|||
|
||||
entry resume;
|
||||
{
|
||||
const 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);
|
||||
lt::session ses(pack);
|
||||
|
||||
add_torrent_params p;
|
||||
|
@ -761,8 +791,17 @@ void test_rename_file_in_fastresume(std::string const& test_path)
|
|||
|
||||
// make sure the fast resume check succeeds, even though we renamed the file
|
||||
{
|
||||
const 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);
|
||||
lt::session ses(pack);
|
||||
|
||||
add_torrent_params p;
|
||||
|
@ -964,11 +1003,8 @@ TORRENT_TEST(storage)
|
|||
p = std::strtok(0, ";");
|
||||
}
|
||||
}
|
||||
|
||||
std::for_each(test_paths.begin(), test_paths.end(), boost::bind(&test_fastresume, _1));
|
||||
std::for_each(test_paths.begin(), test_paths.end(), boost::bind(&test_rename_file_in_fastresume, _1));
|
||||
|
||||
std::for_each(test_paths.begin(), test_paths.end(), boost::bind(&run_test, _1, true));
|
||||
std::for_each(test_paths.begin(), test_paths.end(), boost::bind(&run_test, _1, false));
|
||||
}
|
||||
|
||||
TORRENT_TEST(unbuffered) { run_test(true); }
|
||||
TORRENT_TEST(buffered) { run_test(false); }
|
||||
|
||||
|
|
Loading…
Reference in New Issue