[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/22] qemu-iotests: Fix FilePaths docstring
From: |
Max Reitz |
Subject: |
[PULL 02/22] qemu-iotests: Fix FilePaths docstring |
Date: |
Tue, 15 Sep 2020 12:46:07 +0200 |
From: Nir Soffer <nirsof@gmail.com>
When this class was extracted from FilePath, the docstring was not
updated for generating multiple files, and the example usage was
referencing unrelated file.
While fixing the docstring, add example for creating sockets, which
should use iotests.sock_dir instead of the default base_dir.
Fixes: de263986b5dc
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Message-Id: <20200828232152.205833-3-nsoffer@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
tests/qemu-iotests/iotests.py | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 36814daf84..bbe63a6da0 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -450,14 +450,21 @@ def file_pattern(name):
class FilePaths:
"""
- FilePaths is an auto-generated filename that cleans itself up.
+ Context manager generating multiple file names. The generated files are
+ removed when exiting the context.
- Use this context manager to generate filenames and ensure that the file
- gets deleted::
+ Example usage:
+
+ with FilePaths(['a.img', 'b.img']) as (img_a, img_b):
+ # Use img_a and img_b here...
+
+ # a.img and b.img are automatically removed here.
+
+ By default images are created in iotests.test_dir. To create sockets use
+ iotests.sock_dir:
+
+ with FilePaths(['a.sock'], base_dir=iotests.sock_dir) as (sock,):
- with FilePaths(['test.img']) as img_path:
- qemu_img('create', img_path, '1G')
- # migration_sock_path is automatically deleted
"""
def __init__(self, names, base_dir=test_dir):
self.paths = []
--
2.26.2
- [PULL 00/22] Block patches, Max Reitz, 2020/09/15
- [PULL 01/22] qemu-iotests: Fix FilePaths cleanup, Max Reitz, 2020/09/15
- [PULL 02/22] qemu-iotests: Fix FilePaths docstring,
Max Reitz <=
- [PULL 03/22] qemu-iotests: Support varargs syntax in FilePaths, Max Reitz, 2020/09/15
- [PULL 04/22] qemu-iotests: Merge FilePaths and FilePath, Max Reitz, 2020/09/15
- [PULL 05/22] qemu-iotests: Simplify FilePath __init__, Max Reitz, 2020/09/15
- [PULL 06/22] block/quorum.c: stable children names, Max Reitz, 2020/09/15
- [PULL 07/22] qemu-img: avoid unaligned read requests during convert, Max Reitz, 2020/09/15
- [PULL 08/22] qcow2: Use macros for the L1, refcount and bitmap table entry sizes, Max Reitz, 2020/09/15
- [PULL 10/22] qcow2: Don't check nb_clusters when removing l2meta from the list, Max Reitz, 2020/09/15
- [PULL 11/22] qcow2: Rewrite the documentation of qcow2_alloc_cluster_offset(), Max Reitz, 2020/09/15
- [PULL 12/22] qemu-img: Explicit number replaced by a constant, Max Reitz, 2020/09/15
- [PULL 09/22] qcow2: Fix removal of list members from BDRVQcow2State.cluster_allocs, Max Reitz, 2020/09/15