[PATCH v2] acpi/tests/avocado/bits: keep the work directory when BITS_DEBUG is set in env

Ani Sinha posted 1 patch 1 year, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20221117113630.543495-1-ani@anisinha.ca
Maintainers: Ani Sinha <ani@anisinha.ca>, Cleber Rosa <crosa@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Wainer dos Santos Moschetta <wainersm@redhat.com>, Beraldo Leal <bleal@redhat.com>
tests/avocado/acpi-bits.py | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
[PATCH v2] acpi/tests/avocado/bits: keep the work directory when BITS_DEBUG is set in env
Posted by Ani Sinha 1 year, 5 months ago
Debugging bits issue often involves running the QEMU command line manually
outside of the avocado environment with the generated ISO. Hence, its
inconvenient if the iso gets cleaned up after the test has finished. This change
makes sure that the work directory is kept after the test finishes if the test
is run with BITS_DEBUG=1 in the environment so that the iso is available for use
with the QEMU command line.

CC: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Ani Sinha <ani@anisinha.ca>
---
 tests/avocado/acpi-bits.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

changelog:
changes from v1: introduced a separate BITS_DEBUG env var and tie
workdir removal with this instead of using V.

diff --git a/tests/avocado/acpi-bits.py b/tests/avocado/acpi-bits.py
index e4d60a34ce..898c837f26 100644
--- a/tests/avocado/acpi-bits.py
+++ b/tests/avocado/acpi-bits.py
@@ -263,7 +263,7 @@ def generate_bits_iso(self):
         self.logger.info('using grub-mkrescue for generating biosbits iso ...')
 
         try:
-            if os.getenv('V'):
+            if os.getenv('V') or os.getenv('BITS_DEBUG'):
                 subprocess.check_call([mkrescue_script, '-o', iso_file,
                                        bits_dir], stderr=subprocess.STDOUT)
             else:
@@ -347,7 +347,7 @@ def parse_log(self):
                 self._print_log(log)
                 raise e
             else:
-                if os.getenv('V'):
+                if os.getenv('V') or os.getenv('BITS_DEBUG'):
                     self._print_log(log)
 
     def tearDown(self):
@@ -356,8 +356,13 @@ def tearDown(self):
         """
         if self._vm:
             self.assertFalse(not self._vm.is_running)
-        self.logger.info('removing the work directory %s', self._workDir)
-        shutil.rmtree(self._workDir)
+        if not os.getenv('BITS_DEBUG'):
+            self.logger.info('removing the work directory %s', self._workDir)
+            shutil.rmtree(self._workDir)
+        else:
+            self.logger.info('not removing the work directory %s ' \
+                             'as BITS_DEBUG is ' \
+                             'passed in the environment', self._workDir)
         super().tearDown()
 
     def test_acpi_smbios_bits(self):
-- 
2.34.1