From db3e11b619dcc5f0dcf7383ad421b0095f101adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Widera?= Date: Thu, 28 Jul 2022 14:22:39 +0200 Subject: [PATCH] test: extent ALPAKA_CHECK to show better error messages To know where a test fails the line and file can be very usefull. --- include/alpaka/test/Check.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/alpaka/test/Check.hpp b/include/alpaka/test/Check.hpp index 6aa453fc83ef..4f9115fef5e2 100644 --- a/include/alpaka/test/Check.hpp +++ b/include/alpaka/test/Check.hpp @@ -9,28 +9,33 @@ #pragma once +#include + #include // TODO: SYCL doesn't have a way to detect if we're looking at device or host code. This needs a workaround so that // SYCL and other back-ends are compatible. #ifdef ALPAKA_ACC_SYCL_ENABLED -# define ALPAKA_CHECK(success, expression) \ +# define ALPAKA_CHECK_DO(file, line, success, expression) \ do \ { \ if(!(expression)) \ { \ - acc.cout << "ALPAKA_CHECK failed because '!(" << #expression << ")'\n"; \ + acc.cout << "ALPAKA_CHECK failed because '!(" << #expression << ")' in " << file << ":" << line \ + << "\n"; \ success = false; \ } \ } while(0) #else -# define ALPAKA_CHECK(success, expression) \ +# define ALPAKA_CHECK_DO(file, line, success, expression) \ do \ { \ if(!(expression)) \ { \ - printf("ALPAKA_CHECK failed because '!(%s)'\n", #expression); \ + printf("ALPAKA_CHECK failed because '!(%s)' in %s:%d\n", #expression, file, line); \ success = false; \ } \ } while(0) #endif + +#define ALPAKA_CHECK(success, expression) ALPAKA_CHECK_DO(__FILE__, __LINE__, success, expression)