attempt to make test_pe_crypto pass under valgrind in reasonable time

This commit is contained in:
Arvid Norberg 2013-10-16 08:22:14 +00:00
parent 73323e2c3d
commit 17cb5d1041
1 changed files with 32 additions and 16 deletions

View File

@ -66,9 +66,10 @@ void display_pe_settings(libtorrent::pe_settings s)
, s.prefer_rc4 ? "true": "false");
}
void test_transfer(libtorrent::pe_settings::enc_policy policy,
libtorrent::pe_settings::enc_level level = libtorrent::pe_settings::both,
bool pref_rc4 = false)
void test_transfer(libtorrent::pe_settings::enc_policy policy
, int timeout
, libtorrent::pe_settings::enc_level level = libtorrent::pe_settings::both
, bool pref_rc4 = false)
{
using namespace libtorrent;
@ -110,14 +111,14 @@ void test_transfer(libtorrent::pe_settings::enc_policy policy,
fprintf(stderr, "waiting for transfer to complete\n");
for (int i = 0; i < 50; ++i)
for (int i = 0; i < timeout * 10; ++i)
{
torrent_status s = tor2.status();
print_alerts(ses1, "ses1");
print_alerts(ses2, "ses2");
if (s.is_seeding) break;
test_sleep(1000);
test_sleep(100);
}
TEST_CHECK(tor2.status().is_seeding);
@ -137,7 +138,11 @@ void test_transfer(libtorrent::pe_settings::enc_policy policy,
void test_enc_handler(libtorrent::encryption_handler* a, libtorrent::encryption_handler* b)
{
int repcount = 128;
#ifdef TORRENT_USE_VALGRIND
const int repcount = 10;
#else
const int repcount = 128;
#endif
for (int rep = 0; rep < repcount; ++rep)
{
std::size_t buf_len = rand() % (512 * 1024);
@ -169,7 +174,12 @@ int test_main()
using namespace libtorrent;
#ifndef TORRENT_DISABLE_ENCRYPTION
int repcount = 128;
#ifdef TORRENT_USE_VALGRIND
const int repcount = 10;
#else
const int repcount = 128;
#endif
for (int rep = 0; rep < repcount; ++rep)
{
@ -199,17 +209,23 @@ int test_main()
rc42.set_outgoing_key(&test2_key[0], 20);
test_enc_handler(&rc41, &rc42);
test_transfer(pe_settings::disabled);
#ifdef TORRENT_USE_VALGRIND
const int timeout = 10;
#else
const int timeout = 5;
#endif
test_transfer(pe_settings::forced, pe_settings::plaintext);
test_transfer(pe_settings::forced, pe_settings::rc4);
test_transfer(pe_settings::forced, pe_settings::both, false);
test_transfer(pe_settings::forced, pe_settings::both, true);
test_transfer(pe_settings::disabled, timeout);
test_transfer(pe_settings::enabled, pe_settings::plaintext);
test_transfer(pe_settings::enabled, pe_settings::rc4);
test_transfer(pe_settings::enabled, pe_settings::both, false);
test_transfer(pe_settings::enabled, pe_settings::both, true);
test_transfer(pe_settings::forced, timeout, pe_settings::plaintext);
test_transfer(pe_settings::forced, timeout, pe_settings::rc4);
test_transfer(pe_settings::forced, timeout, pe_settings::both, false);
test_transfer(pe_settings::forced, timeout, pe_settings::both, true);
test_transfer(pe_settings::enabled, timeout, pe_settings::plaintext);
test_transfer(pe_settings::enabled, timeout, pe_settings::rc4);
test_transfer(pe_settings::enabled, timeout, pe_settings::both, false);
test_transfer(pe_settings::enabled, timeout, pe_settings::both, true);
#else
fprintf(stderr, "PE test not run because it's disabled\n");
#endif