[libc-commits] [libc] [libc] Fix build/test errors after 1ecd108 (PR #143811)
via libc-commits
libc-commits at lists.llvm.org
Wed Jun 11 16:49:55 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Alexey Samsonov (vonosmas)
<details>
<summary>Changes</summary>
Make sure ErrnoCheckingTest.h is included. Restore libc_errno clearing in test cases for fgetc/fgetc_unlocked/fgets which don't rely on other errno-clearing assertions.
---
Full diff: https://github.com/llvm/llvm-project/pull/143811.diff
4 Files Affected:
- (modified) libc/test/src/stdio/fgetc_test.cpp (+2)
- (modified) libc/test/src/stdio/fgetc_unlocked_test.cpp (+2)
- (modified) libc/test/src/stdio/fgets_test.cpp (+2)
- (modified) libc/test/src/stdio/setvbuf_test.cpp (+1)
``````````diff
diff --git a/libc/test/src/stdio/fgetc_test.cpp b/libc/test/src/stdio/fgetc_test.cpp
index 7c652f666a8f3..b2e5cc028146b 100644
--- a/libc/test/src/stdio/fgetc_test.cpp
+++ b/libc/test/src/stdio/fgetc_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "src/__support/libc_errno.h"
#include "src/stdio/clearerr.h"
#include "src/stdio/fclose.h"
#include "src/stdio/feof.h"
@@ -33,6 +34,7 @@ class LlvmLibcGetcTest : public LIBC_NAMESPACE::testing::ErrnoCheckingTest {
// This is an error and not a real EOF.
ASSERT_EQ(LIBC_NAMESPACE::feof(file), 0);
ASSERT_NE(LIBC_NAMESPACE::ferror(file), 0);
+ libc_errno = 0;
ASSERT_EQ(0, LIBC_NAMESPACE::fclose(file));
diff --git a/libc/test/src/stdio/fgetc_unlocked_test.cpp b/libc/test/src/stdio/fgetc_unlocked_test.cpp
index f4471dd82df15..d74ff9572224b 100644
--- a/libc/test/src/stdio/fgetc_unlocked_test.cpp
+++ b/libc/test/src/stdio/fgetc_unlocked_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "src/__support/libc_errno.h"
#include "src/stdio/fclose.h"
#include "src/stdio/feof.h"
#include "src/stdio/feof_unlocked.h"
@@ -36,6 +37,7 @@ class LlvmLibcGetcTest : public LIBC_NAMESPACE::testing::ErrnoCheckingTest {
// This is an error and not a real EOF.
ASSERT_EQ(LIBC_NAMESPACE::feof(file), 0);
ASSERT_NE(LIBC_NAMESPACE::ferror(file), 0);
+ libc_errno = 0;
ASSERT_EQ(0, LIBC_NAMESPACE::fclose(file));
diff --git a/libc/test/src/stdio/fgets_test.cpp b/libc/test/src/stdio/fgets_test.cpp
index c00a9256af52d..acfd6fa34b7e3 100644
--- a/libc/test/src/stdio/fgets_test.cpp
+++ b/libc/test/src/stdio/fgets_test.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "src/__support/libc_errno.h"
#include "src/stdio/fclose.h"
#include "src/stdio/feof.h"
#include "src/stdio/ferror.h"
@@ -36,6 +37,7 @@ TEST_F(LlvmLibcFgetsTest, WriteAndReadCharacters) {
// This is an error and not a real EOF.
ASSERT_EQ(LIBC_NAMESPACE::feof(file), 0);
ASSERT_NE(LIBC_NAMESPACE::ferror(file), 0);
+ libc_errno = 0;
ASSERT_EQ(0, LIBC_NAMESPACE::fclose(file));
diff --git a/libc/test/src/stdio/setvbuf_test.cpp b/libc/test/src/stdio/setvbuf_test.cpp
index 4144bc1bef447..a0936ba79ef73 100644
--- a/libc/test/src/stdio/setvbuf_test.cpp
+++ b/libc/test/src/stdio/setvbuf_test.cpp
@@ -11,6 +11,7 @@
#include "src/stdio/fread.h"
#include "src/stdio/fwrite.h"
#include "src/stdio/setvbuf.h"
+#include "test/UnitTest/ErrnoCheckingTest.h"
#include "test/UnitTest/Test.h"
#include "hdr/stdio_macros.h"
``````````
</details>
https://github.com/llvm/llvm-project/pull/143811
More information about the libc-commits
mailing list