Merge "Make tests/libs/CHECK.h work on the host" into main

This commit is contained in:
Ryan Prichard 2024-03-14 23:15:19 +00:00 committed by Gerrit Code Review
commit 3abc30d6a6

View file

@ -20,7 +20,15 @@
// should probably avoid dependencies other than ones we're specifically
// trying to test.
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
static inline void check_failure(const char* file, int line, const char* function,
const char* failed_expression) {
fprintf(stderr, "%s:%d: %s: assertion \"%s\" failed\n", file, line, function, failed_expression);
fflush(stderr);
abort();
}
#define CHECK(e) \
((e) ? static_cast<void>(0) : __assert2(__FILE__, __LINE__, __PRETTY_FUNCTION__, #e))
((e) ? static_cast<void>(0) : check_failure(__FILE__, __LINE__, __PRETTY_FUNCTION__, #e))