From 80162c126bfefcf4c2a3bfd06042f4c672397d96 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Wed, 25 Sep 2019 19:21:22 -0700 Subject: [PATCH] Add test for writing to multiple offsets References #1098. --- test/integration-test-main.sh | 7 +++++++ test/write_multiple_offsets.py | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100755 test/write_multiple_offsets.py diff --git a/test/integration-test-main.sh b/test/integration-test-main.sh index 5fca3b4..4bc058c 100755 --- a/test/integration-test-main.sh +++ b/test/integration-test-main.sh @@ -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 diff --git a/test/write_multiple_offsets.py b/test/write_multiple_offsets.py new file mode 100755 index 0000000..a013299 --- /dev/null +++ b/test/write_multiple_offsets.py @@ -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