[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 09/44] tests/functional: Set up logging
From: |
Thomas Huth |
Subject: |
[PATCH v5 09/44] tests/functional: Set up logging |
Date: |
Fri, 30 Aug 2024 15:38:03 +0200 |
Create log files for each test separately, one file that contains
the basic logging and one that contains the console output.
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/functional/qemu_test/testcase.py | 27 +++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/tests/functional/qemu_test/testcase.py
b/tests/functional/qemu_test/testcase.py
index 6905675778..b2dd863c6e 100644
--- a/tests/functional/qemu_test/testcase.py
+++ b/tests/functional/qemu_test/testcase.py
@@ -31,7 +31,8 @@ class QemuBaseTest(unittest.TestCase):
arch = None
workdir = None
- log = logging.getLogger('qemu-test')
+ log = None
+ logdir = None
def setUp(self, bin_prefix):
self.assertIsNotNone(self.qemu_bin, 'QEMU_TEST_QEMU_BINARY must be
set')
@@ -41,6 +42,20 @@ def setUp(self, bin_prefix):
self.id())
os.makedirs(self.workdir, exist_ok=True)
+ self.logdir = self.workdir
+ self.log = logging.getLogger('qemu-test')
+ self.log.setLevel(logging.DEBUG)
+ self._log_fh = logging.FileHandler(os.path.join(self.logdir,
+ 'base.log'), mode='w')
+ self._log_fh.setLevel(logging.DEBUG)
+ fileFormatter = logging.Formatter(
+ '%(asctime)s - %(levelname)s: %(message)s')
+ self._log_fh.setFormatter(fileFormatter)
+ self.log.addHandler(self._log_fh)
+
+ def tearDown(self):
+ self.log.removeHandler(self._log_fh)
+
def main():
path = os.path.basename(sys.argv[0])[:-3]
tr = pycotap.TAPTestRunner(message_log = pycotap.LogMode.LogToError,
@@ -60,6 +75,15 @@ def setUp(self):
super().setUp('qemu-system-')
+ console_log = logging.getLogger('console')
+ console_log.setLevel(logging.DEBUG)
+ self._console_log_fh = logging.FileHandler(os.path.join(self.workdir,
+ 'console.log'), mode='w')
+ self._console_log_fh.setLevel(logging.DEBUG)
+ fileFormatter = logging.Formatter('%(asctime)s: %(message)s')
+ self._console_log_fh.setFormatter(fileFormatter)
+ console_log.addHandler(self._console_log_fh)
+
def set_machine(self, machinename):
# TODO: We should use QMP to get the list of available machines
if not self._machinehelp:
@@ -150,4 +174,5 @@ def set_vm_arg(self, arg, value):
def tearDown(self):
for vm in self._vms.values():
vm.shutdown()
+ logging.getLogger('console').removeHandler(self._console_log_fh)
super().tearDown()
--
2.46.0
- [PATCH v5 00/44] Convert avocado tests to normal Python unittests, Thomas Huth, 2024/08/30
- [PATCH v5 01/44] tests/avocado: machine aarch64: standardize location and RO access, Thomas Huth, 2024/08/30
- [PATCH v5 02/44] tests/avocado/boot_xen.py: fetch kernel during test setUp(), Thomas Huth, 2024/08/30
- [PATCH v5 03/44] tests/avocado/machine_aarch64_sbsaref.py: allow for rw usage of image, Thomas Huth, 2024/08/30
- [PATCH v5 04/44] Bump avocado to 103.0, Thomas Huth, 2024/08/30
- [PATCH v5 05/44] tests/avocado/avocado_qemu: Fix the "from" statements in linuxtest.py, Thomas Huth, 2024/08/30
- [PATCH v5 07/44] python: Install pycotap in our venv if necessary, Thomas Huth, 2024/08/30
- [PATCH v5 06/44] tests/avocado/boot_linux_console: Remove the s390x subtest, Thomas Huth, 2024/08/30
- [PATCH v5 08/44] tests/functional: Add base classes for the upcoming pytest-based tests, Thomas Huth, 2024/08/30
- [PATCH v5 09/44] tests/functional: Set up logging,
Thomas Huth <=
- [PATCH v5 10/44] tests/Makefile.include: Increase the level of indentation in the help text, Thomas Huth, 2024/08/30
- [PATCH v5 11/44] tests/functional: Prepare the meson build system for the functional tests, Thomas Huth, 2024/08/30
- [PATCH v5 12/44] tests/functional: Convert simple avocado tests into standalone python tests, Thomas Huth, 2024/08/30
- [PATCH v5 14/44] tests/functional: add a module for handling asset download & caching, Thomas Huth, 2024/08/30
- [PATCH v5 13/44] tests/functional: Convert avocado tests that just need a small adjustment, Thomas Huth, 2024/08/30
- [PATCH v5 15/44] tests/functional: enable pre-emptive caching of assets, Thomas Huth, 2024/08/30
- [PATCH v5 16/44] tests/functional: Allow asset downloading with concurrent threads, Thomas Huth, 2024/08/30
- [PATCH v5 17/44] tests/functional: Convert some tests that download files via fetch_asset(), Thomas Huth, 2024/08/30
- [PATCH v5 18/44] tests/functional: Add a function for extracting files from an archive, Thomas Huth, 2024/08/30
- [PATCH v5 19/44] tests/functional: Convert some avocado tests that needed avocado.utils.archive, Thomas Huth, 2024/08/30