minor improvement to test_tracker. fix test output redirection on windows. tweak starting of web server in tests

This commit is contained in:
arvidn 2019-03-26 12:41:52 +01:00 committed by Arvid Norberg
parent 102387f4a8
commit 5260128933
3 changed files with 22 additions and 5 deletions

View File

@ -439,7 +439,25 @@ int EXPORT main(int argc, char const* argv[])
fflush(stdout);
fflush(stderr);
#ifdef TORRENT_MINGW
// mingw has a buggy tmpfile() and tmpname() that needs a . prepended
// to it (or some other directory)
char temp_name[512];
FILE* f = nullptr;
if (tmpnam_s(temp_name + 1, sizeof(temp_name) - 1) == 0)
{
temp_name[0] = '.';
std::printf("using temporary filename %s\n", temp_name);
f = fopen(temp_name, "wb+");
}
else
{
std::printf("failed to generate filename for redirecting "
"output: (%d) %s\n", errno, strerror(errno));
}
#else
FILE* f = tmpfile();
#endif
if (f != nullptr)
{
int ret1 = 0;

View File

@ -542,7 +542,7 @@ int start_proxy(int proxy_type)
if (i->second.type == proxy_type) { return i->first; }
}
int port = 2000 + static_cast<int>(lt::random(6000));
int port = 10000 + static_cast<int>(lt::random(50000));
error_code ec;
io_service ios;
@ -976,7 +976,7 @@ int start_web_server(bool ssl, bool chunked_encoding, bool keepalive, int min_in
if (r == 0) abort();
web_server_pid = r;
std::printf("%s launched\n", time_now_string());
std::this_thread::sleep_for(lt::milliseconds(500));
std::this_thread::sleep_for(lt::milliseconds(1000));
return port;
}

View File

@ -426,7 +426,7 @@ TORRENT_TEST(udp_tracker_v6)
TORRENT_TEST(http_peers)
{
int http_port = start_web_server();
int const http_port = start_web_server();
settings_pack pack = settings();
pack.set_bool(settings_pack::announce_to_all_trackers, true);
@ -445,7 +445,6 @@ TORRENT_TEST(http_peers)
file.close();
char tracker_url[200];
// and this should not be announced to (since the one before it succeeded)
std::snprintf(tracker_url, sizeof(tracker_url), "http://127.0.0.1:%d/announce"
, http_port);
t->add_tracker(tracker_url, 0);
@ -466,7 +465,7 @@ TORRENT_TEST(http_peers)
status = h.status();
TEST_CHECK(!status.current_tracker.empty());
TEST_CHECK(status.current_tracker == tracker_url);
TEST_EQUAL(status.current_tracker, tracker_url);
// we expect to have certain peers in our peer list now
// these peers are hard coded in web_server.py