restore client_test feature to exit after a specified number of loops (useful for automated tests)

This commit is contained in:
arvidn 2019-09-13 14:20:06 +02:00 committed by Arvid Norberg
parent d08fa164d2
commit f995c68377
1 changed files with 11 additions and 1 deletions

View File

@ -1026,6 +1026,8 @@ CLIENT OPTIONS
previous command line options, so be sure to specify this first previous command line options, so be sure to specify this first
-G Add torrents in seed-mode (i.e. assume all pieces -G Add torrents in seed-mode (i.e. assume all pieces
are present and check hashes on-demand) are present and check hashes on-demand)
-e <loops> exit client after the specified number of iterations
through the main loop
-O print session stats counters to the log)" -O print session stats counters to the log)"
#ifdef TORRENT_UTP_LOG_ENABLE #ifdef TORRENT_UTP_LOG_ENABLE
R"( R"(
@ -1117,6 +1119,7 @@ example alert_masks:
bool rate_limit_locals = false; bool rate_limit_locals = false;
std::deque<std::string> events; std::deque<std::string> events;
int loop_limit = -1;
lt::time_point next_dir_scan = lt::clock_type::now(); lt::time_point next_dir_scan = lt::clock_type::now();
@ -1245,6 +1248,11 @@ example alert_masks:
break; break;
} }
case '0': disable_storage = true; --i; case '0': disable_storage = true; --i;
case 'e':
{
loop_limit = atoi(arg);
break;
}
} }
++i; // skip the argument ++i; // skip the argument
} }
@ -1331,8 +1339,10 @@ example alert_masks:
signal(SIGINT, signal_handler); signal(SIGINT, signal_handler);
#endif #endif
while (!quit) while (!quit && loop_limit != 0)
{ {
if (loop_limit > 0) --loop_limit;
ses.post_torrent_updates(); ses.post_torrent_updates();
ses.post_session_stats(); ses.post_session_stats();
ses.post_dht_stats(); ses.post_dht_stats();