From ba5b0638c0d77fd514eae70777a0b865dffa022b Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 25 Nov 2010 23:35:43 +0000 Subject: [PATCH] add feature to automatically close client_test after a specified amount of time (for scripting tests) --- examples/client_test.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 2e8737eeb..6f1de8803 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -836,6 +836,8 @@ int main(int argc, char* argv[]) " -W Set the max number of peers to keep in the peer list\n" " -N Do not attempt to use UPnP and NAT-PMP to forward ports\n" " -Y Rate limit local peers\n" + " -q automatically quit the client after of refreshes\n" + " this is useful for scripting tests\n" " " "\n\n" "TORRENT is a path to a .torrent file\n" @@ -859,6 +861,7 @@ int main(int argc, char* argv[]) int refresh_delay = 1; bool start_dht = true; bool start_upnp = true; + int loop_limit = 0; std::deque events; @@ -1039,6 +1042,7 @@ int main(int argc, char* argv[]) case 'I': outgoing_interface = arg; break; case 'N': start_upnp = false; --i; break; case 'Y': settings.ignore_limits_on_local_network = false; --i; break; + case 'q': loop_limit = atoi(arg); break; } ++i; // skip the argument } @@ -1134,8 +1138,9 @@ int main(int argc, char* argv[]) std::vector peers; std::vector queue; - for (;;) + while (loop_limit > 1 || loop_limit == 0) { + if (loop_limit > 1) --loop_limit; char c; while (sleep_and_input(&c, refresh_delay)) {