Add test for writing to multiple offsets

References #1098.
This commit is contained in:
Andrew Gaul 2019-09-25 19:21:22 -07:00
parent 1db94a0b30
commit 80162c126b
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
}
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 {
add_tests test_append_file
add_tests test_truncate_file
@ -681,6 +687,7 @@ function add_all_tests {
add_tests test_concurrency
add_tests test_concurrent_writes
add_tests test_open_second_fd
add_tests test_write_multiple_offsets
}
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