[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 08/10] iotests.py: add verify_o_direct helper
From: |
Nir Soffer |
Subject: |
Re: [PATCH v4 08/10] iotests.py: add verify_o_direct helper |
Date: |
Fri, 21 Aug 2020 00:00:34 +0300 |
On Thu, Aug 20, 2020 at 9:49 PM Vladimir Sementsov-Ogievskiy
<vsementsov@virtuozzo.com> wrote:
>
> Add python notrun-helper similar to _check_o_direct for bash tests.
> To be used in the following commit.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> tests/qemu-iotests/iotests.py | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
> index 717b5b652c..369e9918b4 100644
> --- a/tests/qemu-iotests/iotests.py
> +++ b/tests/qemu-iotests/iotests.py
> @@ -1083,6 +1083,12 @@ def _verify_aio_mode(supported_aio_modes:
> Sequence[str] = ()) -> None:
> if supported_aio_modes and (aiomode not in supported_aio_modes):
> notrun('not suitable for this aio mode: %s' % aiomode)
>
> +def verify_o_direct() -> None:
> + with FilePath('test_o_direct') as f:
> + qemu_img_create('-f', 'raw', f, '1M')
> + if 'O_DIRECT' in qemu_io('-f', 'raw', '-t', 'none', '-c', 'quit', f):
> + notrun(f'file system at {test_dir} does not support O_DIRECT')
Why not:
with FilePath('test_o_direct') as f:
try:
fd = os.open(f, os.O_DIRECT | os.O_CREAT | os.O_RDWR)
except OSError as e:
if e.errno != errno.EINVAL:
raise
notrun(...)
else:
os.close(fd)
More verbose, but the intent is more clear, and we do not depend on the output
of qemu-io which is not a public API. For example if someone improves qemu-io
to fail with:
Direct I/O is not supported
It would break the tests using this helper.
Nir
> +
> def supports_quorum():
> return 'quorum' in qemu_img_pipe('--help')
>
> --
> 2.21.3
>
>
- [PATCH v4 00/10] preallocate filter, Vladimir Sementsov-Ogievskiy, 2020/08/20
- [PATCH v4 01/10] block: simplify comment to BDRV_REQ_SERIALISING, Vladimir Sementsov-Ogievskiy, 2020/08/20
- [PATCH v4 02/10] block/io.c: drop assertion on double waiting for request serialisation, Vladimir Sementsov-Ogievskiy, 2020/08/20
- [PATCH v4 03/10] block/io: split out bdrv_find_conflicting_request, Vladimir Sementsov-Ogievskiy, 2020/08/20
- [PATCH v4 04/10] block/io: bdrv_wait_serialising_requests_locked: drop extra bs arg, Vladimir Sementsov-Ogievskiy, 2020/08/20
- [PATCH v4 05/10] block: bdrv_mark_request_serialising: split non-waiting function, Vladimir Sementsov-Ogievskiy, 2020/08/20
- [PATCH v4 06/10] block: introduce BDRV_REQ_NO_WAIT flag, Vladimir Sementsov-Ogievskiy, 2020/08/20
- [PATCH v4 07/10] block: introduce preallocate filter, Vladimir Sementsov-Ogievskiy, 2020/08/20
- [PATCH v4 08/10] iotests.py: add verify_o_direct helper, Vladimir Sementsov-Ogievskiy, 2020/08/20
- Re: [PATCH v4 08/10] iotests.py: add verify_o_direct helper,
Nir Soffer <=
- [PATCH v4 09/10] iotests.py: add filter_img_check, Vladimir Sementsov-Ogievskiy, 2020/08/20
- [PATCH v4 10/10] iotests: add 298 to test new preallocate filter driver, Vladimir Sementsov-Ogievskiy, 2020/08/20
- Re: [PATCH v4 00/10] preallocate filter, no-reply, 2020/08/20