Skip to content

Commit fc9c2b3

Browse files
committed
Make errno asserts noop on gpu targets
1 parent 3c162ba commit fc9c2b3

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

libc/test/IntegrationTest/test.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,23 @@
6868
////////////////////////////////////////////////////////////////////////////////
6969
// Errno checks.
7070

71+
#ifdef LIBC_TARGET_ARCH_IS_GPU
72+
#define ASSERT_ERRNO_EQ(VAL)
73+
#else
7174
#define ASSERT_ERRNO_EQ(VAL) ASSERT_EQ(VAL, static_cast<int>(errno))
75+
#endif
76+
77+
#ifdef LIBC_TARGET_ARCH_IS_GPU
78+
#define ASSERT_ERRNO_SUCCESS()
79+
#else
7280
#define ASSERT_ERRNO_SUCCESS() ASSERT_EQ(0, static_cast<int>(errno))
81+
#endif
82+
83+
#ifdef LIBC_TARGET_ARCH_IS_GPU
84+
#define ASSERT_ERRNO_FAILURE()
85+
#else
7386
#define ASSERT_ERRNO_FAILURE() ASSERT_NE(0, static_cast<int>(errno))
87+
#endif
7488

7589
// Integration tests are compiled with -ffreestanding which stops treating
7690
// the main function as a non-overloadable special function. Hence, we use a

libc/test/UnitTest/ErrnoCheckingTest.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,31 @@
1616
// Define macro to validate the value stored in the errno and restore it
1717
// to zero.
1818

19+
#ifdef LIBC_TARGET_ARCH_IS_GPU
20+
#define ASSERT_ERRNO_EQ(VAL)
21+
#else
1922
#define ASSERT_ERRNO_EQ(VAL) \
2023
do { \
2124
ASSERT_EQ(VAL, static_cast<int>(libc_errno)); \
2225
libc_errno = 0; \
2326
} while (0)
27+
#endif
28+
29+
#ifdef LIBC_TARGET_ARCH_IS_GPU
30+
#define ASSERT_ERRNO_SUCCESS()
31+
#else
2432
#define ASSERT_ERRNO_SUCCESS() ASSERT_EQ(0, static_cast<int>(libc_errno))
33+
#endif
34+
35+
#ifdef LIBC_TARGET_ARCH_IS_GPU
36+
#define ASSERT_ERRNO_FAILURE()
37+
#else
2538
#define ASSERT_ERRNO_FAILURE() \
2639
do { \
2740
ASSERT_NE(0, static_cast<int>(libc_errno)); \
2841
libc_errno = 0; \
2942
} while (0)
43+
#endif
3044

3145
namespace LIBC_NAMESPACE_DECL {
3246
namespace testing {

0 commit comments

Comments
 (0)