[libc-commits] [libc] [libc] Make fstatvfs test less flakey (PR #115949)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Tue Nov 12 14:20:07 PST 2024
https://github.com/michaelrj-google created https://github.com/llvm/llvm-project/pull/115949
Apparently I forgot to fix the filename for the fstatvfs test so that
it's different from the statvfs test, oops. This patch fixes that and
also deletes the folder if it already exists.
>From 59696053c4bdfcad9a9c901b3e2045ad3a0c0caf Mon Sep 17 00:00:00 2001
From: Michael Jones <michaelrj at google.com>
Date: Tue, 12 Nov 2024 14:18:01 -0800
Subject: [PATCH] [libc] Make fstatvfs test less flakey
Apparently I forgot to fix the filename for the fstatvfs test so that
it's different from the statvfs test, oops. This patch fixes that and
also deletes the folder if it already exists.
---
libc/test/src/sys/statvfs/linux/fstatvfs_test.cpp | 6 +++++-
libc/test/src/sys/statvfs/linux/statvfs_test.cpp | 4 ++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/libc/test/src/sys/statvfs/linux/fstatvfs_test.cpp b/libc/test/src/sys/statvfs/linux/fstatvfs_test.cpp
index 9daac13321cd43..f4d71e906e2ad8 100644
--- a/libc/test/src/sys/statvfs/linux/fstatvfs_test.cpp
+++ b/libc/test/src/sys/statvfs/linux/fstatvfs_test.cpp
@@ -33,9 +33,13 @@ TEST(LlvmLibcSysFStatvfsTest, FStatvfsBasic) {
TEST(LlvmLibcSysFStatvfsTest, FStatvfsInvalidPath) {
struct statvfs buf;
- constexpr const char *FILENAME = "statvfs.testdir";
+ constexpr const char *FILENAME = "fstatvfs.testdir";
auto TEST_DIR = libc_make_test_file_path(FILENAME);
+ // Always delete the folder so that we start in a consistent state.
+ LIBC_NAMESPACE::rmdir(TEST_DIR);
+ LIBC_NAMESPACE::libc_errno = 0; // Reset errno
+
ASSERT_THAT(LIBC_NAMESPACE::mkdirat(AT_FDCWD, TEST_DIR, S_IRWXU),
Succeeds(0));
diff --git a/libc/test/src/sys/statvfs/linux/statvfs_test.cpp b/libc/test/src/sys/statvfs/linux/statvfs_test.cpp
index 68448e0530af84..32f8120e17b42e 100644
--- a/libc/test/src/sys/statvfs/linux/statvfs_test.cpp
+++ b/libc/test/src/sys/statvfs/linux/statvfs_test.cpp
@@ -33,6 +33,10 @@ TEST(LlvmLibcSysStatvfsTest, StatvfsInvalidPath) {
constexpr const char *FILENAME = "statvfs.testdir";
auto TEST_DIR = libc_make_test_file_path(FILENAME);
+ // Always delete the folder so that we start in a consistent state.
+ LIBC_NAMESPACE::rmdir(TEST_DIR);
+ LIBC_NAMESPACE::libc_errno = 0; // Reset errno
+
ASSERT_THAT(LIBC_NAMESPACE::mkdirat(AT_FDCWD, TEST_DIR, S_IRWXU),
Succeeds(0));
More information about the libc-commits
mailing list