[libc-commits] [libc] 4c8acbd - [libc][minor] Fix assertion in LlvmLibcFILETest.SimpleFileOperations (#126109)

via libc-commits libc-commits at lists.llvm.org
Thu Feb 6 12:57:26 PST 2025


Author: Alan Zhao
Date: 2025-02-06T12:57:22-08:00
New Revision: 4c8acbded152326ad138e1af340c0dbd5e31bbb7

URL: https://github.com/llvm/llvm-project/commit/4c8acbded152326ad138e1af340c0dbd5e31bbb7
DIFF: https://github.com/llvm/llvm-project/commit/4c8acbded152326ad138e1af340c0dbd5e31bbb7.diff

LOG: [libc][minor] Fix assertion in LlvmLibcFILETest.SimpleFileOperations (#126109)

The file descriptor of the first opened file is not necessarily 3, so we
change the assertion so that it's >= 0 (i.e. not an error.)

Fixes #126106

Added: 
    

Modified: 
    libc/test/src/stdio/fileop_test.cpp

Removed: 
    


################################################################################
diff  --git a/libc/test/src/stdio/fileop_test.cpp b/libc/test/src/stdio/fileop_test.cpp
index 98ead6edd38b471..c662a9fbd0860f2 100644
--- a/libc/test/src/stdio/fileop_test.cpp
+++ b/libc/test/src/stdio/fileop_test.cpp
@@ -31,7 +31,7 @@ TEST(LlvmLibcFILETest, SimpleFileOperations) {
   constexpr char FILENAME[] = "testdata/simple_operations.test";
   ::FILE *file = LIBC_NAMESPACE::fopen(FILENAME, "w");
   ASSERT_FALSE(file == nullptr);
-  ASSERT_EQ(LIBC_NAMESPACE::fileno(file), 3);
+  ASSERT_GE(LIBC_NAMESPACE::fileno(file), 0);
   constexpr char CONTENT[] = "1234567890987654321";
   ASSERT_EQ(sizeof(CONTENT) - 1,
             LIBC_NAMESPACE::fwrite(CONTENT, 1, sizeof(CONTENT) - 1, file));


        


More information about the libc-commits mailing list