]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
qemu-iotests: Fix FilePaths docstring
authorNir Soffer <nirsof@gmail.com>
Fri, 28 Aug 2020 23:21:49 +0000 (02:21 +0300)
committerMax Reitz <mreitz@redhat.com>
Tue, 15 Sep 2020 09:05:12 +0000 (11:05 +0200)
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

index 36814daf84e58d3f9d9771bd7dda762f02ba5fd5..bbe63a6da088e7d8ffe45db804ba2426fe18761f 100644 (file)
@@ -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 = []