Skip to content

Test that largefiles can be read through the tree API#4874

Merged
ethomson merged 6 commits intolibgit2:masterfrom
tiennou:test/4615
Apr 4, 2019
Merged

Test that largefiles can be read through the tree API#4874
ethomson merged 6 commits intolibgit2:masterfrom
tiennou:test/4615

Conversation

@tiennou
Copy link
Copy Markdown
Contributor

@tiennou tiennou commented Nov 1, 2018

This is the test case for #4615, ported to clar.

Now I'm hoping fcntl is something portable 🤞.

@tiennou
Copy link
Copy Markdown
Contributor Author

tiennou commented Nov 1, 2018

Note that it's a green test locally, so it look like it's fixed (on the off-chance that the build is red, or that invasive tests are not enabled — I don't recall).

Comment thread tests/object/tree/read.c Outdated
Comment thread tests/object/tree/read.c Outdated
Comment thread tests/object/tree/read.c
@tiennou tiennou force-pushed the test/4615 branch 2 times, most recently from 7d4674c to ccb82f3 Compare January 13, 2019 22:28
Comment thread tests/object/tree/read.c Outdated
Comment thread tests/object/tree/read.c Outdated
@ethomson
Copy link
Copy Markdown
Member

Attempting to add a Win32 version of p_fallocate...

Comment thread src/win32/posix_w32.c
return p_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode);
}

int p_fallocate(int fd, off_t offset, off_t len)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might make sense to have some tests in tests/core/posix.c, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test - I'm always a little nervous testing the POSIX stuff because it's easy to get caught up testing everybody else's implementation. 😀 But let's give it a shot.

Emulate `p_fallocate` on Windows by seeking beyond the end of the file
and setting the size to the current seek position.
On macOS, fcntl(..., F_PREALLOCATE, ...) will only succeed when followed
by an ftruncate(), even when it reports success.

However, that syscall will fail when the file already exists.  Thus, we
must ignore the error code and simply let ftruncate extend the size of
the file itself (albeit slowly).

By calling ftruncate, we also need to prevent against file shrinkage,
for compatibility with posix_ftruncate, which will only extend files,
never shrink them.
Copy link
Copy Markdown
Contributor Author

@tiennou tiennou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for taking care of Windows @ethomson !

(Turns out I can't approve, since this is actually "my own" PR, so here it is 👍).

@ethomson
Copy link
Copy Markdown
Member

ethomson commented Apr 4, 2019

Cool cool. Thanks, @tiennou!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants