[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context m
From: |
Fam Zheng |
Subject: |
Re: [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers |
Date: |
Thu, 24 Aug 2017 16:38:43 +0800 |
User-agent: |
Mutt/1.8.3 (2017-05-23) |
On Thu, 08/24 08:21, Stefan Hajnoczi wrote:
> 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
Looks good but still requires test writers to learn and remember to use FilePath
and with. These are still boilerplates. Here goes my personal oppinion, so may
not be plausible:
- For VM() maybe add an atexit in the launch() method also makes sure the VM is
eventually terminated.
This means vm.shutdown() is still needed in tearDown() if there are multiple
test methods and each of them expects a clean state, but that is probably
still less typing (and also indenting) than the with approach, and also easy
to remember (otherwise a test will fail).
- For scratch how about adding atexit in iotests.main to clean up everything in
the scratch directory? The rationale is similar to above.
Fam
- [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers, Stefan Hajnoczi, 2017/08/24
- [Qemu-devel] [PATCH 2/3] iotests.py: add FilePath context manager, Stefan Hajnoczi, 2017/08/24
- [Qemu-devel] [PATCH 1/3] qemu.py: make VM() a context manager, Stefan Hajnoczi, 2017/08/24
- [Qemu-devel] [PATCH 3/3] qemu-iotests: use context managers for resource cleanup in 194, Stefan Hajnoczi, 2017/08/24
- Re: [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers,
Fam Zheng <=
- Re: [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers, Stefan Hajnoczi, 2017/08/24
- Re: [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers, Fam Zheng, 2017/08/25
- Re: [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers, Stefan Hajnoczi, 2017/08/25
- Re: [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers, Fam Zheng, 2017/08/25
- Re: [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers, Stefan Hajnoczi, 2017/08/30
- Re: [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers, Fam Zheng, 2017/08/30
- Re: [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers, Markus Armbruster, 2017/08/28
Re: [Qemu-devel] [PATCH 0/3] iotests: clean up resources using context managers, Stefan Hajnoczi, 2017/08/31