[libc-commits] [libc] [libc] Make utimes_test more stable (PR #134321)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Thu Apr 3 16:38:13 PDT 2025


https://github.com/michaelrj-google created https://github.com/llvm/llvm-project/pull/134321

The test for utimes added in #134167 might fail if the file for one test
hasn't been cleaned up by the OS before the second test starts. This
patch makes the tests use different files.


>From 07a37c6ad7662af3e2696d0f29f03c462ee8d234 Mon Sep 17 00:00:00 2001
From: Michael Jones <michaelrj at google.com>
Date: Thu, 3 Apr 2025 16:36:31 -0700
Subject: [PATCH] [libc] Make utimes_test more stable

The test for utimes added in #134167 might fail if the file for one test
hasn't been cleaned up by the OS before the second test starts. This
patch makes the tests use different files.
---
 libc/test/src/sys/time/utimes_test.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libc/test/src/sys/time/utimes_test.cpp b/libc/test/src/sys/time/utimes_test.cpp
index b97befb8626e3..69607ba928e1e 100644
--- a/libc/test/src/sys/time/utimes_test.cpp
+++ b/libc/test/src/sys/time/utimes_test.cpp
@@ -17,13 +17,12 @@
 #include "test/UnitTest/ErrnoSetterMatcher.h"
 #include "test/UnitTest/Test.h"
 
-constexpr const char *FILE_PATH = "utimes.test";
-
 // SUCCESS: Takes a file and successfully updates
 // its last access and modified times.
 TEST(LlvmLibcUtimesTest, ChangeTimesSpecific) {
   using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
 
+  constexpr const char *FILE_PATH = "utimes_pass.test";
   auto TEST_FILE = libc_make_test_file_path(FILE_PATH);
   int fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT);
   ASSERT_GT(fd, 0);
@@ -62,6 +61,7 @@ TEST(LlvmLibcUtimesTest, InvalidMicroseconds) {
   using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
   using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
 
+  constexpr const char *FILE_PATH = "utimes_fail.test";
   auto TEST_FILE = libc_make_test_file_path(FILE_PATH);
   int fd = LIBC_NAMESPACE::open(TEST_FILE, O_WRONLY | O_CREAT);
   ASSERT_GT(fd, 0);



More information about the libc-commits mailing list