All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nir Soffer <nirsof@gmail.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, John Snow <jsnow@redhat.com>,
	Max Reitz <mreitz@redhat.com>, Nir Soffer <nsoffer@redhat.com>
Subject: [PATCH v3 2/5] qemu-iotests: Fix FilePaths docstring
Date: Sat, 29 Aug 2020 02:21:49 +0300	[thread overview]
Message-ID: <20200828232152.205833-3-nsoffer@redhat.com> (raw)
In-Reply-To: <20200828232152.205833-1-nsoffer@redhat.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>
---
 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 2fd5c916fa..4abfe63662 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 socket 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



  parent reply	other threads:[~2020-08-28 23:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-28 23:21 [PATCH v3 0/5] iotest.FilePath fixes and cleanups Nir Soffer
2020-08-28 23:21 ` [PATCH v3 1/5] qemu-iotests: Fix FilePaths cleanup Nir Soffer
2020-08-28 23:21 ` Nir Soffer [this message]
2020-08-28 23:21 ` [PATCH v3 3/5] qemu-iotests: Support varargs syntax in FilePaths Nir Soffer
2020-08-28 23:21 ` [PATCH v3 4/5] qemu-iotests: Merge FilePaths and FilePath Nir Soffer
2020-08-28 23:21 ` [PATCH v3 5/5] qemu-iotests: Simplify FilePath __init__ Nir Soffer
2020-09-02 10:18 ` [PATCH v3 0/5] iotest.FilePath fixes and cleanups Max Reitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200828232152.205833-3-nsoffer@redhat.com \
    --to=nirsof@gmail.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=nsoffer@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.