[libc-commits] [libc] 95c0e03 - [libc] Fix 'fgets' test on the GPU for some C libraries (#110118)
via libc-commits
libc-commits at lists.llvm.org
Thu Sep 26 07:23:11 PDT 2024
Author: Joseph Huber
Date: 2024-09-26T07:23:07-07:00
New Revision: 95c0e03376a4699c38cd3e37a3b6fdad0549cd52
URL: https://github.com/llvm/llvm-project/commit/95c0e03376a4699c38cd3e37a3b6fdad0549cd52
DIFF: https://github.com/llvm/llvm-project/commit/95c0e03376a4699c38cd3e37a3b6fdad0549cd52.diff
LOG: [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).
Added:
Modified:
libc/test/src/stdio/fgets_test.cpp
Removed:
################################################################################
diff --git a/libc/test/src/stdio/fgets_test.cpp b/libc/test/src/stdio/fgets_test.cpp
index d005a71710d21a..39337262f1e008 100644
--- a/libc/test/src/stdio/fgets_test.cpp
+++ b/libc/test/src/stdio/fgets_test.cpp
@@ -43,6 +43,8 @@ TEST(LlvmLibcFgetsTest, WriteAndReadCharacters) {
file = LIBC_NAMESPACE::fopen(FILENAME, "r");
ASSERT_FALSE(file == nullptr);
+ // The GPU build relies on the host C library, so this check may be
diff erent.
+#ifndef LIBC_TARGET_ARCH_IS_GPU
// If we request just 1 byte, it should return just a null byte and not
// advance the read head. This is implementation defined.
output = LIBC_NAMESPACE::fgets(buff, 1, file);
@@ -54,6 +56,7 @@ TEST(LlvmLibcFgetsTest, WriteAndReadCharacters) {
// This is also implementation defined.
output = LIBC_NAMESPACE::fgets(buff, 0, file);
ASSERT_TRUE(output == nullptr);
+#endif
const char *output_arr[] = {
"1234567", "89\n", "1234567", "\n", "123456\n", "1",
More information about the libc-commits
mailing list