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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Alan Zhao (alanzhao1)

<details>
<summary>Changes</summary>

The file descriptor of the first opened file is not necessarily 3, so we change the assertion so that it's >= 3 (i.e. not 0, 1, 2, or -1 which correspond to stdin, stdout, stderr, or error respectively.)

Fixes #<!-- -->126106

---
Full diff: https://github.com/llvm/llvm-project/pull/126109.diff


1 Files Affected:

- (modified) libc/test/src/stdio/fileop_test.cpp (+1-1) 


``````````diff
diff --git a/libc/test/src/stdio/fileop_test.cpp b/libc/test/src/stdio/fileop_test.cpp
index 98ead6edd38b471..d12e9379e158e0f 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), 3);
   constexpr char CONTENT[] = "1234567890987654321";
   ASSERT_EQ(sizeof(CONTENT) - 1,
             LIBC_NAMESPACE::fwrite(CONTENT, 1, sizeof(CONTENT) - 1, file));

``````````

</details>


https://github.com/llvm/llvm-project/pull/126109


More information about the libc-commits mailing list