@@ -8,7 +8,6 @@
# This work is licensed under the terms of the GNU GPL, version 2 or
# later. See the COPYING file in the top-level directory.
-import logging
import os
import shutil
import subprocess
@@ -138,7 +137,7 @@ def _console_interaction(test, success_message, failure_message,
if vm is None:
vm = test.vm
console = vm.console_socket.makefile(mode='rb', encoding='utf-8')
- console_logger = logging.getLogger('console')
+ console_logger = test.log.getChild('console')
while True:
if send_string:
vm.console_socket.sendall(send_string.encode())
@@ -370,7 +369,7 @@ class LinuxSSHMixIn:
"""Contains utility methods for interacting with a guest via SSH."""
def ssh_connect(self, username, credential, credential_is_key=True):
- self.ssh_logger = logging.getLogger('ssh')
+ self.ssh_logger = self.log.getChild('ssh')
res = self.vm.command('human-monitor-command',
command_line='info usernet')
port = get_info_usernet_hostfwd_port(res)
@@ -9,7 +9,6 @@
# later. See the COPYING file in the top-level directory.
import os
-import logging
import tempfile
from avocado_qemu import QemuSystemTest
@@ -79,7 +78,7 @@ def test_with_2gib_file_should_work_with_linux_v4_16(self):
'-m', '5120')
self.vm.launch()
console = self.vm.console_socket.makefile()
- console_logger = logging.getLogger('console')
+ console_logger = self.log.getChild('console')
while True:
msg = console.readline()
console_logger.debug(msg.strip())
@@ -9,7 +9,6 @@
# later. See the COPYING file in the top-level directory.
import os
-import logging
from avocado import skipUnless
from avocado_qemu import QemuSystemTest
@@ -84,7 +83,7 @@ def test_framebuffer_tux_logo(self):
self.vm.command('human-monitor-command', command_line='stop')
self.vm.command('human-monitor-command',
command_line='screendump %s' % screendump_path)
- logger = logging.getLogger('framebuffer')
+ logger = self.log.getChild('framebuffer')
cpu_count = 1
match_threshold = 0.92
@@ -9,7 +9,6 @@
import os
import gzip
-import logging
from avocado import skipUnless
from avocado_qemu import QemuSystemTest
@@ -72,7 +71,7 @@ def do_test_i6400_framebuffer_logo(self, cpu_cores_count):
self.vm.command('human-monitor-command', command_line='stop')
self.vm.command('human-monitor-command',
command_line='screendump %s' % screendump_path)
- logger = logging.getLogger('framebuffer')
+ logger = self.log.getChild('framebuffer')
match_threshold = 0.95
screendump_bgr = cv2.imread(screendump_path, cv2.IMREAD_COLOR)
@@ -11,7 +11,6 @@
import os
import lzma
import shutil
-import logging
import time
from avocado import skip
@@ -36,7 +35,7 @@ class ReplayKernelBase(LinuxKernelTest):
def run_vm(self, kernel_path, kernel_command_line, console_pattern,
record, shift, args, replay_path):
- logger = logging.getLogger('replay')
+ logger = self.log.getChild('replay')
start_time = time.time()
vm = self.get_vm()
vm.set_console()
@@ -74,7 +73,7 @@ def run_rr(self, kernel_path, kernel_command_line, console_pattern,
True, shift, args, replay_path)
t2 = self.run_vm(kernel_path, kernel_command_line, console_pattern,
False, shift, args, replay_path)
- logger = logging.getLogger('replay')
+ logger = self.log.getChild('replay')
logger.info('replay overhead {:.2%}'.format(t2 / t1 - 1))
class ReplayKernelNormal(ReplayKernelBase):
@@ -9,7 +9,6 @@
# later. See the COPYING file in the top-level directory.
import os
-import logging
import time
from avocado import skipUnless
@@ -55,7 +54,7 @@ def launch_and_wait(self, record, args, shift):
vm.add_args(*args)
self.vm_add_disk(vm, self.boot_path, 0, self.hdd)
self.vm_add_disk(vm, self.cloudinit_path, 1, self.cd)
- logger = logging.getLogger('replay')
+ logger = self.log.getChild('replay')
if record:
logger.info('recording the execution...')
mode = 'record'
@@ -91,7 +90,7 @@ def launch_and_wait(self, record, args, shift):
def run_rr(self, args=None, shift=7):
t1 = self.launch_and_wait(True, args, shift)
t2 = self.launch_and_wait(False, args, shift)
- logger = logging.getLogger('replay')
+ logger = self.log.getChild('replay')
logger.info('replay overhead {:.2%}'.format(t2 / t1 - 1))
@skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
@@ -8,7 +8,6 @@
# This work is licensed under the terms of the GNU GPL, version 2 or
# later. See the COPYING file in the top-level directory.
import os
-import logging
from avocado import skipIf
from avocado_qemu import BUILD_DIR
@@ -35,7 +34,7 @@ class ReverseDebugging(LinuxKernelTest):
endian_is_le = True
def run_vm(self, record, shift, args, replay_path, image_path, port):
- logger = logging.getLogger('replay')
+ logger = self.log.getChild('replay')
vm = self.get_vm()
vm.set_console()
if record:
@@ -95,7 +94,7 @@ def vm_get_icount(vm):
return vm.qmp('query-replay')['return']['icount']
def reverse_debugging(self, shift=7, args=None):
- logger = logging.getLogger('replay')
+ logger = self.log.getChild('replay')
# create qcow2 for snapshots
logger.info('creating qcow2 image for VM snapshots')
@@ -31,8 +31,8 @@ def tesseract_available(expected_version):
def tesseract_ocr(image_path, tesseract_args='', tesseract_version=3):
- console_logger = logging.getLogger('tesseract')
- console_logger.debug(image_path)
+ logger = logging.getLogger('avocado.test.tesseract')
+ logger.debug(image_path)
if tesseract_version == 4:
tesseract_args += ' --oem 1'
proc = process.run("tesseract {} {} stdout".format(tesseract_args,
@@ -41,6 +41,6 @@ def tesseract_ocr(image_path, tesseract_args='', tesseract_version=3):
for line in proc.stdout_text.split('\n'):
sline = line.strip()
if len(sline):
- console_logger.debug(sline)
+ logger.debug(sline)
lines += [sline]
return lines
@@ -20,7 +20,6 @@
import sys
import os
import re
-import logging
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
from qemu.machine import QEMUMachine
@@ -75,7 +74,7 @@ def query_virtqueue(self, vm, dev_type_name):
def check_mt(self, mt, dev_type_name):
mt['device'] = dev_type_name # Only for the debug() call.
- logger = logging.getLogger('machine')
+ logger = self.log.getChild('machine')
logger.debug(mt)
with QEMUMachine(self.qemu_bin) as vm:
vm.set_machine(mt["name"])
Since Avocado 92.0[1], there's no universal preservation of logged content via Python's "logging" APIs into the test log files. This changes were motivated by the fact that doing so is intrusive as it touches on Python's root logger. Test writers are now expected to use "avocado." as a namespace prefix for everything that Avocado should collect/preserve, and other prefixes for logged content that should be handled differently. [1] - https://avocado-framework.readthedocs.io/en/94.0/releases/92_0.html#users-test-writers Signed-off-by: Cleber Rosa <crosa@redhat.com> --- tests/avocado/avocado_qemu/__init__.py | 5 ++--- tests/avocado/linux_initrd.py | 3 +-- tests/avocado/machine_arm_integratorcp.py | 3 +-- tests/avocado/machine_mips_malta.py | 3 +-- tests/avocado/replay_kernel.py | 5 ++--- tests/avocado/replay_linux.py | 5 ++--- tests/avocado/reverse_debugging.py | 5 ++--- tests/avocado/tesseract_utils.py | 6 +++--- tests/avocado/virtio_check_params.py | 3 +-- 9 files changed, 15 insertions(+), 23 deletions(-)