Skip to content

Conversation

@michaelrj-google
Copy link
Contributor

@michaelrj-google michaelrj-google commented Apr 3, 2025

The main issue was that the kernel expected suseconds_t to be 64 bits but ours was 32. This caused inconsistent failures since all valid suseconds_t values are less than 1000000 (1 million), and some configurations caused struct timeval to be padded to 128 bits.

Also: forgot to use TEST_FILE instead of FILE_PATH in some places.

@llvmbot llvmbot added the libc label Apr 4, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 4, 2025

@llvm/pr-subscribers-libc

Author: Michael Jones (michaelrj-google)

Changes

Forgot to use TEST_FILE instead of FILE_PATH in some places.


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

1 Files Affected:

  • (modified) libc/test/src/sys/time/utimes_test.cpp (+4-4)
diff --git a/libc/test/src/sys/time/utimes_test.cpp b/libc/test/src/sys/time/utimes_test.cpp
index 69607ba928e1e..802900e8be7fc 100644
--- a/libc/test/src/sys/time/utimes_test.cpp
+++ b/libc/test/src/sys/time/utimes_test.cpp
@@ -36,11 +36,11 @@ TEST(LlvmLibcUtimesTest, ChangeTimesSpecific) {
   times[1].tv_usec = 23456;
 
   // ensure utimes succeeds
-  ASSERT_THAT(LIBC_NAMESPACE::utimes(FILE_PATH, times), Succeeds(0));
+  ASSERT_THAT(LIBC_NAMESPACE::utimes(TEST_FILE, times), Succeeds(0));
 
   // verify the times values against stat of the TEST_FILE
   struct stat statbuf;
-  ASSERT_EQ(LIBC_NAMESPACE::stat(FILE_PATH, &statbuf), 0);
+  ASSERT_EQ(LIBC_NAMESPACE::stat(TEST_FILE, &statbuf), 0);
 
   // seconds
   ASSERT_EQ(statbuf.st_atim.tv_sec, times[0].tv_sec);
@@ -76,7 +76,7 @@ TEST(LlvmLibcUtimesTest, InvalidMicroseconds) {
   times[1].tv_usec = 1000000; // invalid
 
   // ensure utimes fails
-  ASSERT_THAT(LIBC_NAMESPACE::utimes(FILE_PATH, times), Fails(EINVAL));
+  ASSERT_THAT(LIBC_NAMESPACE::utimes(TEST_FILE, times), Fails(EINVAL));
 
   // check for failure on
   // the other possible bad values
@@ -87,6 +87,6 @@ TEST(LlvmLibcUtimesTest, InvalidMicroseconds) {
   times[1].tv_usec = 1000;
 
   // ensure utimes fails once more
-  ASSERT_THAT(LIBC_NAMESPACE::utimes(FILE_PATH, times), Fails(EINVAL));
+  ASSERT_THAT(LIBC_NAMESPACE::utimes(TEST_FILE, times), Fails(EINVAL));
   ASSERT_THAT(LIBC_NAMESPACE::remove(TEST_FILE), Succeeds(0));
 }

@michaelrj-google michaelrj-google changed the title [libc] Fix utimes use of file paths [libc] Fix suseconds_t definition and utimes_test Apr 4, 2025
@michaelrj-google michaelrj-google merged commit 4c182df into llvm:main Apr 4, 2025
9 of 11 checks passed
@michaelrj-google michaelrj-google deleted the libcMoreUtimesFix branch April 4, 2025 20:04
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