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

Alan Zhao via libc-commits libc-commits at lists.llvm.org
Thu Feb 6 10:46:51 PST 2025


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

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

>From a1ed97b02980aa4c2d11c105cf29941f1ab0a834 Mon Sep 17 00:00:00 2001
From: Alan Zhao <ayzhao at google.com>
Date: Thu, 6 Feb 2025 10:40:17 -0800
Subject: [PATCH] [libc][minor] Fix assertion in
 LlvmLibcFILETest.SimpleFileOperations

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
---
 libc/test/src/stdio/fileop_test.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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));



More information about the libc-commits mailing list