Include stdio.h & list.h before this header
*/
+/** calculate the difference in useconds out of two "struct timespec"s */
+#define DIFF_IN_USEC(begin, end) \
+ ( (((end).tv_sec - (begin).tv_sec) * 1000000) + \
+ ((end).tv_nsec/1000) - ((begin).tv_nsec/1000) )
+
typedef struct TF {
TFun fn;
int loop_start;
{
TestResult *tr;
Suite *s;
- static struct timeval inittv;
+ static struct timespec ts_start;
static char t[sizeof "yyyy-mm-dd hh:mm:ss"] = {0};
if (t[0] == 0)
{
+ struct timeval inittv;
struct tm now;
gettimeofday(&inittv, NULL);
+ clock_gettime(CLOCK_MONOTONIC, &ts_start);
localtime_r(&(inittv.tv_sec), &now);
strftime(t, sizeof("yyyy-mm-dd hh:mm:ss"), "%Y-%m-%d %H:%M:%S", &now);
}
break;
case CLENDLOG_SR:
{
- struct timeval now;
+ struct timespec ts_end;
+ unsigned int duration;
/* calculate time the test were running */
- gettimeofday(&now, NULL);
- timersub(&now, &inittv, &now);
-
- fprintf(file, " <duration>%lu.%06lu</duration>\n",
- now.tv_sec, now.tv_usec);
+ clock_gettime(CLOCK_MONOTONIC, &ts_end);
+ duration = DIFF_IN_USEC(ts_start, ts_end);
+ fprintf(file, " <duration>%u.%06u</duration>\n",
+ duration / 1000000, duration % 1000000);
fprintf(file, "</testsuites>\n");
}
break;
};
-/** calculate the difference in useconds out of two "struct timeval"s */
-#define DIFF_IN_USEC(begin, end) \
- ( (((end).tv_sec - (begin).tv_sec) * 1000000) + \
- ((end).tv_nsec/1000) - ((begin).tv_nsec/1000) )
-
/* all functions are defined in the same order they are declared.
functions that depend on forking are gathered all together.
non-static functions are at the end of the file. */