anv/tests: Propagate failures to gtest

Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24355>
This commit is contained in:
Caio Oliveira
2023-07-27 14:54:02 -07:00
parent c374033f5b
commit 54b0745b5e
2 changed files with 23 additions and 9 deletions

View File

@@ -5,6 +5,8 @@
#include <gtest/gtest.h>
#include "test_common.h"
#define ANV_C_TEST(S, N, C) extern "C" void C(void); TEST(S, N) { C(); }
ANV_C_TEST(StatePool, Regular, state_pool_test);
@@ -14,3 +16,7 @@ ANV_C_TEST(StatePool, Padding, state_pool_padding_test);
ANV_C_TEST(BlockPool, NoFree, block_pool_no_free_test);
ANV_C_TEST(BlockPool, GrowFirst, block_pool_grow_first_test);
extern "C" void FAIL_IN_GTEST(const char *file_path, unsigned line_number, const char *msg) {
GTEST_FAIL_AT(file_path, line_number) << msg;
}

View File

@@ -21,19 +21,27 @@
* IN THE SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include "dev/intel_device_info.h"
#define ASSERT(cond) \
do { \
if (!(cond)) { \
fprintf(stderr, "%s:%d: Test assertion `%s` failed.\n", \
__FILE__, __LINE__, # cond); \
abort(); \
} \
#ifdef __cplusplus
extern "C" {
#endif
#define ASSERT(cond) \
do { \
if (!(cond)) { \
FAIL_IN_GTEST(__FILE__, __LINE__, "Test assertion `" # cond \
"` failed."); \
} \
} while (false)
static inline void test_device_info_init(struct intel_device_info *info)
{
info->mem_alignment = 4096;
}
void FAIL_IN_GTEST(const char *file_path, unsigned line_number, const char *msg);
#ifdef __cplusplus
} // extern "C"
#endif