Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc] fixup ftello test #87282

Merged
merged 1 commit into from
Apr 1, 2024
Merged

Conversation

nickdesaulniers
Copy link
Member

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

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 llvm#86928
@nickdesaulniers
Copy link
Member Author

cc @Sh0g0-1758

@llvmbot
Copy link

llvmbot commented Apr 1, 2024

@llvm/pr-subscribers-libc

Author: Nick Desaulniers (nickdesaulniers)

Changes

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


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

1 Files Affected:

  • (modified) libc/test/src/stdio/ftell_test.cpp (+1-1)
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));

@nickdesaulniers nickdesaulniers merged commit 70e189f into llvm:main Apr 1, 2024
6 checks passed
@nickdesaulniers nickdesaulniers deleted the fseeko2 branch April 1, 2024 21:13
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.

3 participants