diff --git a/test/integration-test-main.sh b/test/integration-test-main.sh index 7690f36..689156b 100755 --- a/test/integration-test-main.sh +++ b/test/integration-test-main.sh @@ -670,7 +670,13 @@ function test_open_second_fd { function test_write_multiple_offsets { describe "test writing to multiple offsets" - ../../write_multiple_offsets.py ${TEST_TEXT_FILE} + ../../write_multiple_offsets.py ${TEST_TEXT_FILE} 1024 1 $((16 * 1024 * 1024)) 1 $((18 * 1024 * 1024)) 1 + rm_test_file ${TEST_TEXT_FILE} +} + +function test_write_multiple_offsets_backwards { + describe "test writing to multiple offsets" + ../../write_multiple_offsets.py ${TEST_TEXT_FILE} $((20 * 1024 * 1024 + 1)) 1 $((10 * 1024 * 1024)) 1 rm_test_file ${TEST_TEXT_FILE} } @@ -780,6 +786,7 @@ function add_all_tests { add_tests test_concurrent_writes add_tests test_open_second_fd add_tests test_write_multiple_offsets + add_tests test_write_multiple_offsets_backwards add_tests test_content_type add_tests test_truncate_cache } diff --git a/test/write_multiple_offsets.py b/test/write_multiple_offsets.py index a013299..4da52c8 100755 --- a/test/write_multiple_offsets.py +++ b/test/write_multiple_offsets.py @@ -3,16 +3,15 @@ import os import sys +if len(sys.argv) < 4 or len(sys.argv) % 2 != 0: + sys.exit("Usage: %s OUTFILE OFFSET_1 SIZE_1 [OFFSET_N SIZE_N]...") + 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) + for i in range(2, len(sys.argv), 2): + data = bytes("a" * int(sys.argv[i+1]), 'utf-8') + os.pwrite(fd, data, int(sys.argv[i])) finally: os.close(fd) - -stat = os.lstat(filename) -assert stat.st_size == 18 * 1024 * 1024 + 1