All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers
@ 2017-08-24  7:21 Stefan Hajnoczi
  2017-08-24  7:22 ` [Qemu-devel] [PATCH 1/3] qemu.py: make VM() a context manager Stefan Hajnoczi
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Stefan Hajnoczi @ 2017-08-24  7:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Daniel Berrange, Stefan Hajnoczi

This series introduces context managers for the two most commonly used
resources: files and VMs.  Context managers eliminate the need to call a
cleanup function explicitly.

Tests should declare resources upfront in a with statement.  Resources are
automatically cleaned up whether the test passes or fails:

  with FilePath('test.img') as img_path,
       VM() as vm:
      ...test...
  # img_path is deleted and vm is shut down automatically

The final patch converts 194 to use context managers instead of
atexit.register().  This makes the code shorter and easier to read.

Stefan Hajnoczi (3):
  qemu.py: make VM() a context manager
  iotests.py: add FilePath context manager
  qemu-iotests: use context managers for resource cleanup in 194

 scripts/qemu.py               | 16 ++++++++-
 tests/qemu-iotests/194        | 83 +++++++++++++++++++++----------------------
 tests/qemu-iotests/iotests.py | 26 ++++++++++++++
 3 files changed, 82 insertions(+), 43 deletions(-)

-- 
2.13.5

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-08-31 11:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-24  7:21 [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers Stefan Hajnoczi
2017-08-24  7:22 ` [Qemu-devel] [PATCH 1/3] qemu.py: make VM() a context manager Stefan Hajnoczi
2017-08-25 12:44   ` Eduardo Habkost
2017-08-24  7:22 ` [Qemu-devel] [PATCH 2/3] iotests.py: add FilePath " Stefan Hajnoczi
2017-08-24  7:22 ` [Qemu-devel] [PATCH 3/3] qemu-iotests: use context managers for resource cleanup in 194 Stefan Hajnoczi
2017-08-24  8:38 ` [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers Fam Zheng
2017-08-24 18:04   ` Stefan Hajnoczi
2017-08-25  7:32     ` Fam Zheng
2017-08-25  8:52       ` Stefan Hajnoczi
2017-08-25  9:29         ` Fam Zheng
2017-08-30 12:44           ` Stefan Hajnoczi
2017-08-30 12:54             ` Fam Zheng
2017-08-28 10:55         ` Markus Armbruster
2017-08-31 11:26 ` Stefan Hajnoczi

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.