anv/tests: Propagate failures to gtest
authorCaio Oliveira <caio.oliveira@intel.com>
Thu, 27 Jul 2023 21:54:02 +0000 (14:54 -0700)
committerCaio Oliveira <caio.oliveira@intel.com>
Fri, 25 Aug 2023 19:08:26 +0000 (12:08 -0700)
Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24355>

src/intel/vulkan/tests/anv_tests.cpp
src/intel/vulkan/tests/test_common.h

index 1763177..eb97070 100644 (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;
+}
index ae84935..eea5b5a 100644 (file)
  * 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