forked from premiere/premiere-libtorrent
attempt to make test_utp and swarm_suite more reliable
This commit is contained in:
parent
0a67a2dd67
commit
ab2d187001
|
@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/alert_types.hpp"
|
#include "libtorrent/alert_types.hpp"
|
||||||
#include "libtorrent/thread.hpp"
|
#include "libtorrent/thread.hpp"
|
||||||
#include "libtorrent/time.hpp"
|
#include "libtorrent/time.hpp"
|
||||||
|
#include "libtorrent/random.hpp"
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
|
|
||||||
#include "test.hpp"
|
#include "test.hpp"
|
||||||
|
@ -102,8 +103,11 @@ void test_swarm(int flags)
|
||||||
// three peers before finishing.
|
// three peers before finishing.
|
||||||
float rate_limit = 100000;
|
float rate_limit = 100000;
|
||||||
|
|
||||||
|
int port = lt::random() % 100;
|
||||||
|
char iface[50];
|
||||||
|
snprintf(iface, sizeof(iface), "0.0.0.0:480%02d", port);
|
||||||
pack.set_int(settings_pack::upload_rate_limit, rate_limit);
|
pack.set_int(settings_pack::upload_rate_limit, rate_limit);
|
||||||
pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48000");
|
pack.set_str(settings_pack::listen_interfaces, iface);
|
||||||
pack.set_int(settings_pack::max_retry_port_bind, 1000);
|
pack.set_int(settings_pack::max_retry_port_bind, 1000);
|
||||||
|
|
||||||
pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_forced);
|
pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_forced);
|
||||||
|
@ -111,12 +115,14 @@ void test_swarm(int flags)
|
||||||
|
|
||||||
lt::session ses1(pack);
|
lt::session ses1(pack);
|
||||||
|
|
||||||
pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:49000");
|
snprintf(iface, sizeof(iface), "0.0.0.0:490%02d", port);
|
||||||
|
pack.set_str(settings_pack::listen_interfaces, iface);
|
||||||
pack.set_int(settings_pack::download_rate_limit, rate_limit / 2);
|
pack.set_int(settings_pack::download_rate_limit, rate_limit / 2);
|
||||||
pack.set_int(settings_pack::upload_rate_limit, rate_limit);
|
pack.set_int(settings_pack::upload_rate_limit, rate_limit);
|
||||||
lt::session ses2(pack);
|
lt::session ses2(pack);
|
||||||
|
|
||||||
pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:50000");
|
snprintf(iface, sizeof(iface), "0.0.0.0:500%02d", port);
|
||||||
|
pack.set_str(settings_pack::listen_interfaces, iface);
|
||||||
lt::session ses3(pack);
|
lt::session ses3(pack);
|
||||||
|
|
||||||
torrent_handle tor1;
|
torrent_handle tor1;
|
||||||
|
|
|
@ -63,7 +63,17 @@ void test_transfer()
|
||||||
session_proxy p1;
|
session_proxy p1;
|
||||||
session_proxy p2;
|
session_proxy p2;
|
||||||
|
|
||||||
|
const int mask = alert::all_categories
|
||||||
|
& ~(alert::progress_notification
|
||||||
|
| alert::performance_warning
|
||||||
|
| alert::stats_notification);
|
||||||
|
|
||||||
settings_pack pack;
|
settings_pack pack;
|
||||||
|
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);
|
||||||
pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_disabled);
|
pack.set_int(settings_pack::out_enc_policy, settings_pack::pe_disabled);
|
||||||
pack.set_int(settings_pack::in_enc_policy, settings_pack::pe_disabled);
|
pack.set_int(settings_pack::in_enc_policy, settings_pack::pe_disabled);
|
||||||
pack.set_bool(settings_pack::enable_outgoing_tcp, false);
|
pack.set_bool(settings_pack::enable_outgoing_tcp, false);
|
||||||
|
@ -98,9 +108,9 @@ void test_transfer()
|
||||||
, true, false, true, "_utp", 0, &t, false, &atp);
|
, true, false, true, "_utp", 0, &t, false, &atp);
|
||||||
|
|
||||||
#ifdef TORRENT_USE_VALGRIND
|
#ifdef TORRENT_USE_VALGRIND
|
||||||
const int timeout = 12;
|
const int timeout = 16;
|
||||||
#else
|
#else
|
||||||
const int timeout = 6;
|
const int timeout = 8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < timeout; ++i)
|
for (int i = 0; i < timeout; ++i)
|
||||||
|
|
Loading…
Reference in New Issue