From: hugo303 Date: Thu, 11 Oct 2012 08:53:08 +0000 (+0000) Subject: * Measure test duration correctly. Fixes SF bug #3575451. X-Git-Tag: 0.10.0~557 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d2706e9d63e7d1df0b50fa970f580d3f6c1c2775;p=check * Measure test duration correctly. Fixes SF bug #3575451. git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@622 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- diff --git a/src/check_log.c b/src/check_log.c index bec5aa4..7be1b42 100644 --- a/src/check_log.c +++ b/src/check_log.c @@ -222,7 +222,7 @@ void xml_lfun (SRunner *sr CK_ATTRIBUTE_UNUSED, FILE *file, enum print_output pr { TestResult *tr; Suite *s; - static struct timeval inittv, endtv; + static struct timeval inittv; static char t[sizeof "yyyy-mm-dd hh:mm:ss"] = {0}; if (t[0] == 0) @@ -241,11 +241,17 @@ void xml_lfun (SRunner *sr CK_ATTRIBUTE_UNUSED, FILE *file, enum print_output pr fprintf(file, " %s\n", t); break; case CLENDLOG_SR: - gettimeofday(&endtv, NULL); - fprintf(file, " %f\n", - (endtv.tv_sec + (float)(endtv.tv_usec)/1000000) - \ - (inittv.tv_sec + (float)(inittv.tv_usec/1000000))); - fprintf(file, "\n"); + { + struct timeval now; + + /* calculate time the test were running */ + gettimeofday(&now, NULL); + timersub(&now, &inittv, &now); + + fprintf(file, " %d.%06d\n", + now.tv_sec, now.tv_usec); + fprintf(file, "\n"); + } break; case CLSTART_SR: break;