[libc-commits] [libc] [libc] fixup ftello test (PR #87282)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Mon Apr 1 13:53:24 PDT 2024


https://github.com/nickdesaulniers created https://github.com/llvm/llvm-project/pull/87282

Use a seek offset that fits within the file size.

This was missed in presubmit because the FILE based stdio tests aren't run in
overlay mode; fullbuild is not tested in presubmit.

WRITE_SIZE == 11, so using a value of 42 for offseto would cause the expression
`WRITE_SIZE - offseto` to evaluate to -31 as an unsigned 64b integer
(18446744073709551585ULL).

Fixes #86928


>From 67f038b31fe191f2636e0a4a8511ab3d69ff12be Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Mon, 1 Apr 2024 13:50:12 -0700
Subject: [PATCH] [libc] fixup ftello test

Use a seek offset that fits within the file size.

This was missed in presubmit because the FILE based stdio tests aren't run in
overlay mode; fullbuild is not tested in presubmit.

WRITE_SIZE == 11, so using a value of 42 for offseto would cause the expression
`WRITE_SIZE - offseto` to evaluate to -31 as an unsigned 64b integer
(18446744073709551585ULL).

Fixes #86928
---
 libc/test/src/stdio/ftell_test.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/test/src/stdio/ftell_test.cpp b/libc/test/src/stdio/ftell_test.cpp
index 68a969ed0c30dd..62745e2194be6d 100644
--- a/libc/test/src/stdio/ftell_test.cpp
+++ b/libc/test/src/stdio/ftell_test.cpp
@@ -39,7 +39,7 @@ class LlvmLibcFTellTest : public LIBC_NAMESPACE::testing::Test {
     // still return the correct effective offset.
     ASSERT_EQ(size_t(LIBC_NAMESPACE::ftell(file)), WRITE_SIZE);
 
-    off_t offseto = 42;
+    off_t offseto = 5;
     ASSERT_EQ(0, LIBC_NAMESPACE::fseeko(file, offseto, SEEK_SET));
     ASSERT_EQ(LIBC_NAMESPACE::ftello(file), offseto);
     ASSERT_EQ(0, LIBC_NAMESPACE::fseeko(file, -offseto, SEEK_END));



More information about the libc-commits mailing list