-
Notifications
You must be signed in to change notification settings - Fork 171
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
Add a C API test for appending #198
base: master
Are you sure you want to change the base?
Conversation
// | ||
// Using O_APPEND itself does not produce the same result. Opening a file with | ||
// O_APPEND and writing to it will create hole of the appropriate size to make | ||
// the previous chunk reach the chunksize. This can be useful as an atomic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"This can be useful as an atomic append, but is not the behavior you'd expect from a normal filesystem."
I don't think this statement is needed here.
|
||
// Generate the string consisting of the testdata twice | ||
char expected_str[expected_len]; | ||
strcpy(expected_str, testdata); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use memcpy instead of strcpy followed by strcat?
@noahgoldman Can you squeeze this into a single commit? One that reads something like "Add an append test by writing, closing, then seeking and writing ...". |
strcpy(expected_str, testdata); | ||
strcat(expected_str, testdata); | ||
|
||
char buf[expected_len]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if variable sized array declaration is a good idea.
c35348d
to
41c45e0
Compare
Current coverage is 64.89% (diff: 100%)@@ master #198 diff @@
==========================================
Files 8 8
Lines 245 245
Methods 34 34
Messages 0 0
Branches 31 31
==========================================
Hits 159 159
Misses 69 69
Partials 17 17
|
This adds a test for appending to a file by writing, closing the file, opening it again and seeking to the end, then writing again. I added a clarifying comment before the test describing why this method is used as opposed to just opening the file with "O_APPEND".
@mckurt Updated this PR from your comments:
|
This adds a test for appending to a file by writing, closing the file, opening it again and seeking to the end, then writing again. I added a clarifying comment before the test describing why this method is used as opposed to just opening the file with "O_APPEND".
@kstinsonqc @mckurt @mikeov