* Copyright (C) 2017 Jérémie Galarneau
*/
+#include "../utils.h"
+#include "common/compat/time.hpp"
#include "tap.h"
#include <assert.h>
#include <ctype.h>
+#include <errno.h>
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
static int no_plan = 0;
static int skip_all = 0;
static const char *todo_msg_fixed = "libtap malloc issue";
static int todo = 0;
static int test_died = 0;
+static int time_tests = 1;
+struct timespec last_time;
/* Encapsulate the pthread code in a conditional. In the absence of
libpthread the code does nothing */
}
printf("\n");
+ _output_test_time();
if (!ok) {
if (getenv("HARNESS_ACTIVE") != NULL)
in the same place relative to stderr output as it does
with Test::Harness */
setbuf(stdout, 0);
+
+ /*
+ * Check if the LTTNG_TESTS_TAP_AUTOTIME environment variable
+ * is set and contains at least one byte.
+ */
+ const char *autotime_env = getenv("LTTNG_TESTS_TAP_AUTOTIME");
+ if (autotime_env != NULL && strnlen(autotime_env, 1)) {
+ int tap_autotime;
+
+ /*
+ * Check if LTTNG_TESTS_TAP_AUTOTIME is '0', also check
+ * errno because strtol() can return '0' on error.
+ */
+ errno = 0;
+ tap_autotime = strtol(autotime_env, NULL, 10);
+ if (tap_autotime == 0 && errno == 0) {
+ time_tests = 0;
+ }
+ }
+
run_once = 1;
}
+ lttng_clock_gettime(CLOCK_MONOTONIC, &last_time);
}
/*
printf("ok %d # skip %s\n",
test_count,
skip_msg != NULL ? skip_msg : "libtap():malloc() failed");
+ _output_test_time();
}
free(skip_msg);
return 1;
}
+void _output_test_time(void)
+{
+ struct timespec new_time;
+ int64_t time_ns;
+ if (time_tests) {
+ lttng_clock_gettime(CLOCK_MONOTONIC, &new_time);
+ time_ns = elapsed_time_ns(&last_time, &new_time);
+ printf(" ---\n duration_ms: %ld.%ld\n ...\n",
+ time_ns / 1000000,
+ time_ns % 1000000);
+ }
+ lttng_clock_gettime(CLOCK_MONOTONIC, &last_time);
+}
+
void todo_start(const char *fmt, ...)
{
va_list ap;