runtime: Fixed timestamps not being reported. Fixes #116

This commit is contained in:
Snaipe 2016-09-04 10:38:05 +02:00
parent 63d0bc8a4e
commit 7aa0b1c5ce
15 changed files with 144 additions and 192 deletions

View file

@ -23,13 +23,25 @@ endif ()
check_function_exists(strtok_s HAVE_STRTOK_S)
check_function_exists(strtok_r HAVE_STRTOK_R)
check_library_exists (rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
check_library_exists (anl getaddrinfo_a "" HAVE_GETADDRINFO_A)
check_function_exists(funopen HAVE_FUNOPEN)
check_function_exists(fopencookie HAVE_FOPENCOOKIE)
check_function_exists(open_memstream HAVE_OPEN_MEMSTREAM)
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME_RT)
if (HAVE_CLOCK_GETTIME_RT AND NOT HAVE_LIBRT)
set (HAVE_LIBRT 1)
endif ()
if (NOT HAVE_CLOCK_GETTIME_RT)
check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
else ()
set (HAVE_CLOCK_GETTIME "${HAVE_CLOCK_GETTIME_RT}" CACHE INTERNAL "Have symbol clock_gettime")
endif ()
check_symbol_exists(CLOCK_MONOTONIC_RAW "time.h" HAVE_CLOCK_MONOTONIC_RAW)
# Check for C++11
if (LANG_CXX)

View file

@ -113,7 +113,7 @@ cr_link_subproject(criterion wingetopt STATIC)
cr_link_subproject(criterion boxfort STATIC)
cr_link_libraries(criterion pthread IF NOT WIN32)
cr_link_libraries(criterion rt IF HAVE_CLOCK_GETTIME)
cr_link_libraries(criterion rt IF HAVE_LIBRT)
# Required by nanomsg
cr_link_libraries(criterion anl IF HAVE_GETADDRINFO_A)

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Criterion \n"
"Report-Msgid-Bugs-To: franklinmathieu+criterion@gmail.com\n"
"POT-Creation-Date: 2016-09-03 23:05+0200\n"
"POT-Creation-Date: 2016-09-04 10:11+0200\n"
"PO-Revision-Date: 2016-02-12 11:12+0100\n"
"Last-Translator: <a1lu@arcor.de>\n"
"Language-Team: German\n"
@ -28,7 +28,7 @@ msgstr "Criterion v%s\n"
msgid " %s\n"
msgstr " %s\n"
#: src/log/normal.c:46 src/log/normal.c:48
#: src/log/normal.c:46
#, c-format
msgid "%1$s::%2$s\n"
msgstr "%1$s::%2$s\n"
@ -38,45 +38,45 @@ msgstr "%1$s::%2$s\n"
msgid "%1$s::%2$s: (%3$3.2fs)\n"
msgstr "%1$s::%2$s: (%3$3.2fs)\n"
#: src/log/normal.c:49
#: src/log/normal.c:48
#, c-format
msgid "%1$s::%2$s: Test was skipped\n"
msgstr "%1$s::%2$s: Test wurde übersprungen\n"
#: src/log/normal.c:50
#: src/log/normal.c:49
#, c-format
msgid "%1$s%2$s%3$s:%4$s%5$d%6$s: Assertion failed: %7$s\n"
msgstr "%1$s%2$s%3$s:%4$s%5$d%6$s: Fehlerhafte Behauptung: %7$s\n"
#: src/log/normal.c:51
#: src/log/normal.c:50
#, c-format
msgid " Theory %1$s::%2$s failed with the following parameters: (%3$s)\n"
msgstr ""
" Hypothese %1$s::%2$s schlug fehl mit den folgenden Parametern: (%3$s)\n"
#: src/log/normal.c:52
#: src/log/normal.c:51
#, c-format
msgid "%1$s::%2$s: Timed out. (%3$3.2fs)\n"
msgstr "%1$s::%2$s: Außerhalb der Vorgabezeit. (%3$3.2fs)\n"
#: src/log/normal.c:53
#: src/log/normal.c:52
#, c-format
msgid "%1$s%2$s%3$s:%4$s%5$u%6$s: Unexpected signal caught below this line!\n"
msgstr ""
"%1$s%2$s%3$s:%4$s%5$u%6$s: Unerwartetes Signal gefangen unterhalb dieser "
"Zeile!\n"
#: src/log/normal.c:54
#: src/log/normal.c:53
#, c-format
msgid "%1$s::%2$s: CRASH!\n"
msgstr "%1$s::%2$s: ABSTURZ!\n"
#: src/log/normal.c:55
#: src/log/normal.c:54
#, c-format
msgid "%1$s::%2$s: %3$s\n"
msgstr "%1$s::%2$s: %3$s\n"
#: src/log/normal.c:56
#: src/log/normal.c:55
#, c-format
msgid ""
"%1$sWarning! The test `%2$s::%3$s` crashed during its setup or teardown."
@ -85,7 +85,7 @@ msgstr ""
"%1$sWarnung! Der Test `%2$s::%3$s` ist abgestürzt während der "
"Initialisierung oder Beendung %4$s\n"
#: src/log/normal.c:57
#: src/log/normal.c:56
#, c-format
msgid ""
"%1$sWarning! The test `%2$s::%3$s` exited during its setup or teardown.%4$s\n"
@ -93,14 +93,14 @@ msgstr ""
"%1$sWarnung! Der Test `%2$s::%3$s` hat sich beendet während der "
"Initialisierung oder Beendung.%4$s\n"
#: src/log/normal.c:58
#: src/log/normal.c:57
#, c-format
msgid "Running %1$s%2$lu%3$s test from %4$s%5$s%6$s:\n"
msgid_plural "Running %1$s%2$lu%3$s tests from %4$s%5$s%6$s:\n"
msgstr[0] "Führe %1$s%2$lu%3$s Test durch von %4$s%5$s%6$s:\n"
msgstr[1] "Führe %1$s%2$lu%3$s Tests durch von %4$s%5$s%6$s:\n"
#: src/log/normal.c:60
#: src/log/normal.c:59
#, c-format
msgid ""
"%1$sSynthesis: Tested: %2$s%3$lu%4$s | Passing: %5$s%6$lu%7$s | Failing: %8$s"

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: criterion 2.0.0\n"
"Report-Msgid-Bugs-To: franklinmathieu+criterion@gmail.com\n"
"POT-Creation-Date: 2016-09-03 23:05+0200\n"
"POT-Creation-Date: 2016-09-04 10:11+0200\n"
"PO-Revision-Date: 2015-04-03 17:58+0200\n"
"Last-Translator: <franklinmathieu@gmail.com>\n"
"Language-Team: French\n"
@ -28,7 +28,7 @@ msgstr "Criterion v%s\n"
msgid " %s\n"
msgstr " %s\n"
#: src/log/normal.c:46 src/log/normal.c:48
#: src/log/normal.c:46
#, c-format
msgid "%1$s::%2$s\n"
msgstr "%1$s::%2$s\n"
@ -38,45 +38,45 @@ msgstr "%1$s::%2$s\n"
msgid "%1$s::%2$s: (%3$3.2fs)\n"
msgstr "%1$s::%2$s: (%3$3.2fs)\n"
#: src/log/normal.c:49
#: src/log/normal.c:48
#, c-format
msgid "%1$s::%2$s: Test was skipped\n"
msgstr "%1$s::%2$s: Le test a été sauté\n"
#: src/log/normal.c:50
#: src/log/normal.c:49
#, c-format
msgid "%1$s%2$s%3$s:%4$s%5$d%6$s: Assertion failed: %7$s\n"
msgstr "%1$s%2$s%3$s:%4$s%5$d%6$s: Échec d'assertion: %7$s\n"
#: src/log/normal.c:51
#: src/log/normal.c:50
#, fuzzy, c-format
msgid " Theory %1$s::%2$s failed with the following parameters: (%3$s)\n"
msgstr ""
" La théorie %1$s::%2$s a échoué avec les paramètres suivants: (%3$s)\n"
#: src/log/normal.c:52
#: src/log/normal.c:51
#, fuzzy, c-format
msgid "%1$s::%2$s: Timed out. (%3$3.2fs)\n"
msgstr "%1$s::%2$s: Délai expiré. (%3$3.2fs)\n"
#: src/log/normal.c:53
#: src/log/normal.c:52
#, c-format
msgid "%1$s%2$s%3$s:%4$s%5$u%6$s: Unexpected signal caught below this line!\n"
msgstr ""
"%1$s%2$s%3$s:%4$s%5$u%6$s: Un signal inattendu a été reçu après cette "
"ligne!\n"
#: src/log/normal.c:54
#: src/log/normal.c:53
#, c-format
msgid "%1$s::%2$s: CRASH!\n"
msgstr "%1$s::%2$s: PLANTAGE!\n"
#: src/log/normal.c:55
#: src/log/normal.c:54
#, fuzzy, c-format
msgid "%1$s::%2$s: %3$s\n"
msgstr "%1$s::%2$s: (%3$3.2fs)\n"
#: src/log/normal.c:56
#: src/log/normal.c:55
#, fuzzy, c-format
msgid ""
"%1$sWarning! The test `%2$s::%3$s` crashed during its setup or teardown."
@ -85,7 +85,7 @@ msgstr ""
"%1$sAttention! Le test `%2$s::%3$s` a planté pendant son initialisation ou "
"sa finalisation.%4$s\n"
#: src/log/normal.c:57
#: src/log/normal.c:56
#, fuzzy, c-format
msgid ""
"%1$sWarning! The test `%2$s::%3$s` exited during its setup or teardown.%4$s\n"
@ -93,14 +93,14 @@ msgstr ""
"%1$sAttention! Le test `%2$s::%3$s` a quitté pendant son initialisation ou "
"sa finalisation.%4$s\n"
#: src/log/normal.c:58
#: src/log/normal.c:57
#, c-format
msgid "Running %1$s%2$lu%3$s test from %4$s%5$s%6$s:\n"
msgid_plural "Running %1$s%2$lu%3$s tests from %4$s%5$s%6$s:\n"
msgstr[0] "Lancement de %1$s%2$lu%3$s test dans %4$s%5$s%6$s:\n"
msgstr[1] "Lancement de %1$s%2$lu%3$s tests dans %4$s%5$s%6$s:\n"
#: src/log/normal.c:60
#: src/log/normal.c:59
#, c-format
msgid ""
"%1$sSynthesis: Tested: %2$s%3$lu%4$s | Passing: %5$s%6$lu%7$s | Failing: %8$s"

View file

@ -1,49 +1,68 @@
/*
* The MIT License (MIT)
*
* Copyright © 2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <errno.h>
#include <inttypes.h>
#include <stdlib.h>
#include "criterion/internal/common.h"
#include "criterion/options.h"
#include "compat/time.h"
#include "compat/posix.h"
#define GIGA 1000000000
#include "config.h"
#include "time.h"
#if defined(__unix__) && !defined(__CYGWIN__) && !defined(__OpenBSD__)
#define KILO 1000ull
#define MEGA (KILO * 1000ull)
#define GIGA (MEGA * 1000ull)
# ifdef CLOCK_MONOTONIC_RAW
#if defined(HAVE_GETTIMEOFDAY)
# include <sys/time.h>
#endif
#if defined(HAVE_CLOCK_GETTIME)
# include <time.h>
#endif
#if defined(__APPLE__)
# include <mach/clock.h>
# include <mach/mach.h>
# include <pthread.h>
#endif
#if defined(_WIN32) || defined(__CYGWIN__)
# include <windows.h>
#endif
#if defined(HAVE_CLOCK_GETTIME)
# if defined(HAVE_CLOCK_MONOTONIC_RAW)
# define CLOCK CLOCK_MONOTONIC_RAW
# else
# define CLOCK CLOCK_MONOTONIC
# endif
#endif
extern __attribute__ ((weak)) int clock_gettime(clockid_t, struct timespec *);
#elif defined(__OpenBSD__)
# include <pthread.h>
# define CLOCK CLOCK_MONOTONIC
uint64_t cri_timestamp_monotonic(void)
{
#if defined(HAVE_CLOCK_GETTIME)
struct timespec now;
clock_gettime(CLOCK, &now);
return now.tv_sec * GIGA + now.tv_nsec;
#elif defined(__APPLE__)
# include <mach/clock.h>
# include <mach/mach.h>
# include <pthread.h>
#elif defined(_WIN32) || defined(__CYGWIN__)
# define VC_EXTRALEAN
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
bool can_measure_time(void) {
if (!criterion_options.measure_time)
return false;
#if defined(__unix__) && !defined(__CYGWIN__) && !defined(__OpenBSD__)
return clock_gettime != NULL;
#else
return true;
#endif
}
int gettime_compat(struct timespec_compat *ts) {
#if defined(__APPLE__)
clock_serv_t cclock;
mach_timespec_t mts;
@ -51,106 +70,18 @@ int gettime_compat(struct timespec_compat *ts) {
int res = clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock);
*ts = (struct timespec_compat) { mts.tv_sec, mts.tv_nsec };
return res > 0 ? -1 : 0;
return mts.tv_sec * GIGA + mts.tv_nsec;
#elif defined(_WIN32) || defined(__CYGWIN__)
LARGE_INTEGER freq, count;
if (!QueryPerformanceFrequency(&freq)
|| !QueryPerformanceCounter(&count))
return -1;
int64_t sec = count.QuadPart / freq.QuadPart;
int64_t nano = (int64_t) ((double) count.QuadPart * GIGA / (double) freq.QuadPart) % GIGA;
*ts = (struct timespec_compat) { sec, nano };
return 0;
#elif defined(__unix__)
if (!can_measure_time()) {
errno = ENOTSUP;
return -1;
}
struct timespec ts_;
int res = clock_gettime(CLOCK, &ts_);
*ts = (struct timespec_compat) { ts_.tv_sec, ts_.tv_nsec };
return res;
#else
return -1;
#endif
}
int timer_start(struct timespec_compat *state) {
return gettime_compat(state) == -1 ? 0 : 1;
}
int timer_end(double *time, struct timespec_compat *state) {
struct timespec_compat last;
if (gettime_compat(&last) == -1)
return 0;
*time = (last.tv_sec - state->tv_sec) + (last.tv_nsec - state->tv_nsec) / (double) GIGA;
return 1;
}
#if defined(_WIN32) || defined(__CYGWIN__)
DWORD WINAPI win_raise_timeout(LPVOID ptr) {
uint64_t *nanos = (uint64_t*) ptr;
Sleep(*nanos / 1000000);
TerminateProcess(GetCurrentProcess(), CR_EXCEPTION_TIMEOUT);
return 0;
}
#endif
#if defined(__APPLE__) || defined(__OpenBSD__)
void *wait_and_raise(void *ptr) {
uint64_t *nanos = ptr;
struct timespec elapsed = {
.tv_sec = *nanos / GIGA,
.tv_nsec = *nanos % GIGA,
};
free(nanos);
if (!nanosleep(&elapsed, NULL))
raise(SIGPROF);
return NULL;
}
#endif
int setup_timeout(uint64_t nanos) {
#if defined(__APPLE__) || defined(__OpenBSD__)
uint64_t *nanos_copy = malloc(sizeof (uint64_t));
*nanos_copy = nanos;
pthread_t thread;
int res = pthread_create(&thread, NULL, wait_and_raise, nanos_copy);
return res ? -1 : 0;
#elif defined(_WIN32) || defined(__CYGWIN__)
uint64_t *nanos_copy = malloc(sizeof (uint64_t));
*nanos_copy = nanos;
HANDLE thread = CreateThread(NULL, 0, win_raise_timeout, nanos_copy, 0, NULL);
if (thread == NULL)
return -1;
CloseHandle(thread);
return 0;
#elif defined(__unix__)
timer_t timer;
int res = timer_create(CLOCK_MONOTONIC, &(struct sigevent) {
.sigev_notify = SIGEV_SIGNAL,
.sigev_signo = SIGPROF,
}, &timer);
if (res == -1)
return res;
struct itimerspec schedule = {
.it_value = { .tv_sec = nanos / GIGA, .tv_nsec = (nanos % GIGA) }
};
return timer_settime(timer, 0, &schedule, NULL);
uint64_t sec = count.QuadPart / freq.QuadPart;
uint64_t nano = ((count.QuadPart * GIGA) / freq.QuadPart) % GIGA;
return sec * GIGA + nano;
#else
errno = ENOTSUP;
return -1;
return (uint64_t) -1;
#endif
}

View file

@ -24,19 +24,8 @@
#ifndef TIMER_H_
# define TIMER_H_
# include <signal.h>
# include <time.h>
# include <inttypes.h>
# include <stdbool.h>
# include <stdint.h>
struct timespec_compat {
int64_t tv_sec;
int64_t tv_nsec;
};
bool can_measure_time(void);
int timer_start(struct timespec_compat *state);
int timer_end(double *time, struct timespec_compat *state);
int setup_timeout(uint64_t nanos);
uint64_t cri_timestamp_monotonic(void);
#endif /* !TIMER_H_ */

View file

@ -10,6 +10,8 @@
#cmakedefine HAVE_FUNOPEN @HAVE_FUNOPEN@
#cmakedefine HAVE_FOPENCOOKIE @HAVE_FOPENCOOKIE@
#cmakedefine HAVE_OPEN_MEMSTREAM @HAVE_OPEN_MEMSTREAM@
#cmakedefine HAVE_CLOCK_GETTIME @HAVE_CLOCK_GETTIME@
#cmakedefine HAVE_CLOCK_MONOTONIC_RAW @HAVE_CLOCK_MONOTONIC_RAW@
# define LOCALEDIR "${LOCALEDIR}"
# define PACKAGE "${PROJECT_NAME}"

View file

@ -237,6 +237,18 @@ static void death_callback(bxf_instance *instance)
? instance->status.signal
: instance->status.exit;
if (instance->status.timed_out) {
criterion_protocol_msg msg = criterion_message(phase,
.phase = criterion_protocol_phase_kind_TIMEOUT,
);
msg.id.pid = instance->pid;
cr_send_to_runner(&msg);
result = criterion_protocol_death_result_type_NORMAL;
code = 0;
}
criterion_protocol_msg msg = criterion_message(death,
.result = result,
.has_status = true,

View file

@ -71,9 +71,7 @@ void criterion_internal_test_main(void (*fn)(void)) {
send_event(criterion_protocol_phase_kind_MAIN);
struct timespec_compat ts;
if (!setjmp(g_pre_test)) {
timer_start(&ts);
if (!test->data->param_) {
fn();
} else {
@ -82,10 +80,6 @@ void criterion_internal_test_main(void (*fn)(void)) {
}
}
double elapsed_time;
if (!timer_end(&elapsed_time, &ts))
elapsed_time = -1;
send_event(criterion_protocol_phase_kind_TEARDOWN);
}

View file

@ -50,8 +50,7 @@ static void print_pre_suite(FILE *f, struct criterion_suite_stats *stats) {
static void print_test_normal(FILE *f, struct criterion_test_stats *stats) {
const char *format = can_measure_time() ? "%s - %s::%s %s (%3.2fs)\n"
: "%s - %s::%s %s\n";
const char *format = "%s - %s::%s %s (%3.2fs)\n";
fprintf(f, format,
stats->test_status == CR_STATUS_FAILED ? "not ok" : "ok",
stats->test->category,

View file

@ -45,7 +45,6 @@ static msg_t msg_desc = N_(" %s\n");
#ifdef ENABLE_NLS
static msg_t msg_pre_init = N_("%1$s::%2$s\n");
static msg_t msg_post_test_timed = N_("%1$s::%2$s: (%3$3.2fs)\n");
static msg_t msg_post_test = N_("%1$s::%2$s\n");
static msg_t msg_post_test_skip = N_("%1$s::%2$s: Test was skipped\n");
static msg_t msg_assert_fail = N_("%1$s%2$s%3$s:%4$s%5$d%6$s: Assertion failed: %7$s\n");
static msg_t msg_theory_fail = N_(" Theory %1$s::%2$s failed with the following parameters: (%3$s)\n");
@ -65,7 +64,6 @@ static msg_t msg_post_all = N_("%1$sSynthesis: Tested: %2$s%3$lu%4$s "
#else
static msg_t msg_pre_init = "%s::%s\n";
static msg_t msg_post_test_timed = "%s::%s: (%3.2fs)\n";
static msg_t msg_post_test = "%s::%s\n";
static msg_t msg_post_test_skip = "%1$s::%2$s: Test was skipped\n";
static msg_t msg_assert_fail = "%s%s%s:%s%d%s: Assertion failed: %s\n";
static msg_t msg_theory_fail = " Theory %s::%s failed with the following parameters: (%s)\n";
@ -99,7 +97,7 @@ void normal_log_pre_init(struct criterion_test *test) {
}
void normal_log_post_test(struct criterion_test_stats *stats) {
const char *format = can_measure_time() ? msg_post_test_timed : msg_post_test;
const char *format = msg_post_test_timed;
const enum criterion_logging_level level
= stats->test_status == CR_STATUS_FAILED ? CRITERION_IMPORTANT : CRITERION_INFO;

View file

@ -1,5 +1,5 @@
/* Automatically generated nanopb constant definitions */
/* Generated by nanopb-0.3.5-dev at Mon Aug 8 22:00:27 2016. */
/* Generated by nanopb-0.3.5-dev at Sun Sep 4 10:10:57 2016. */
#include "criterion.pb.h"
@ -31,17 +31,19 @@ const pb_field_t criterion_protocol_death_fields[4] = {
PB_LAST_FIELD
};
const pb_field_t criterion_protocol_assert_fields[5] = {
const pb_field_t criterion_protocol_assert_fields[6] = {
PB_FIELD( 1, STRING , REQUIRED, POINTER , FIRST, criterion_protocol_assert, message, message, 0),
PB_FIELD( 2, BOOL , REQUIRED, STATIC , OTHER, criterion_protocol_assert, passed, message, 0),
PB_FIELD( 3, STRING , OPTIONAL, POINTER , OTHER, criterion_protocol_assert, file, passed, 0),
PB_FIELD( 4, INT64 , OPTIONAL, STATIC , OTHER, criterion_protocol_assert, line, file, 0),
PB_FIELD( 5, INT64 , OPTIONAL, STATIC , OTHER, criterion_protocol_assert, timestamp, line, 0),
PB_LAST_FIELD
};
const pb_field_t criterion_protocol_log_fields[3] = {
const pb_field_t criterion_protocol_log_fields[4] = {
PB_FIELD( 1, UENUM , REQUIRED, STATIC , FIRST, criterion_protocol_log, severity, severity, 0),
PB_FIELD( 2, STRING , REQUIRED, POINTER , OTHER, criterion_protocol_log, message, severity, 0),
PB_FIELD( 3, INT64 , OPTIONAL, STATIC , OTHER, criterion_protocol_log, timestamp, message, 0),
PB_LAST_FIELD
};

View file

@ -1,5 +1,5 @@
/* Automatically generated nanopb header */
/* Generated by nanopb-0.3.5-dev at Mon Aug 8 22:00:27 2016. */
/* Generated by nanopb-0.3.5-dev at Sun Sep 4 10:10:57 2016. */
#ifndef PB_CRITERION_PB_H_INCLUDED
#define PB_CRITERION_PB_H_INCLUDED
@ -52,6 +52,8 @@ typedef struct _criterion_protocol_assert {
char *file;
bool has_line;
int64_t line;
bool has_timestamp;
int64_t timestamp;
} criterion_protocol_assert;
typedef struct _criterion_protocol_birth {
@ -71,6 +73,8 @@ typedef struct _criterion_protocol_death {
typedef struct _criterion_protocol_log {
criterion_protocol_log_level severity;
char *message;
bool has_timestamp;
int64_t timestamp;
} criterion_protocol_log;
typedef struct _criterion_protocol_phase {
@ -109,16 +113,16 @@ extern const int32_t criterion_protocol_msg_version_default;
#define criterion_protocol_birth_init_default {NULL, false, 0}
#define criterion_protocol_phase_init_default {(criterion_protocol_phase_kind)0, NULL, false, 0, NULL}
#define criterion_protocol_death_init_default {(criterion_protocol_death_result_type)0, false, 0, false, 0}
#define criterion_protocol_assert_init_default {NULL, 0, NULL, false, 0}
#define criterion_protocol_log_init_default {(criterion_protocol_log_level)0, NULL}
#define criterion_protocol_assert_init_default {NULL, 0, NULL, false, 0, false, 0}
#define criterion_protocol_log_init_default {(criterion_protocol_log_level)0, NULL, false, 0}
#define criterion_protocol_ack_init_default {(criterion_protocol_ack_status)0, NULL}
#define criterion_protocol_submessage_init_default {0, {criterion_protocol_birth_init_default}}
#define criterion_protocol_msg_init_default {1, 0, {0}, criterion_protocol_submessage_init_default}
#define criterion_protocol_birth_init_zero {NULL, false, 0}
#define criterion_protocol_phase_init_zero {(criterion_protocol_phase_kind)0, NULL, false, 0, NULL}
#define criterion_protocol_death_init_zero {(criterion_protocol_death_result_type)0, false, 0, false, 0}
#define criterion_protocol_assert_init_zero {NULL, 0, NULL, false, 0}
#define criterion_protocol_log_init_zero {(criterion_protocol_log_level)0, NULL}
#define criterion_protocol_assert_init_zero {NULL, 0, NULL, false, 0, false, 0}
#define criterion_protocol_log_init_zero {(criterion_protocol_log_level)0, NULL, false, 0}
#define criterion_protocol_ack_init_zero {(criterion_protocol_ack_status)0, NULL}
#define criterion_protocol_submessage_init_zero {0, {criterion_protocol_birth_init_zero}}
#define criterion_protocol_msg_init_zero {0, 0, {0}, criterion_protocol_submessage_init_zero}
@ -130,6 +134,7 @@ extern const int32_t criterion_protocol_msg_version_default;
#define criterion_protocol_assert_passed_tag 2
#define criterion_protocol_assert_file_tag 3
#define criterion_protocol_assert_line_tag 4
#define criterion_protocol_assert_timestamp_tag 5
#define criterion_protocol_birth_name_tag 1
#define criterion_protocol_birth_timestamp_tag 2
#define criterion_protocol_death_result_tag 1
@ -137,6 +142,7 @@ extern const int32_t criterion_protocol_msg_version_default;
#define criterion_protocol_death_timestamp_tag 3
#define criterion_protocol_log_severity_tag 1
#define criterion_protocol_log_message_tag 2
#define criterion_protocol_log_timestamp_tag 3
#define criterion_protocol_phase_phase_tag 1
#define criterion_protocol_phase_name_tag 2
#define criterion_protocol_phase_timestamp_tag 3
@ -155,8 +161,8 @@ extern const int32_t criterion_protocol_msg_version_default;
extern const pb_field_t criterion_protocol_birth_fields[3];
extern const pb_field_t criterion_protocol_phase_fields[5];
extern const pb_field_t criterion_protocol_death_fields[4];
extern const pb_field_t criterion_protocol_assert_fields[5];
extern const pb_field_t criterion_protocol_log_fields[3];
extern const pb_field_t criterion_protocol_assert_fields[6];
extern const pb_field_t criterion_protocol_log_fields[4];
extern const pb_field_t criterion_protocol_ack_fields[3];
extern const pb_field_t criterion_protocol_submessage_fields[6];
extern const pb_field_t criterion_protocol_msg_fields[5];

View file

@ -41,6 +41,7 @@ message assert {
required bool passed = 2;
optional string file = 3;
optional int64 line = 4;
optional int64 timestamp = 5;
}
message log {
@ -52,6 +53,7 @@ message log {
required level severity = 1;
required string message = 2;
optional int64 timestamp = 3;
}
message ack {

View file

@ -30,6 +30,7 @@
# include "criterion.pb.h"
# include "criterion/internal/preprocess.h"
# include "compat/process.h"
# include "compat/time.h"
enum protocol_version {
PROTOCOL_V1 = 1,
@ -55,7 +56,11 @@ extern volatile bool is_extern_worker;
.data = { \
.which_value = criterion_protocol_submessage_ ## Kind ## _tag, \
.value = { \
.Kind = { __VA_ARGS__ }, \
.Kind = { \
.timestamp = cri_timestamp_monotonic(), \
.has_timestamp = true, \
__VA_ARGS__ \
}, \
} \
} \
}