fix stout redirection in test framework

This commit is contained in:
arvidn 2017-11-21 11:27:23 +01:00 committed by Arvid Norberg
parent a57ad00e15
commit eac3fbceda
2 changed files with 14 additions and 9 deletions

View File

@ -70,7 +70,7 @@ using namespace libtorrent;
int old_stdout = -1;
int old_stderr = -1;
bool redirect_stdout = true;
bool redirect_stderr = false; // TODO: TEMPORARY!
bool redirect_stderr = true;
bool keep_files = false;
extern int _g_test_idx;
@ -80,14 +80,22 @@ unit_test_t* current_test = NULL;
void output_test_log_to_terminal()
{
if (current_test == NULL || old_stdout == -1 || old_stderr == -1
|| !redirect_stdout || current_test->output == NULL)
if (current_test == NULL
|| current_test->output == NULL)
return;
fflush(stdout);
fflush(stderr);
dup2(old_stdout, fileno(stdout));
dup2(old_stderr, fileno(stderr));
if (old_stdout != -1)
{
dup2(old_stdout, fileno(stdout));
old_stdout = -1;
}
if (old_stderr != -1)
{
dup2(old_stderr, fileno(stderr));
old_stderr = -1;
}
fseek(current_test->output, 0, SEEK_SET);
fprintf(stdout, "\x1b[1m[%s]\x1b[0m\n\n", current_test->name);

View File

@ -329,6 +329,7 @@ void test_udp_tracker(std::string const& iface, address tracker, tcp::endpoint c
pack.set_bool(settings_pack::announce_to_all_trackers, true);
pack.set_bool(settings_pack::announce_to_all_tiers, true);
pack.set_str(settings_pack::listen_interfaces, iface + ":48875");
pack.set_int(settings_pack::alert_mask, alert::all_categories);
boost::scoped_ptr<lt::session> s(new lt::session(pack));
@ -360,8 +361,6 @@ void test_udp_tracker(std::string const& iface, address tracker, tcp::endpoint c
break;
test_sleep(100);
fprintf(stderr, "UDP: %d / %d\n", int(num_udp_announces())
, int(prev_udp_announces) + 1);
}
// we should have announced to the tracker by now
@ -380,8 +379,6 @@ void test_udp_tracker(std::string const& iface, address tracker, tcp::endpoint c
break;
test_sleep(100);
fprintf(stderr, "UDP: %d / %d\n", int(num_udp_announces())
, int(prev_udp_announces) + 1);
}
TEST_CHECK(peer_ep == expected_peer);