31#if !defined(MUNIT_OUTPUT_FILE)
32# define MUNIT_OUTPUT_FILE stdout
39#if !defined(MUNIT_TEST_TIME_FORMAT)
40# define MUNIT_TEST_TIME_FORMAT "0.8f"
45#if !defined(MUNIT_TEST_NAME_LEN)
46# define MUNIT_TEST_NAME_LEN 60
51#if !defined(MUNIT_DISABLE_TIMING)
52# define MUNIT_ENABLE_TIMING
57#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE < 200809L)
58# undef _POSIX_C_SOURCE
60#if !defined(_POSIX_C_SOURCE)
61# define _POSIX_C_SOURCE 200809L
66#if defined(_XOPEN_SOURCE)
70#if defined(__STDC_VERSION__)
71# if __STDC_VERSION__ >= 201112L
72# define _XOPEN_SOURCE 700
73# elif __STDC_VERSION__ >= 199901L
74# define _XOPEN_SOURCE 600
80#if defined(_MSC_VER) && !defined(_CRT_NONSTDC_NO_DEPRECATE)
81# define _CRT_NONSTDC_NO_DEPRECATE
84#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
101#if !defined(MUNIT_NO_NL_LANGINFO) && !defined(_WIN32)
102#define MUNIT_NL_LANGINFO
113# include <sys/types.h>
114# include <sys/wait.h>
120# if !defined(STDERR_FILENO)
121# define STDERR_FILENO _fileno(stderr)
127#define MUNIT_STRINGIFY(x) #x
128#define MUNIT_XSTRINGIFY(x) MUNIT_STRINGIFY(x)
130#if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__SUNPRO_CC) || defined(__IBMCPP__)
131# define MUNIT_THREAD_LOCAL __thread
132#elif (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201102L)) || defined(_Thread_local)
133# define MUNIT_THREAD_LOCAL _Thread_local
135# define MUNIT_THREAD_LOCAL __declspec(thread)
141#if defined(_MSC_VER) && (_MSC_VER <= 1800)
142#pragma warning(disable: 4127)
145#if defined(_WIN32) || defined(__EMSCRIPTEN__)
146# define MUNIT_NO_FORK
149#if defined(__EMSCRIPTEN__)
150# define MUNIT_NO_BUFFER
158#if defined(MUNIT_THREAD_LOCAL)
159static MUNIT_THREAD_LOCAL
munit_bool munit_error_jmp_buf_valid = 0;
160static MUNIT_THREAD_LOCAL jmp_buf munit_error_jmp_buf;
169#if defined(__MINGW32__) || defined(__MINGW64__)
170# pragma GCC diagnostic push
171# pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
176munit_logf_exv(
MunitLogLevel level, FILE *
fp, const
char *filename,
int line, const
char *format, va_list ap) {
177 if (level < munit_log_level_visible)
188 fputs(
"Warning",
fp);
199 if (filename != NULL)
200 fprintf(
fp,
"%s:%d: ", filename, line);
201 vfprintf(
fp, format, ap);
207munit_logf_internal(
MunitLogLevel level, FILE *
fp, const
char *format, ...) {
210 va_start(ap, format);
211 munit_logf_exv(level,
fp, NULL, 0, format, ap);
216munit_log_internal(
MunitLogLevel level, FILE *
fp,
const char *message) {
217 munit_logf_internal(level,
fp,
"%s", message);
224 va_start(ap, format);
225 munit_logf_exv(level, stderr, filename, line, format, ap);
228 if (level >= munit_log_level_fatal) {
229#if defined(MUNIT_THREAD_LOCAL)
230 if (munit_error_jmp_buf_valid)
231 longjmp(munit_error_jmp_buf, 1);
241 va_start(ap, format);
245#if defined(MUNIT_THREAD_LOCAL)
246 if (munit_error_jmp_buf_valid)
247 longjmp(munit_error_jmp_buf, 1);
252#if defined(__MINGW32__) || defined(__MINGW64__)
253#pragma GCC diagnostic pop
256#if !defined(MUNIT_STRERROR_LEN)
257# define MUNIT_STRERROR_LEN 80
262#if defined(MUNIT_NO_STRERROR_R) || (defined(__MINGW32__) && !defined(MINGW_HAS_SECURE_API))
263 munit_logf_internal(level,
fp,
"%s: %s (%d)", msg, strerror(errno), errno);
266 munit_error_str[0] =
'\0';
274 munit_logf_internal(level,
fp,
"%s: %s (%d)", msg, munit_error_str, errno);
287 ptr = calloc(1, size);
297#if defined(MUNIT_ENABLE_TIMING)
299#define psnip_uint64_t munit_uint64_t
300#define psnip_uint32_t munit_uint32_t
317#if !defined(PSNIP_CLOCK_H)
320#if !defined(psnip_uint64_t)
321# include "../exact-int/exact-int.h"
324#if !defined(PSNIP_CLOCK_STATIC_INLINE)
325# if defined(__GNUC__)
326# define PSNIP_CLOCK__COMPILER_ATTRIBUTES __attribute__((__unused__))
328# define PSNIP_CLOCK__COMPILER_ATTRIBUTES
331# define PSNIP_CLOCK__FUNCTION PSNIP_CLOCK__COMPILER_ATTRIBUTES static
357#define PSNIP_CLOCK_METHOD_CLOCK_GETTIME 1
358#define PSNIP_CLOCK_METHOD_TIME 2
359#define PSNIP_CLOCK_METHOD_GETTIMEOFDAY 3
360#define PSNIP_CLOCK_METHOD_QUERYPERFORMANCECOUNTER 4
361#define PSNIP_CLOCK_METHOD_MACH_ABSOLUTE_TIME 5
362#define PSNIP_CLOCK_METHOD_CLOCK 6
363#define PSNIP_CLOCK_METHOD_GETPROCESSTIMES 7
364#define PSNIP_CLOCK_METHOD_GETRUSAGE 8
365#define PSNIP_CLOCK_METHOD_GETSYSTEMTIMEPRECISEASFILETIME 9
366#define PSNIP_CLOCK_METHOD_GETTICKCOUNT64 10
370#if defined(HEDLEY_UNREACHABLE)
371# define PSNIP_CLOCK_UNREACHABLE() HEDLEY_UNREACHABLE()
373# define PSNIP_CLOCK_UNREACHABLE() assert(0)
385#if defined(__unix__) || defined(__unix) || defined(__linux__)
392#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0)
396 (defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 17))) || \
397 (defined(__FreeBSD__))
398# define PSNIP_CLOCK_HAVE_CLOCK_GETTIME
399# elif !defined(PSNIP_CLOCK_NO_LIBRT)
400# define PSNIP_CLOCK_HAVE_CLOCK_GETTIME
405# if !defined(PSNIP_CLOCK_CPU_METHOD)
406# define PSNIP_CLOCK_CPU_METHOD PSNIP_CLOCK_METHOD_GETPROCESSTIMES
408# if !defined(PSNIP_CLOCK_MONOTONIC_METHOD)
409# define PSNIP_CLOCK_MONOTONIC_METHOD PSNIP_CLOCK_METHOD_QUERYPERFORMANCECOUNTER
413#if defined(__MACH__) && !defined(__gnu_hurd__)
414# if !defined(PSNIP_CLOCK_MONOTONIC_METHOD)
415# define PSNIP_CLOCK_MONOTONIC_METHOD PSNIP_CLOCK_METHOD_MACH_ABSOLUTE_TIME
419#if defined(PSNIP_CLOCK_HAVE_CLOCK_GETTIME)
423# if !defined(PSNIP_CLOCK_WALL_METHOD)
424# if defined(CLOCK_REALTIME_PRECISE)
425# define PSNIP_CLOCK_WALL_METHOD PSNIP_CLOCK_METHOD_CLOCK_GETTIME
426# define PSNIP_CLOCK_CLOCK_GETTIME_WALL CLOCK_REALTIME_PRECISE
427# elif !defined(__sun)
428# define PSNIP_CLOCK_WALL_METHOD PSNIP_CLOCK_METHOD_CLOCK_GETTIME
429# define PSNIP_CLOCK_CLOCK_GETTIME_WALL CLOCK_REALTIME
432# if !defined(PSNIP_CLOCK_CPU_METHOD)
433# if defined(_POSIX_CPUTIME) || defined(CLOCK_PROCESS_CPUTIME_ID)
434# define PSNIP_CLOCK_CPU_METHOD PSNIP_CLOCK_METHOD_CLOCK_GETTIME
435# define PSNIP_CLOCK_CLOCK_GETTIME_CPU CLOCK_PROCESS_CPUTIME_ID
436# elif defined(CLOCK_VIRTUAL)
437# define PSNIP_CLOCK_CPU_METHOD PSNIP_CLOCK_METHOD_CLOCK_GETTIME
438# define PSNIP_CLOCK_CLOCK_GETTIME_CPU CLOCK_VIRTUAL
441# if !defined(PSNIP_CLOCK_MONOTONIC_METHOD)
442# if defined(CLOCK_MONOTONIC_RAW)
443# define PSNIP_CLOCK_MONOTONIC_METHOD PSNIP_CLOCK_METHOD_CLOCK_GETTIME
444# define PSNIP_CLOCK_CLOCK_GETTIME_MONOTONIC CLOCK_MONOTONIC
445# elif defined(CLOCK_MONOTONIC_PRECISE)
446# define PSNIP_CLOCK_MONOTONIC_METHOD PSNIP_CLOCK_METHOD_CLOCK_GETTIME
447# define PSNIP_CLOCK_CLOCK_GETTIME_MONOTONIC CLOCK_MONOTONIC_PRECISE
448# elif defined(_POSIX_MONOTONIC_CLOCK) || defined(CLOCK_MONOTONIC)
449# define PSNIP_CLOCK_MONOTONIC_METHOD PSNIP_CLOCK_METHOD_CLOCK_GETTIME
450# define PSNIP_CLOCK_CLOCK_GETTIME_MONOTONIC CLOCK_MONOTONIC
455#if defined(_POSIX_VERSION) && (_POSIX_VERSION >= 200112L)
456# if !defined(PSNIP_CLOCK_WALL_METHOD)
457# define PSNIP_CLOCK_WALL_METHOD PSNIP_CLOCK_METHOD_GETTIMEOFDAY
461#if !defined(PSNIP_CLOCK_WALL_METHOD)
462# define PSNIP_CLOCK_WALL_METHOD PSNIP_CLOCK_METHOD_TIME
465#if !defined(PSNIP_CLOCK_CPU_METHOD)
466# define PSNIP_CLOCK_CPU_METHOD PSNIP_CLOCK_METHOD_CLOCK
470#if !defined(PSNIP_CLOCK_MONOTONIC_METHOD) && defined(PSNIP_CLOCK_REQUIRE_MONOTONIC)
471# error No monotonic clock found.
477 (defined(PSNIP_CLOCK_CPU_METHOD) && (PSNIP_CLOCK_CPU_METHOD == PSNIP_CLOCK_METHOD_CLOCK_GETTIME)) || \
478 (defined(PSNIP_CLOCK_WALL_METHOD) && (PSNIP_CLOCK_WALL_METHOD == PSNIP_CLOCK_METHOD_CLOCK_GETTIME)) || \
479 (defined(PSNIP_CLOCK_MONOTONIC_METHOD) && (PSNIP_CLOCK_MONOTONIC_METHOD == PSNIP_CLOCK_METHOD_CLOCK_GETTIME)) || \
480 (defined(PSNIP_CLOCK_CPU_METHOD) && (PSNIP_CLOCK_CPU_METHOD == PSNIP_CLOCK_METHOD_CLOCK)) || \
481 (defined(PSNIP_CLOCK_WALL_METHOD) && (PSNIP_CLOCK_WALL_METHOD == PSNIP_CLOCK_METHOD_CLOCK)) || \
482 (defined(PSNIP_CLOCK_MONOTONIC_METHOD) && (PSNIP_CLOCK_MONOTONIC_METHOD == PSNIP_CLOCK_METHOD_CLOCK)) || \
483 (defined(PSNIP_CLOCK_CPU_METHOD) && (PSNIP_CLOCK_CPU_METHOD == PSNIP_CLOCK_METHOD_TIME)) || \
484 (defined(PSNIP_CLOCK_WALL_METHOD) && (PSNIP_CLOCK_WALL_METHOD == PSNIP_CLOCK_METHOD_TIME)) || \
485 (defined(PSNIP_CLOCK_MONOTONIC_METHOD) && (PSNIP_CLOCK_MONOTONIC_METHOD == PSNIP_CLOCK_METHOD_TIME))
492 (defined(PSNIP_CLOCK_CPU_METHOD) && (PSNIP_CLOCK_CPU_METHOD == PSNIP_CLOCK_METHOD_GETTIMEOFDAY)) || \
493 (defined(PSNIP_CLOCK_WALL_METHOD) && (PSNIP_CLOCK_WALL_METHOD == PSNIP_CLOCK_METHOD_GETTIMEOFDAY)) || \
494 (defined(PSNIP_CLOCK_MONOTONIC_METHOD) && (PSNIP_CLOCK_MONOTONIC_METHOD == PSNIP_CLOCK_METHOD_GETTIMEOFDAY))
495# include <sys/time.h>
499 (defined(PSNIP_CLOCK_CPU_METHOD) && (PSNIP_CLOCK_CPU_METHOD == PSNIP_CLOCK_METHOD_GETPROCESSTIMES)) || \
500 (defined(PSNIP_CLOCK_WALL_METHOD) && (PSNIP_CLOCK_WALL_METHOD == PSNIP_CLOCK_METHOD_GETPROCESSTIMES)) || \
501 (defined(PSNIP_CLOCK_MONOTONIC_METHOD) && (PSNIP_CLOCK_MONOTONIC_METHOD == PSNIP_CLOCK_METHOD_GETPROCESSTIMES)) || \
502 (defined(PSNIP_CLOCK_CPU_METHOD) && (PSNIP_CLOCK_CPU_METHOD == PSNIP_CLOCK_METHOD_GETTICKCOUNT64)) || \
503 (defined(PSNIP_CLOCK_WALL_METHOD) && (PSNIP_CLOCK_WALL_METHOD == PSNIP_CLOCK_METHOD_GETTICKCOUNT64)) || \
504 (defined(PSNIP_CLOCK_MONOTONIC_METHOD) && (PSNIP_CLOCK_MONOTONIC_METHOD == PSNIP_CLOCK_METHOD_GETTICKCOUNT64))
509 (defined(PSNIP_CLOCK_CPU_METHOD) && (PSNIP_CLOCK_CPU_METHOD == PSNIP_CLOCK_METHOD_GETRUSAGE)) || \
510 (defined(PSNIP_CLOCK_WALL_METHOD) && (PSNIP_CLOCK_WALL_METHOD == PSNIP_CLOCK_METHOD_GETRUSAGE)) || \
511 (defined(PSNIP_CLOCK_MONOTONIC_METHOD) && (PSNIP_CLOCK_MONOTONIC_METHOD == PSNIP_CLOCK_METHOD_GETRUSAGE))
512# include <sys/time.h>
513# include <sys/resource.h>
517 (defined(PSNIP_CLOCK_CPU_METHOD) && (PSNIP_CLOCK_CPU_METHOD == PSNIP_CLOCK_METHOD_MACH_ABSOLUTE_TIME)) || \
518 (defined(PSNIP_CLOCK_WALL_METHOD) && (PSNIP_CLOCK_WALL_METHOD == PSNIP_CLOCK_METHOD_MACH_ABSOLUTE_TIME)) || \
519 (defined(PSNIP_CLOCK_MONOTONIC_METHOD) && (PSNIP_CLOCK_MONOTONIC_METHOD == PSNIP_CLOCK_METHOD_MACH_ABSOLUTE_TIME))
520# include <CoreServices/CoreServices.h>
521# include <mach/mach.h>
522# include <mach/mach_time.h>
527#define PSNIP_CLOCK_NSEC_PER_SEC ((psnip_uint32_t) (1000000000ULL))
530 (defined(PSNIP_CLOCK_CPU_METHOD) && (PSNIP_CLOCK_CPU_METHOD == PSNIP_CLOCK_METHOD_CLOCK_GETTIME)) || \
531 (defined(PSNIP_CLOCK_WALL_METHOD) && (PSNIP_CLOCK_WALL_METHOD == PSNIP_CLOCK_METHOD_CLOCK_GETTIME)) || \
532 (defined(PSNIP_CLOCK_MONOTONIC_METHOD) && (PSNIP_CLOCK_MONOTONIC_METHOD == PSNIP_CLOCK_METHOD_CLOCK_GETTIME))
535psnip_clock__clock_getres(clockid_t clk_id) {
539 r = clock_getres(clk_id, &res);
550 if (clock_gettime(clk_id, &ts) != 0)
563#if !defined(PSNIP_CLOCK_WALL_METHOD)
565#elif defined(PSNIP_CLOCK_WALL_METHOD) && PSNIP_CLOCK_WALL_METHOD == PSNIP_CLOCK_METHOD_CLOCK_GETTIME
566 return psnip_clock__clock_getres(PSNIP_CLOCK_CLOCK_GETTIME_WALL);
567#elif defined(PSNIP_CLOCK_WALL_METHOD) && PSNIP_CLOCK_WALL_METHOD == PSNIP_CLOCK_METHOD_GETTIMEOFDAY
569#elif defined(PSNIP_CLOCK_WALL_METHOD) && PSNIP_CLOCK_WALL_METHOD == PSNIP_CLOCK_METHOD_TIME
580#if !defined(PSNIP_CLOCK_WALL_METHOD)
582#elif defined(PSNIP_CLOCK_WALL_METHOD) && PSNIP_CLOCK_WALL_METHOD == PSNIP_CLOCK_METHOD_CLOCK_GETTIME
583 return psnip_clock__clock_gettime(PSNIP_CLOCK_CLOCK_GETTIME_WALL, res);
584#elif defined(PSNIP_CLOCK_WALL_METHOD) && PSNIP_CLOCK_WALL_METHOD == PSNIP_CLOCK_METHOD_TIME
587#elif defined(PSNIP_CLOCK_WALL_METHOD) && PSNIP_CLOCK_WALL_METHOD == PSNIP_CLOCK_METHOD_GETTIMEOFDAY
590 if (gettimeofday(&tv, NULL) != 0)
604#if !defined(PSNIP_CLOCK_CPU_METHOD)
606#elif defined(PSNIP_CLOCK_CPU_METHOD) && PSNIP_CLOCK_CPU_METHOD == PSNIP_CLOCK_METHOD_CLOCK_GETTIME
607 return psnip_clock__clock_getres(PSNIP_CLOCK_CLOCK_GETTIME_CPU);
608#elif defined(PSNIP_CLOCK_CPU_METHOD) && PSNIP_CLOCK_CPU_METHOD == PSNIP_CLOCK_METHOD_CLOCK
609 return CLOCKS_PER_SEC;
610#elif defined(PSNIP_CLOCK_CPU_METHOD) && PSNIP_CLOCK_CPU_METHOD == PSNIP_CLOCK_METHOD_GETPROCESSTIMES
619#if !defined(PSNIP_CLOCK_CPU_METHOD)
622#elif defined(PSNIP_CLOCK_CPU_METHOD) && PSNIP_CLOCK_CPU_METHOD == PSNIP_CLOCK_METHOD_CLOCK_GETTIME
623 return psnip_clock__clock_gettime(PSNIP_CLOCK_CLOCK_GETTIME_CPU, res);
624#elif defined(PSNIP_CLOCK_CPU_METHOD) && PSNIP_CLOCK_CPU_METHOD == PSNIP_CLOCK_METHOD_CLOCK
626 if (t == ((clock_t) -1))
628 res->
seconds = t / CLOCKS_PER_SEC;
630#elif defined(PSNIP_CLOCK_CPU_METHOD) && PSNIP_CLOCK_CPU_METHOD == PSNIP_CLOCK_METHOD_GETPROCESSTIMES
631 FILETIME CreationTime, ExitTime, KernelTime, UserTime;
632 LARGE_INTEGER date, adjust;
634 if (!GetProcessTimes(GetCurrentProcess(), &CreationTime, &ExitTime, &KernelTime, &UserTime))
638 date.HighPart = UserTime.dwHighDateTime;
639 date.LowPart = UserTime.dwLowDateTime;
640 adjust.QuadPart = 11644473600000 * 10000;
641 date.QuadPart -= adjust.QuadPart;
643 res->
seconds = date.QuadPart / 10000000;
645#elif PSNIP_CLOCK_CPU_METHOD == PSNIP_CLOCK_METHOD_GETRUSAGE
647 if (getrusage(RUSAGE_SELF, &usage) != 0)
650 res->
seconds = usage.ru_utime.tv_sec;
662#if !defined(PSNIP_CLOCK_MONOTONIC_METHOD)
664#elif defined(PSNIP_CLOCK_MONOTONIC_METHOD) && PSNIP_CLOCK_MONOTONIC_METHOD == PSNIP_CLOCK_METHOD_CLOCK_GETTIME
665 return psnip_clock__clock_getres(PSNIP_CLOCK_CLOCK_GETTIME_MONOTONIC);
666#elif defined(PSNIP_CLOCK_MONOTONIC_METHOD) && PSNIP_CLOCK_MONOTONIC_METHOD == PSNIP_CLOCK_METHOD_MACH_ABSOLUTE_TIME
667 static mach_timebase_info_data_t tbi = { 0, };
669 mach_timebase_info(&tbi);
671#elif defined(PSNIP_CLOCK_MONOTONIC_METHOD) && PSNIP_CLOCK_MONOTONIC_METHOD == PSNIP_CLOCK_METHOD_GETTICKCOUNT64
673#elif defined(PSNIP_CLOCK_MONOTONIC_METHOD) && PSNIP_CLOCK_MONOTONIC_METHOD == PSNIP_CLOCK_METHOD_QUERYPERFORMANCECOUNTER
674 LARGE_INTEGER Frequency;
675 QueryPerformanceFrequency(&Frequency);
684#if !defined(PSNIP_CLOCK_MONOTONIC_METHOD)
687#elif defined(PSNIP_CLOCK_MONOTONIC_METHOD) && PSNIP_CLOCK_MONOTONIC_METHOD == PSNIP_CLOCK_METHOD_CLOCK_GETTIME
688 return psnip_clock__clock_gettime(PSNIP_CLOCK_CLOCK_GETTIME_MONOTONIC, res);
689#elif defined(PSNIP_CLOCK_MONOTONIC_METHOD) && PSNIP_CLOCK_MONOTONIC_METHOD == PSNIP_CLOCK_METHOD_MACH_ABSOLUTE_TIME
691 static mach_timebase_info_data_t tbi = { 0, };
693 mach_timebase_info(&tbi);
697#elif defined(PSNIP_CLOCK_MONOTONIC_METHOD) && PSNIP_CLOCK_MONOTONIC_METHOD == PSNIP_CLOCK_METHOD_QUERYPERFORMANCECOUNTER
699 if (QueryPerformanceCounter(&t) == 0)
702 QueryPerformanceFrequency(&f);
703 res->
seconds = t.QuadPart / f.QuadPart;
709#elif defined(PSNIP_CLOCK_MONOTONIC_METHOD) && PSNIP_CLOCK_MONOTONIC_METHOD == PSNIP_CLOCK_METHOD_GETTICKCOUNT64
710 const ULONGLONG msec = GetTickCount64();
734 switch (clock_type) {
753 switch (clock_type) {
795#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__) && !defined(__EMSCRIPTEN__) && (!defined(__GNUC_MINOR__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ > 8))
796# define HAVE_STDATOMIC
797#elif defined(__clang__)
798# if __has_extension(c_atomic)
799# define HAVE_CLANG_ATOMICS
804#if defined(__clang__) && defined(_WIN32)
805# undef HAVE_STDATOMIC
807# undef HAVE_CLANG_ATOMICS
812# define ATOMIC_UINT32_T uint32_t
813# define ATOMIC_UINT32_INIT(x) (x)
814#elif defined(HAVE_STDATOMIC)
815# include <stdatomic.h>
816# define ATOMIC_UINT32_T _Atomic uint32_t
817# define ATOMIC_UINT32_INIT(x) ATOMIC_VAR_INIT(x)
818#elif defined(HAVE_CLANG_ATOMICS)
819# define ATOMIC_UINT32_T _Atomic uint32_t
820# define ATOMIC_UINT32_INIT(x) (x)
822# define ATOMIC_UINT32_T volatile LONG
823# define ATOMIC_UINT32_INIT(x) (x)
825# define ATOMIC_UINT32_T volatile uint32_t
826# define ATOMIC_UINT32_INIT(x) (x)
834#pragma omp critical (munit_atomics)
838static inline uint32_t
841#pragma omp critical (munit_atomics)
846static inline uint32_t
850#pragma omp critical (munit_atomics)
852 if (*dest == *expected) {
862#elif defined(HAVE_STDATOMIC)
863# define munit_atomic_store(dest, value) atomic_store(dest, value)
864# define munit_atomic_load(src) atomic_load(src)
865# define munit_atomic_cas(dest, expected, value) atomic_compare_exchange_weak(dest, expected, value)
866#elif defined(HAVE_CLANG_ATOMICS)
867# define munit_atomic_store(dest, value) __c11_atomic_store(dest, value, __ATOMIC_SEQ_CST)
868# define munit_atomic_load(src) __c11_atomic_load(src, __ATOMIC_SEQ_CST)
869# define munit_atomic_cas(dest, expected, value) __c11_atomic_compare_exchange_weak(dest, expected, value, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
870#elif defined(__GNUC__) && (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
871# define munit_atomic_store(dest, value) __atomic_store_n(dest, value, __ATOMIC_SEQ_CST)
872# define munit_atomic_load(src) __atomic_load_n(src, __ATOMIC_SEQ_CST)
873# define munit_atomic_cas(dest, expected, value) __atomic_compare_exchange_n(dest, expected, value, 1, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)
874#elif defined(__GNUC__) && (__GNUC__ >= 4)
875# define munit_atomic_store(dest,value) do { *(dest) = (value); } while (0)
876# define munit_atomic_load(src) (*(src))
877# define munit_atomic_cas(dest, expected, value) __sync_bool_compare_and_swap(dest, *expected, value)
879# define munit_atomic_store(dest,value) do { *(dest) = (value); } while (0)
880# define munit_atomic_load(src) (*(src))
881# define munit_atomic_cas(dest, expected, value) InterlockedCompareExchange((dest), (value), *(expected))
883# warning No atomic implementation, PRNG will not be thread-safe
884# define munit_atomic_store(dest, value) do { *(dest) = (value); } while (0)
885# define munit_atomic_load(src) (*(src))
888 if (*dest == *expected) {
897#define MUNIT_PRNG_MULTIPLIER (747796405U)
898#define MUNIT_PRNG_INCREMENT (1729U)
907 munit_uint32_t res = ((state >> ((state >> 28) + 4)) ^ state) * (277803737U);
919munit_rand_generate_seed(
void) {
921#if defined(MUNIT_ENABLE_TIMING)
931 return munit_rand_from_state(state);
937 *state = munit_rand_next_state(old);
938 return munit_rand_from_state(old);
947 state = munit_rand_next_state(old);
948 }
while (!munit_atomic_cas(&munit_rand_state, &old, state));
950 return munit_rand_from_state(old);
959 while (members_remaining-- > 0) {
960 rv = munit_rand_state_uint32(state);
964 if (bytes_remaining != 0) {
965 rv = munit_rand_state_uint32(state);
966 memcpy(b, &rv, bytes_remaining);
976 munit_rand_state_memory(&state, size, data);
977 }
while (!munit_atomic_cas(&munit_rand_state, &old, state));
990 return munit_rand_state_uint32(state) ^ salt;
995 x = munit_rand_state_uint32(state) ^ salt;
1008 retval = munit_rand_state_at_most(&state, salt, max);
1009 }
while (!munit_atomic_cas(&munit_rand_state, &old, state));
1030 double retval = 0.0;
1038 retval = munit_rand_state_uint32(&state) / ((~((
munit_uint32_t) 0U)) + 1.0);
1039 }
while (!munit_atomic_cas(&munit_rand_state, &old, state));
1051#if defined(MUNIT_ENABLE_TIMING)
1078 for (param = params; param != NULL && param->
name != NULL; param++)
1079 if (strcmp(param->
name, key) == 0)
1080 return param->
value;
1084#if defined(MUNIT_ENABLE_TIMING)
1097 *params = realloc(*params,
sizeof(
MunitParameter) * (*params_size + 2));
1098 if (*params == NULL)
1101 (*params)[*params_size].name = name;
1102 (*params)[*params_size].value = value;
1104 (*params)[*params_size].name = NULL;
1105 (*params)[*params_size].value = NULL;
1113munit_maybe_concat(
size_t *len,
char *prefix,
char *suffix) {
1116 const size_t prefix_l = prefix != NULL ? strlen(prefix) : 0;
1117 const size_t suffix_l = suffix != NULL ? strlen(suffix) : 0;
1118 if (prefix_l == 0 && suffix_l == 0) {
1121 }
else if (prefix_l == 0 && suffix_l != 0) {
1124 }
else if (prefix_l != 0 && suffix_l == 0) {
1128 res_l = prefix_l + suffix_l;
1129 res = malloc(res_l + 1);
1130 memcpy(res, prefix, prefix_l);
1131 memcpy(res + prefix_l, suffix, suffix_l);
1143munit_maybe_free_concat(
char *s,
const char *prefix,
const char *suffix) {
1144 if (prefix != s && suffix != s)
1150munit_str_hash(
const char *name) {
1154 for (
p = name; *
p !=
'\0';
p++)
1155 h = (h << 5) + h + *
p;
1161munit_splice(
int from,
int to) {
1165 ssize_t bytes_written;
1173 len = read(from, buf,
sizeof(buf));
1177 write_res = write(to, buf + bytes_written, len - bytes_written);
1180 bytes_written += write_res;
1181 }
while (bytes_written < len);
1191 unsigned int iterations = runner->
iterations;
1193#if defined(MUNIT_ENABLE_TIMING)
1201 else if (iterations == 0)
1207 void *data = (test->
setup == NULL) ? runner->
user_data : test->
setup(params, runner->user_data);
1209#if defined(MUNIT_ENABLE_TIMING)
1214 result = test->
test(params, data);
1216#if defined(MUNIT_ENABLE_TIMING)
1226#if defined(MUNIT_ENABLE_TIMING)
1227 report->
wall_clock += munit_clock_get_elapsed(&wall_clock_begin, &wall_clock_end);
1228 report->
cpu_clock += munit_clock_get_elapsed(&cpu_clock_begin, &cpu_clock_end);
1231 switch ((
int) result) {
1246 }
while (++
i < iterations);
1251#if defined(MUNIT_EMOTICON)
1252# define MUNIT_RESULT_STRING_OK ":)"
1253# define MUNIT_RESULT_STRING_SKIP ":|"
1254# define MUNIT_RESULT_STRING_FAIL ":("
1255# define MUNIT_RESULT_STRING_ERROR ":o"
1256# define MUNIT_RESULT_STRING_TODO ":/"
1258# define MUNIT_RESULT_STRING_OK "OK "
1259# define MUNIT_RESULT_STRING_SKIP "SKIP "
1260# define MUNIT_RESULT_STRING_FAIL "FAIL "
1261# define MUNIT_RESULT_STRING_ERROR "ERROR"
1262# define MUNIT_RESULT_STRING_TODO "TODO "
1266munit_test_runner_print_color(
const MunitTestRunner *runner,
const char *
string,
char color) {
1273#if !defined(MUNIT_NO_BUFFER)
1276munit_replace_stderr(FILE *stderr_buf) {
1277 if (stderr_buf != NULL) {
1278 const int orig_stderr = dup(STDERR_FILENO);
1280 int errfd = fileno(stderr_buf);
1285 dup2(errfd, STDERR_FILENO);
1294munit_restore_stderr(
int orig_stderr) {
1295 if (orig_stderr != -1) {
1296 dup2(orig_stderr, STDERR_FILENO);
1309#if defined(MUNIT_ENABLE_TIMING)
1313 unsigned int output_l;
1317#if !defined(MUNIT_NO_FORK)
1321 ssize_t bytes_written = 0;
1323 ssize_t bytes_read = 0;
1329 if (params != NULL) {
1333 for (param = params; param != NULL && param->
name != NULL; param++) {
1351#if !defined(_WIN32) || defined(__MINGW32__)
1352 stderr_buf = tmpfile();
1354 tmpfile_s(&stderr_buf);
1356 if (stderr_buf == NULL) {
1357 munit_log_errno(
MUNIT_LOG_ERROR, stderr,
"unable to create buffer for stderr");
1362#if !defined(MUNIT_NO_FORK)
1366 if (pipe(pipefd) != 0) {
1373 if (fork_pid == 0) {
1376 orig_stderr = munit_replace_stderr(stderr_buf);
1377 munit_test_runner_exec(runner, test, params, &report);
1385 write_res = write(pipefd[1], ((
munit_uint8_t*) (&report)) + bytes_written,
sizeof(report) - bytes_written);
1386 if (write_res < 0) {
1387 if (stderr_buf != NULL) {
1392 bytes_written += write_res;
1393 }
while ((
size_t) bytes_written <
sizeof(report));
1395 if (stderr_buf != NULL)
1400 }
else if (fork_pid == -1) {
1403 if (stderr_buf != NULL) {
1411 read_res = read(pipefd[0], ((
munit_uint8_t*) (&report)) + bytes_read,
sizeof(report) - bytes_read);
1414 bytes_read += read_res;
1415 }
while (bytes_read < (ssize_t)
sizeof(report));
1417 changed_pid = waitpid(fork_pid, &status, 0);
1420 if (bytes_read !=
sizeof(report)) {
1421 munit_logf_internal(
MUNIT_LOG_ERROR, stderr_buf,
"child exited unexpectedly with status %d", WEXITSTATUS(status));
1423 }
else if (WEXITSTATUS(status) != EXIT_SUCCESS) {
1424 munit_logf_internal(
MUNIT_LOG_ERROR, stderr_buf,
"child exited with status %d", WEXITSTATUS(status));
1428 if (WIFSIGNALED(status)) {
1429#if defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 700)
1430 munit_logf_internal(
MUNIT_LOG_ERROR, stderr_buf,
"child killed by signal %d (%s)", WTERMSIG(status), strsignal(WTERMSIG(status)));
1432 munit_logf_internal(
MUNIT_LOG_ERROR, stderr_buf,
"child killed by signal %d", WTERMSIG(status));
1434 }
else if (WIFSTOPPED(status)) {
1435 munit_logf_internal(
MUNIT_LOG_ERROR, stderr_buf,
"child stopped by signal %d", WSTOPSIG(status));
1441 waitpid(fork_pid, NULL, 0);
1446#if !defined(MUNIT_NO_BUFFER)
1447 const volatile int orig_stderr = munit_replace_stderr(stderr_buf);
1450#if defined(MUNIT_THREAD_LOCAL)
1455 munit_error_jmp_buf_valid = 1;
1456 result = munit_test_runner_exec(runner, test, params, &report);
1459 result = munit_test_runner_exec(runner, test, params, &report_simple);
1462#if !defined(MUNIT_NO_BUFFER)
1463 munit_restore_stderr(orig_stderr);
1481 munit_log_internal(
MUNIT_LOG_ERROR, stderr_buf,
"Test marked TODO, but was successful.");
1485 }
else if (report.
failed > 0) {
1489 }
else if (report.
errored > 0) {
1493 }
else if (report.
skipped > 0) {
1499#if defined(MUNIT_ENABLE_TIMING)
1514#if defined(MUNIT_ENABLE_TIMING)
1526 if (stderr_buf != NULL) {
1531 munit_splice(fileno(stderr_buf), STDERR_FILENO);
1543 const char *test_name,
1550 for (pe = test->
parameters; pe != NULL && pe->
name != NULL; pe++) {
1551 if (
p->name == pe->
name)
1558 for (values = pe->
values; *values != NULL; values++) {
1561 if (next->
name == NULL) {
1562 munit_test_runner_run_test_with_params(runner, test, params);
1564 munit_test_runner_run_test_wild(runner, test, test_name, params, next);
1576 const char *prefix) {
1577 char *test_name = munit_maybe_concat(NULL, (
char *) prefix, (
char *) test->
name);
1581 size_t params_l = 0;
1589 size_t wild_params_l = 0;
1593 unsigned int possible;
1605 munit_test_runner_run_test_with_params(runner, test, NULL);
1609 for (pe = test->
parameters; pe != NULL && pe->
name != NULL; pe++) {
1612 for (cli_p = runner->
parameters; cli_p != NULL && cli_p->
name != NULL; cli_p++) {
1613 if (strcmp(cli_p->
name, pe->
name) == 0) {
1632 for (vals = pe->
values; *vals != NULL; vals++)
1638 pidx = munit_rand_at_most(munit_str_hash(test_name), possible - 1);
1649 if (wild_params_l != 0) {
1650 first_wild = params_l;
1651 for (wp = wild_params; wp != NULL && wp->
name != NULL; wp++) {
1653 if (strcmp(wp->
name, pe->
name) == 0) {
1661 munit_test_runner_run_test_wild(runner, test, test_name, params, params + first_wild);
1663 munit_test_runner_run_test_with_params(runner, test, params);
1671 munit_maybe_free_concat(test_name, prefix, test->
name);
1680 const char *prefix) {
1683 int is_suite_name_prefix;
1684 int is_test_name_prefix;
1685 char *pre = munit_maybe_concat(&pre_l, (
char *) prefix, (
char *) suite->
prefix);
1687 const char **test_name;
1692 for (test = suite->
tests; test != NULL && test->
test != NULL; test++) {
1693 if (runner->
tests != NULL) {
1694 for (test_name = runner->
tests; test_name != NULL && *test_name != NULL; test_name++) {
1695 test_name_l = strlen(*test_name);
1697 is_suite_name_prefix = (test_name_l < pre_l) && strncmp(pre, *test_name, test_name_l) == 0;
1699 is_test_name_prefix = (pre_l == 0 || strncmp(pre, *test_name, pre_l) == 0) &&
1700 strncmp(test->
name, *test_name + pre_l, strlen(*test_name + pre_l)) == 0;
1701 if (is_suite_name_prefix || is_test_name_prefix) {
1702 munit_test_runner_run_test(runner, test, pre);
1708 munit_test_runner_run_test(runner, test, pre);
1716 for (child_suite = suite->
suites; child_suite != NULL && child_suite->
prefix != NULL; child_suite++) {
1717 munit_test_runner_run_suite(runner, child_suite, pre);
1722 munit_maybe_free_concat(pre, prefix, suite->
prefix);
1727 munit_test_runner_run_suite(runner, runner->
suite, NULL);
1731munit_print_help(
int argc,
char *
const argv[
MUNIT_ARRAY_PARAM(argc + 1)],
void *user_data,
1736 printf(
"USAGE: %s [OPTIONS...] [TEST...]\n\n", argv[0]);
1737 puts(
" --seed SEED\n"
1738 " Value used to seed the PRNG. Must be a 32-bit integer in decimal\n"
1739 " notation with no separators (commas, decimals, spaces, etc.), or\n"
1740 " hexidecimal prefixed by \"0x\".\n"
1742 " Run each test N times. 0 means the default number.\n"
1743 " --param name value\n"
1744 " A parameter key/value pair which will be passed to any test with\n"
1745 " takes a parameter of that name. If not provided, the test will be\n"
1746 " run once for each possible parameter value.\n"
1747 " --list Write a list of all available tests.\n"
1749 " Write a list of all available tests and their possible parameters.\n"
1750 " --single Run each parameterized test in a single configuration instead of\n"
1751 " every possible combination\n"
1752 " --log-visible debug|info|warning|error\n"
1753 " --log-fatal debug|info|warning|error\n"
1754 " Set the level at which messages of different severities are visible,\n"
1755 " or cause the test to terminate.\n"
1756 #
if !defined(MUNIT_NO_FORK)
1757 " --no-fork Do not execute tests in a child process. If this option is supplied\n"
1758 " and a test crashes (including by failing an assertion), no further\n"
1759 " tests will be performed.\n"
1761 " --fatal-failures\n"
1762 " Stop executing tests as soon as a failure is found.\n"
1764 " Show data written to stderr by the tests, even if the test succeeds.\n"
1765 " --color auto|always|never\n"
1766 " Colorize (or don't) the output.\n"
1768 " --help Print this help message and exit.\n");
1769#if defined(MUNIT_NL_LANGINFO)
1770 setlocale(LC_ALL,
"");
1771 fputs((strcasecmp(
"UTF-8", nl_langinfo(CODESET)) == 0) ?
"µnit" :
"munit", stdout);
1775 printf(
" %d.%d.%d\n"
1776 "Full documentation at: https://nemequ.github.io/munit/\n",
1780 for (arg = arguments; arg != NULL && arg->
name != NULL; arg++)
1785munit_arguments_find(
const MunitArgument arguments[],
const char *name) {
1788 for (arg = arguments; arg != NULL && arg->
name != NULL; arg++)
1789 if (strcmp(arg->
name, name) == 0)
1798 char *pre = munit_maybe_concat(&pre_l, (
char *) prefix, (
char *) suite->
prefix);
1805 for (test = suite->
tests;
1806 test != NULL && test->
name != NULL;
1814 params != NULL && params->
name != NULL;
1816 fprintf(stdout,
" - %s: ", params->
name);
1817 if (params->
values == NULL) {
1821 for (val = params->
values;
1825 fputs(
", ", stdout);
1829 fputs(*val, stdout);
1837 for (child_suite = suite->
suites; child_suite != NULL && child_suite->
prefix != NULL; child_suite++) {
1838 munit_suite_list_tests(child_suite, show_params, pre);
1841 munit_maybe_free_concat(pre, prefix, suite->
prefix);
1845munit_stream_supports_ansi(FILE *stream) {
1847 return isatty(fileno(stream));
1850#if !defined(__MINGW32__)
1851 size_t ansicon_size = 0;
1854 if (isatty(fileno(stream))) {
1855#if !defined(__MINGW32__)
1856 getenv_s(&ansicon_size, NULL, 0,
"ANSICON");
1857 return ansicon_size != 0;
1859 return getenv(
"ANSICON") != NULL;
1870 int result = EXIT_FAILURE;
1872 size_t parameters_size = 0;
1873 size_t tests_size = 0;
1879 unsigned long long iterations;
1882 const char **runner_tests;
1883 unsigned int tests_run;
1884 unsigned int tests_total;
1887 runner.
suite = NULL;
1889 runner.
tests = NULL;
1900#if defined(MUNIT_ENABLE_TIMING)
1913 runner.
suite = suite;
1915 runner.
seed = munit_rand_generate_seed();
1918 for (arg = 1; arg < argc; arg++) {
1919 if (strncmp(
"--", argv[arg], 2) == 0) {
1920 if (strcmp(
"seed", argv[arg] + 2) == 0) {
1921 if (arg + 1 >= argc) {
1922 munit_logf_internal(
MUNIT_LOG_ERROR, stderr,
"%s requires an argument", argv[arg]);
1926 envptr = argv[arg + 1];
1927 ts = strtoul(argv[arg + 1], &envptr, 0);
1929 munit_logf_internal(
MUNIT_LOG_ERROR, stderr,
"invalid value ('%s') passed to %s", argv[arg + 1],
1936 }
else if (strcmp(
"iterations", argv[arg] + 2) == 0) {
1937 if (arg + 1 >= argc) {
1938 munit_logf_internal(
MUNIT_LOG_ERROR, stderr,
"%s requires an argument", argv[arg]);
1942 endptr = argv[arg + 1];
1943 iterations = strtoul(argv[arg + 1], &endptr, 0);
1944 if (*endptr !=
'\0' || iterations > UINT_MAX) {
1945 munit_logf_internal(
MUNIT_LOG_ERROR, stderr,
"invalid value ('%s') passed to %s", argv[arg + 1],
1950 runner.
iterations = (
unsigned int) iterations;
1953 }
else if (strcmp(
"param", argv[arg] + 2) == 0) {
1954 if (arg + 2 >= argc) {
1955 munit_logf_internal(
MUNIT_LOG_ERROR, stderr,
"%s requires two arguments", argv[arg]);
1961 munit_log_internal(
MUNIT_LOG_ERROR, stderr,
"failed to allocate memory");
1964 runner.
parameters[parameters_size].
name = (
char *) argv[arg + 1];
1970 }
else if (strcmp(
"color", argv[arg] + 2) == 0) {
1971 if (arg + 1 >= argc) {
1972 munit_logf_internal(
MUNIT_LOG_ERROR, stderr,
"%s requires an argument", argv[arg]);
1976 if (strcmp(argv[arg + 1],
"always") == 0)
1978 else if (strcmp(argv[arg + 1],
"never") == 0)
1980 else if (strcmp(argv[arg + 1],
"auto") == 0)
1983 munit_logf_internal(
MUNIT_LOG_ERROR, stderr,
"invalid value ('%s') passed to %s", argv[arg + 1],
1989 }
else if (strcmp(
"help", argv[arg] + 2) == 0) {
1990 munit_print_help(argc, argv, user_data, arguments);
1991 result = EXIT_SUCCESS;
1993 }
else if (strcmp(
"single", argv[arg] + 2) == 0) {
1995 }
else if (strcmp(
"show-stderr", argv[arg] + 2) == 0) {
1998 }
else if (strcmp(
"no-fork", argv[arg] + 2) == 0) {
2001 }
else if (strcmp(
"fatal-failures", argv[arg] + 2) == 0) {
2003 }
else if (strcmp(
"log-visible", argv[arg] + 2) == 0 ||
2004 strcmp(
"log-fatal", argv[arg] + 2) == 0) {
2005 if (arg + 1 >= argc) {
2006 munit_logf_internal(
MUNIT_LOG_ERROR, stderr,
"%s requires an argument", argv[arg]);
2010 if (strcmp(argv[arg + 1],
"debug") == 0)
2012 else if (strcmp(argv[arg + 1],
"info") == 0)
2014 else if (strcmp(argv[arg + 1],
"warning") == 0)
2016 else if (strcmp(argv[arg + 1],
"error") == 0)
2019 munit_logf_internal(
MUNIT_LOG_ERROR, stderr,
"invalid value ('%s') passed to %s", argv[arg + 1],
2024 if (strcmp(
"log-visible", argv[arg] + 2) == 0)
2025 munit_log_level_visible = level;
2027 munit_log_level_fatal = level;
2030 }
else if (strcmp(
"list", argv[arg] + 2) == 0) {
2031 munit_suite_list_tests(suite, 0, NULL);
2032 result = EXIT_SUCCESS;
2034 }
else if (strcmp(
"list-params", argv[arg] + 2) == 0) {
2035 munit_suite_list_tests(suite, 1, NULL);
2036 result = EXIT_SUCCESS;
2039 argument = munit_arguments_find(arguments, argv[arg] + 2);
2040 if (argument == NULL) {
2041 munit_logf_internal(
MUNIT_LOG_ERROR, stderr,
"unknown argument ('%s')", argv[arg]);
2045 if (!argument->
parse_argument(suite, user_data, &arg, argc, argv))
2049 runner_tests = realloc((
void *) runner.
tests,
sizeof(
char *) * (tests_size + 2));
2050 if (runner_tests == NULL) {
2051 munit_log_internal(
MUNIT_LOG_ERROR, stderr,
"failed to allocate memory");
2054 runner.
tests = runner_tests;
2055 runner.
tests[tests_size++] = argv[arg];
2056 runner.
tests[tests_size] = NULL;
2063 munit_test_runner_run(&runner);
2067 if (tests_run == 0) {
2068 fprintf(stderr,
"No tests run, %d (100%%) skipped.\n", runner.
report.
skipped);
2070 fprintf(
MUNIT_OUTPUT_FILE,
"%d of %d (%0.0f%%) tests successful, %d (%0.0f%%) test skipped.\n",
2074 (((
double) runner.
report.
skipped) / ((
double) tests_total)) * 100.0);
2078#if defined(MUNIT_FAIL_NO_TEST_RUN)
2081 if (runner.
report.
failed == 0 && runner.report_simple.errored == 0) {
2083 result = EXIT_SUCCESS;
2088 free((
void *) runner.
tests);
uint64_t fp[NUMBER_OF_WORDS]
#define MUNIT_TEST_NAME_LEN
PSNIP_CLOCK__FUNCTION psnip_uint32_t psnip_clock_get_precision(enum PsnipClockType clock_type)
int munit_rand_int_range(int min, int max)
PSNIP_CLOCK__FUNCTION int psnip_clock_wall_get_time(struct PsnipClockTimespec *res)
#define MUNIT_RESULT_STRING_TODO
#define PSNIP_CLOCK__FUNCTION
#define MUNIT_PRNG_MULTIPLIER
PSNIP_CLOCK__FUNCTION psnip_uint32_t psnip_clock_wall_get_precision(void)
#define MUNIT_TEST_TIME_FORMAT
#define MUNIT_OUTPUT_FILE
int munit_suite_main_custom(const MunitSuite *suite, void *user_data, int argc, char *const argv[MUNIT_ARRAY_PARAM(argc+1)], const MunitArgument arguments[])
void munit_rand_seed(munit_uint32_t seed)
#define MUNIT_RESULT_STRING_SKIP
#define MUNIT_PRNG_INCREMENT
PSNIP_CLOCK__FUNCTION psnip_uint32_t psnip_clock_cpu_get_precision(void)
#define ATOMIC_UINT32_INIT(x)
PSNIP_CLOCK__FUNCTION psnip_uint32_t psnip_clock_monotonic_get_precision(void)
void munit_rand_memory(size_t size, munit_uint8_t data[MUNIT_ARRAY_PARAM(size)])
#define PSNIP_CLOCK_NSEC_PER_SEC
#define MUNIT_XSTRINGIFY(x)
void munit_errorf_ex(const char *filename, int line, const char *format,...)
void munit_logf_ex(MunitLogLevel level, const char *filename, int line, const char *format,...)
int munit_suite_main(const MunitSuite *suite, void *user_data, int argc, char *const argv[MUNIT_ARRAY_PARAM(argc+1)])
#define MUNIT_RESULT_STRING_FAIL
PSNIP_CLOCK__FUNCTION int psnip_clock_cpu_get_time(struct PsnipClockTimespec *res)
munit_uint32_t munit_rand_uint32(void)
PSNIP_CLOCK__FUNCTION int psnip_clock_monotonic_get_time(struct PsnipClockTimespec *res)
#define PSNIP_CLOCK_UNREACHABLE()
#define MUNIT_STRERROR_LEN
double munit_rand_double(void)
PSNIP_CLOCK__FUNCTION int psnip_clock_get_time(enum PsnipClockType clock_type, struct PsnipClockTimespec *res)
void * munit_malloc_ex(const char *filename, int line, size_t size)
#define munit_atomic_store(dest, value)
#define MUNIT_RESULT_STRING_OK
#define munit_atomic_load(src)
#define MUNIT_RESULT_STRING_ERROR
const char * munit_parameters_get(const MunitParameter params[], const char *key)
@ PSNIP_CLOCK_TYPE_MONOTONIC
#define MUNIT_LIKELY(expr)
struct MunitSuite_ MunitSuite
#define MUNIT_ARRAY_PARAM(name)
#define MUNIT_CURRENT_VERSION
@ MUNIT_TEST_OPTION_SINGLE_ITERATION
struct MunitArgument_ MunitArgument
#define MUNIT_UNLIKELY(expr)
#define MUNIT_PRINTF(string_index, first_to_check)
#define MUNIT_SIZE_MODIFIER
munit_bool(* parse_argument)(const MunitSuite *suite, void *user_data, int *arg, int argc, char *const argv[MUNIT_ARRAY_PARAM(argc+1)])
void(* write_help)(const MunitArgument *argument, void *user_data)
munit_uint64_t wall_clock
MunitTestTearDown tear_down
MunitParameterEnum * parameters
const MunitSuite * current_suite
MunitParameter * parameters
munit_bool single_parameter_mode
munit_bool fatal_failures
psnip_uint64_t nanoseconds