Skip to content

Commit 3d0a367

Browse files
authored
[libc] Make errno asserts noop on gpu targets (#166606)
This patch defines errno unit and integration test asserts as noop on GPU targets. Checking for errnos is tests has caused build breakages in previous patches.
1 parent 28a279c commit 3d0a367

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

libc/test/IntegrationTest/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ add_object_library(
1414
libc.hdr.stdint_proxy
1515
libc.src.__support.OSUtil.osutil
1616
libc.src.__support.CPP.atomic
17+
libc.src.__support.macros.properties.architectures
1718
${arch_specific_deps}
1819
)

libc/test/IntegrationTest/test.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "src/__support/OSUtil/exit.h"
1313
#include "src/__support/OSUtil/io.h"
14+
#include "src/__support/macros/properties/architectures.h"
1415

1516
#define __AS_STRING(val) #val
1617
#define __CHECK_TRUE(file, line, val, should_exit) \
@@ -68,9 +69,15 @@
6869
////////////////////////////////////////////////////////////////////////////////
6970
// Errno checks.
7071

72+
#ifdef LIBC_TARGET_ARCH_IS_GPU
73+
#define ASSERT_ERRNO_EQ(VAL)
74+
#define ASSERT_ERRNO_SUCCESS()
75+
#define ASSERT_ERRNO_FAILURE()
76+
#else
7177
#define ASSERT_ERRNO_EQ(VAL) ASSERT_EQ(VAL, static_cast<int>(errno))
7278
#define ASSERT_ERRNO_SUCCESS() ASSERT_EQ(0, static_cast<int>(errno))
7379
#define ASSERT_ERRNO_FAILURE() ASSERT_NE(0, static_cast<int>(errno))
80+
#endif
7481

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

libc/test/UnitTest/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,5 +204,6 @@ add_header_library(
204204
ErrnoCheckingTest.h
205205
DEPENDS
206206
libc.src.__support.common
207+
libc.src.__support.macros.properties.architectures
207208
libc.src.errno.errno
208209
)

libc/test/UnitTest/ErrnoCheckingTest.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,17 @@
1111

1212
#include "src/__support/libc_errno.h"
1313
#include "src/__support/macros/config.h"
14+
#include "src/__support/macros/properties/architectures.h"
1415
#include "test/UnitTest/Test.h"
1516

1617
// Define macro to validate the value stored in the errno and restore it
1718
// to zero.
1819

20+
#ifdef LIBC_TARGET_ARCH_IS_GPU
21+
#define ASSERT_ERRNO_EQ(VAL)
22+
#define ASSERT_ERRNO_SUCCESS()
23+
#define ASSERT_ERRNO_FAILURE()
24+
#else
1925
#define ASSERT_ERRNO_EQ(VAL) \
2026
do { \
2127
ASSERT_EQ(VAL, static_cast<int>(libc_errno)); \
@@ -27,6 +33,7 @@
2733
ASSERT_NE(0, static_cast<int>(libc_errno)); \
2834
libc_errno = 0; \
2935
} while (0)
36+
#endif
3037

3138
namespace LIBC_NAMESPACE_DECL {
3239
namespace testing {

0 commit comments

Comments
 (0)