Skip to content

Conversation

@michaelrj-google
Copy link
Contributor

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.

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.
@llvmbot llvmbot added the libc label Nov 12, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 12, 2024

@llvm/pr-subscribers-libc

Author: Michael Jones (michaelrj-google)

Changes

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.


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

2 Files Affected:

  • (modified) libc/test/src/sys/statvfs/linux/fstatvfs_test.cpp (+5-1)
  • (modified) libc/test/src/sys/statvfs/linux/statvfs_test.cpp (+4)
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));
 

@SchrodingerZhu SchrodingerZhu merged commit d6219e6 into llvm:main Nov 12, 2024
7 of 8 checks passed
@michaelrj-google michaelrj-google deleted the libcMoreStatvfsCleanup branch November 12, 2024 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants