Skip to content

Commit 95c0e03

Browse files
authored
[libc] Fix 'fgets' test on the GPU for some C libraries (#110118)
Summary: The GPU handling for a lot of `FILE *` functions pretty much just forwards it to the host via RPC. This test checks for implementation defined behavior, which sometimes passes and sometimes doesn't. We just disable it here so it works on the standard semantics. We do this forwarding primarily for interopt w/ the host if the user is compiling from an offloading language (e.g. CUDA).
1 parent 8f21459 commit 95c0e03

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

libc/test/src/stdio/fgets_test.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ TEST(LlvmLibcFgetsTest, WriteAndReadCharacters) {
4343
file = LIBC_NAMESPACE::fopen(FILENAME, "r");
4444
ASSERT_FALSE(file == nullptr);
4545

46+
// The GPU build relies on the host C library, so this check may be different.
47+
#ifndef LIBC_TARGET_ARCH_IS_GPU
4648
// If we request just 1 byte, it should return just a null byte and not
4749
// advance the read head. This is implementation defined.
4850
output = LIBC_NAMESPACE::fgets(buff, 1, file);
@@ -54,6 +56,7 @@ TEST(LlvmLibcFgetsTest, WriteAndReadCharacters) {
5456
// This is also implementation defined.
5557
output = LIBC_NAMESPACE::fgets(buff, 0, file);
5658
ASSERT_TRUE(output == nullptr);
59+
#endif
5760

5861
const char *output_arr[] = {
5962
"1234567", "89\n", "1234567", "\n", "123456\n", "1",

0 commit comments

Comments
 (0)