iotests: clean up resources using context managers
Status from this message: Thanks, applied to my block-next tree:
Get series with b4
b4 am [email protected]Versions newest first
Patches in v1 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | qemu.py: make VM() a context managerscripts/ | +15 | 1 reply | |
| 2/3 | iotests.py: add FilePath context managertests/ | +26 | 0 replies | |
| 3/3 | qemu-iotests: use context managers for resource cleanup in 194tests/ | +41 | 0 replies |
Reviews trailers per patch
1 of 3 patches has a Reviewed-by or Acked-by.
| Patch | Eduardo Habkost |
|---|---|
| 1/3 | R-b |
| 2/3 | |
| 3/3 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers
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 automaticallyThe 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(-)
Signature · 1 line
2.13.5