Skip to content

Commit 6495cc2

Browse files
committed
tests/test_libvhost: add a few test cases for various sector/block sizes
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
1 parent 3c76c86 commit 6495cc2

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

tests/test_libvhost.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,16 @@ def disk_image(work_dir: str) -> Generator[str, None, None]:
7777

7878
def create_server(
7979
work_dir: str, disk_image: str, vhost_user_test_server: str,
80-
pte_flush_threshold: int = 0
80+
pte_flush_threshold: int = 0, sector_size: int = 4096,
81+
block_size: int = 4096
8182
) -> Generator[str, None, None]:
8283
socket_path = os.path.join(work_dir, "server.sock")
8384

8485
process = subprocess.Popen([
8586
vhost_user_test_server, "--disk",
8687
f"socket-path={socket_path},blk-file={disk_image}"
8788
f",serial=helloworld,pte-flush-threshold={pte_flush_threshold}"
89+
f",sector-size={sector_size},block-size={block_size}"
8890
])
8991

9092
retry = 0
@@ -122,6 +124,15 @@ def server_socket_with_pte_flush(
122124
request.param)
123125

124126

127+
@pytest.fixture(scope="class")
128+
def server_socket_with_custom_sector_size(
129+
request: pytest.FixtureRequest, work_dir: str, disk_image: str,
130+
vhost_user_test_server: str
131+
) -> Generator[str, None, None]:
132+
yield from create_server(work_dir, disk_image, vhost_user_test_server,
133+
0, *request.param)
134+
135+
125136
def pretty_print_blkio_config(param: List[str]) -> str:
126137
return f"{param[0]}, blocksize={param[1]}"
127138

@@ -171,3 +182,23 @@ def test_pte_flush(
171182
) -> None:
172183
check_run_blkio_bench(blkio_bench, "randread", 4096, time,
173184
server_socket_with_pte_flush)
185+
186+
187+
@pytest.mark.parametrize(
188+
'server_socket_with_custom_sector_size, block_size',
189+
[
190+
# Test different sector sizes
191+
# Format is: [[sector_size, block_size], blkio_bench_block_size]
192+
[[1024, 2048], 2048],
193+
[[4096, 4096], 4096],
194+
[[2048, 8192], 8192],
195+
],
196+
indirect=['server_socket_with_custom_sector_size']
197+
)
198+
class TestSectorSizes:
199+
def test_sector_sizes(
200+
self, server_socket_with_custom_sector_size: str, block_size: int,
201+
blkio_bench: str
202+
) -> None:
203+
check_run_blkio_bench(blkio_bench, "randread", block_size, 1,
204+
server_socket_with_custom_sector_size)

0 commit comments

Comments
 (0)