2013-05-31 18:33:06 +02:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright (c) 2013, Arvid Norberg
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in
|
|
|
|
the documentation and/or other materials provided with the distribution.
|
|
|
|
* Neither the name of the author nor the names of its
|
|
|
|
contributors may be used to endorse or promote products derived
|
|
|
|
from this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libtorrent/session.hpp"
|
|
|
|
|
|
|
|
#include "test.hpp"
|
|
|
|
#include "setup_transfer.hpp"
|
2014-07-06 21:18:00 +02:00
|
|
|
#include "libtorrent/alert_types.hpp"
|
2013-05-31 18:33:06 +02:00
|
|
|
|
|
|
|
using namespace libtorrent;
|
2014-07-06 21:18:00 +02:00
|
|
|
namespace lt = libtorrent;
|
2013-05-31 18:33:06 +02:00
|
|
|
|
|
|
|
int test_main()
|
|
|
|
{
|
2014-07-06 21:18:00 +02:00
|
|
|
settings_pack p;
|
|
|
|
p.set_int(settings_pack::alert_mask, ~0);
|
2014-12-31 16:51:45 +01:00
|
|
|
lt::session ses(p);
|
2014-07-06 21:18:00 +02:00
|
|
|
|
|
|
|
settings_pack sett;
|
|
|
|
sett.set_int(settings_pack::cache_size, 100);
|
|
|
|
sett.set_int(settings_pack::max_queued_disk_bytes, 1000 * 16 * 1024);
|
|
|
|
|
|
|
|
ses.apply_settings(sett);
|
|
|
|
|
|
|
|
// verify that we get the appropriate performance warning because
|
|
|
|
// we're allowing a larger queue than we have cache.
|
|
|
|
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
alert const* a;
|
2014-07-06 21:18:00 +02:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
a = wait_for_alert(ses, performance_alert::alert_type, "ses1");
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
if (a == NULL) break;
|
|
|
|
TEST_EQUAL(a->type(), performance_alert::alert_type);
|
2014-07-06 21:18:00 +02:00
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
if (alert_cast<performance_alert>(a)->warning_code
|
2014-07-06 21:18:00 +02:00
|
|
|
== performance_alert::too_high_disk_queue_limit)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
TEST_CHECK(a);
|
2013-05-31 18:33:06 +02:00
|
|
|
|
2014-11-09 12:17:13 +01:00
|
|
|
sett.set_int(settings_pack::unchoke_slots_limit, 0);
|
|
|
|
ses.apply_settings(sett);
|
|
|
|
TEST_CHECK(ses.get_settings().get_int(settings_pack::unchoke_slots_limit) == 0);
|
|
|
|
|
|
|
|
sett.set_int(settings_pack::unchoke_slots_limit, -1);
|
|
|
|
ses.apply_settings(sett);
|
|
|
|
TEST_CHECK(ses.get_settings().get_int(settings_pack::unchoke_slots_limit) == -1);
|
|
|
|
|
|
|
|
sett.set_int(settings_pack::unchoke_slots_limit, 8);
|
|
|
|
ses.apply_settings(sett);
|
|
|
|
TEST_CHECK(ses.get_settings().get_int(settings_pack::unchoke_slots_limit) == 8);
|
|
|
|
|
2013-05-31 18:33:06 +02:00
|
|
|
// make sure the destructor waits properly
|
|
|
|
// for the asynchronous call to set the alert
|
|
|
|
// mask completes, before it goes on to destruct
|
|
|
|
// the session object
|
2013-06-12 09:57:13 +02:00
|
|
|
return 0;
|
2013-05-31 18:33:06 +02:00
|
|
|
}
|
|
|
|
|