Merge pull request #1160 from gaul/mix_upload

Add test for writing to multiple offsets
This commit is contained in:
Takeshi Nakatani 2019-10-14 22:07:50 +09:00 committed by GitHub
commit db338b36b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 0 deletions

View File

@ -650,6 +650,12 @@ function test_open_second_fd {
rm_test_file second_fd_file rm_test_file second_fd_file
} }
function test_write_multiple_offsets {
describe "test writing to multiple offsets"
../../write_multiple_offsets.py ${TEST_TEXT_FILE}
rm_test_file
}
function add_all_tests { function add_all_tests {
add_tests test_append_file add_tests test_append_file
add_tests test_truncate_file add_tests test_truncate_file
@ -681,6 +687,7 @@ function add_all_tests {
add_tests test_concurrency add_tests test_concurrency
add_tests test_concurrent_writes add_tests test_concurrent_writes
add_tests test_open_second_fd add_tests test_open_second_fd
add_tests test_write_multiple_offsets
} }
init_suite init_suite

18
test/write_multiple_offsets.py Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env python3
import os
import sys
filename = sys.argv[1]
data = bytes('a', 'utf-8')
fd = os.open(filename, os.O_CREAT | os.O_TRUNC | os.O_WRONLY)
try:
os.pwrite(fd, data, 1024)
os.pwrite(fd, data, 16 * 1024 * 1024)
os.pwrite(fd, data, 18 * 1024 * 1024)
finally:
os.close(fd)
stat = os.lstat(filename)
assert stat.st_size == 18 * 1024 * 1024 + 1