-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve the management of workdir cleanup for debugging purposes (#221)
- In case of test failure, we would like that the workdir of qemu is not cleaned up so that we can do some debugging. - Improve the management of environment variable TDXTEST_DEBUG that forbids the clean up of these workdirs at any case
- Loading branch information
1 parent
8fd5854
commit 80b75fd
Showing
2 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
import pytest | ||
|
||
import Qemu | ||
|
||
@pytest.fixture(autouse=True) | ||
def run_before_and_after_tests(tmpdir): | ||
""" | ||
Fixture to execute before and after a test is run | ||
Even in case of test failure | ||
""" | ||
# Setup: fill with any logic you want | ||
# enable the debug flag if TDXTEST_DEBUG is set | ||
debug = os.environ.get('TDXTEST_DEBUG', False) | ||
if debug: | ||
Qemu.QemuMachine.set_debug(debug) | ||
|
||
yield # this is where the testing happens | ||
|
||
# Teardown : fill with any logic you want | ||
|
||
def pytest_exception_interact(node, call, report): | ||
""" | ||
Called at test failure | ||
""" | ||
if report.failed: | ||
# enable debug flag to avoid cleanup to happen | ||
Qemu.QemuMachine.set_debug(True) |