Skip to content

Commit

Permalink
Log time taken by each test case in a test suite.
Browse files Browse the repository at this point in the history
Should help diagnose why test/backupstore sometimes takes >500 seconds on
Travis, when it normally takes ~120 seconds.
  • Loading branch information
qris committed Jul 23, 2017
1 parent 54a1d8a commit 28c48b6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/common/Test.cpp
Expand Up @@ -39,6 +39,7 @@ std::string first_fail_file;
std::string current_test_name;
std::list<std::string> run_only_named_tests;
std::map<std::string, std::string> s_test_status;
box_time_t current_test_start;

bool setUp(const char* function_name)
{
Expand Down Expand Up @@ -69,6 +70,7 @@ bool setUp(const char* function_name)
printf("\n\n== %s ==\n", function_name);
num_tests_selected++;
old_failure_count = num_failures;
current_test_start = GetCurrentBoxTime();

if (original_working_dir == "")
{
Expand Down Expand Up @@ -224,15 +226,21 @@ bool setUp(const char* function_name)

bool tearDown()
{
box_time_t elapsed_time = GetCurrentBoxTime() - current_test_start;
std::ostringstream buf;
buf.setf(std::ios_base::fixed);
buf.precision(1);
buf << " (" << ((float)BoxTimeToMilliSeconds(elapsed_time) / 1000) << " sec)";

if (num_failures == old_failure_count)
{
BOX_NOTICE(current_test_name << " passed");
BOX_NOTICE(current_test_name << " passed" << buf.str());
s_test_status[current_test_name] = "passed";
return true;
}
else
{
BOX_NOTICE(current_test_name << " failed"); \
BOX_NOTICE(current_test_name << " failed" << buf.str()); \
s_test_status[current_test_name] = "FAILED";
return false;
}
Expand Down

0 comments on commit 28c48b6

Please sign in to comment.