Message ID | 20190117185628.21862-11-crosa@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Acceptance Tests: target architecture support | expand |
On Thu, Jan 17, 2019 at 01:56:20PM -0500, Cleber Rosa wrote: > This introduces a utility method that monitors the console device and > looks for either a message that signals the test success or failure. > > Signed-off-by: Cleber Rosa <crosa@redhat.com> Reviewed-by: Caio Carrara <ccarrara@redhat.com> > --- > tests/acceptance/boot_linux_console.py | 30 ++++++++++++++++++-------- > 1 file changed, 21 insertions(+), 9 deletions(-) > {...} >
Hi Cleber, On 1/17/19 7:56 PM, Cleber Rosa wrote: > This introduces a utility method that monitors the console device and > looks for either a message that signals the test success or failure. > > Signed-off-by: Cleber Rosa <crosa@redhat.com> > --- > tests/acceptance/boot_linux_console.py | 30 ++++++++++++++++++-------- > 1 file changed, 21 insertions(+), 9 deletions(-) > > diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py > index 35b31162d4..278bb2be3d 100644 > --- a/tests/acceptance/boot_linux_console.py > +++ b/tests/acceptance/boot_linux_console.py > @@ -23,6 +23,25 @@ class BootLinuxConsole(Test): > > timeout = 60 > > + def wait_for_console_pattern(self, success_message, > + failure_message='Kernel panic - not syncing'): > + """ > + Waits for messages to appear on the console, while logging the content > + > + :param success_message: if this message appears, test succeeds > + :param failure_message: if this message appears, test fails > + """ > + console = self.vm.console_socket.makefile() > + console_logger = logging.getLogger('console') > + while True: > + msg = console.readline() > + console_logger.debug(msg.strip()) > + if success_message in msg: > + break > + if failure_message in msg: > + fail = 'Failure message found in console: %s' % failure_message > + self.fail(fail) > + This helper is more generic than the BootLinuxConsole class, can you move it out? I'd like to use it in test_uefi_ovmf_x86_64_pc and test_uefi_armvirtqemu_aarch64_virt. Anyway this can be a follow-up patch, so regardless: Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> > def test_x86_64_pc(self): > """ > :avocado: tags=arch:x86_64 > @@ -39,12 +58,5 @@ class BootLinuxConsole(Test): > self.vm.add_args('-kernel', kernel_path, > '-append', kernel_command_line) > self.vm.launch() > - console = self.vm.console_socket.makefile() > - console_logger = logging.getLogger('console') > - while True: > - msg = console.readline() > - console_logger.debug(msg.strip()) > - if 'Kernel command line: %s' % kernel_command_line in msg: > - break > - if 'Kernel panic - not syncing' in msg: > - self.fail("Kernel panic reached") > + console_pattern = 'Kernel command line: %s' % kernel_command_line > + self.wait_for_console_pattern(console_pattern) >
On 1/22/19 5:06 AM, Philippe Mathieu-Daudé wrote: > Hi Cleber, > > On 1/17/19 7:56 PM, Cleber Rosa wrote: >> This introduces a utility method that monitors the console device and >> looks for either a message that signals the test success or failure. >> >> Signed-off-by: Cleber Rosa <crosa@redhat.com> >> --- >> tests/acceptance/boot_linux_console.py | 30 ++++++++++++++++++-------- >> 1 file changed, 21 insertions(+), 9 deletions(-) >> >> diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py >> index 35b31162d4..278bb2be3d 100644 >> --- a/tests/acceptance/boot_linux_console.py >> +++ b/tests/acceptance/boot_linux_console.py >> @@ -23,6 +23,25 @@ class BootLinuxConsole(Test): >> >> timeout = 60 >> >> + def wait_for_console_pattern(self, success_message, >> + failure_message='Kernel panic - not syncing'): >> + """ >> + Waits for messages to appear on the console, while logging the content >> + >> + :param success_message: if this message appears, test succeeds >> + :param failure_message: if this message appears, test fails >> + """ >> + console = self.vm.console_socket.makefile() >> + console_logger = logging.getLogger('console') >> + while True: >> + msg = console.readline() >> + console_logger.debug(msg.strip()) >> + if success_message in msg: >> + break >> + if failure_message in msg: >> + fail = 'Failure message found in console: %s' % failure_message >> + self.fail(fail) >> + > > This helper is more generic than the BootLinuxConsole class, can you > move it out? I'd like to use it in test_uefi_ovmf_x86_64_pc and > test_uefi_armvirtqemu_aarch64_virt. > > Anyway this can be a follow-up patch, so regardless: > Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> > Sure thing, I'll work on something on top of this. Tracking it here in the mean time: https://trello.com/c/oJtL1nRJ/78-create-utility-out-of-waitforconsolepattern - Cleber.
Hi Cleber, On 01/17/2019 04:56 PM, Cleber Rosa wrote: > This introduces a utility method that monitors the console device and > looks for either a message that signals the test success or failure. > > Signed-off-by: Cleber Rosa <crosa@redhat.com> > --- > tests/acceptance/boot_linux_console.py | 30 ++++++++++++++++++-------- > 1 file changed, 21 insertions(+), 9 deletions(-) > > diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py > index 35b31162d4..278bb2be3d 100644 > --- a/tests/acceptance/boot_linux_console.py > +++ b/tests/acceptance/boot_linux_console.py > @@ -23,6 +23,25 @@ class BootLinuxConsole(Test): > > timeout = 60 > > + def wait_for_console_pattern(self, success_message, > + failure_message='Kernel panic - not syncing'): > + """ > + Waits for messages to appear on the console, while logging the content > + > + :param success_message: if this message appears, test succeeds > + :param failure_message: if this message appears, test fails > + """ What's the docstring format used here? I am wondering if :type is optional. - Wainer > + console = self.vm.console_socket.makefile() > + console_logger = logging.getLogger('console') > + while True: > + msg = console.readline() > + console_logger.debug(msg.strip()) > + if success_message in msg: > + break > + if failure_message in msg: > + fail = 'Failure message found in console: %s' % failure_message > + self.fail(fail) > + > def test_x86_64_pc(self): > """ > :avocado: tags=arch:x86_64 > @@ -39,12 +58,5 @@ class BootLinuxConsole(Test): > self.vm.add_args('-kernel', kernel_path, > '-append', kernel_command_line) > self.vm.launch() > - console = self.vm.console_socket.makefile() > - console_logger = logging.getLogger('console') > - while True: > - msg = console.readline() > - console_logger.debug(msg.strip()) > - if 'Kernel command line: %s' % kernel_command_line in msg: > - break > - if 'Kernel panic - not syncing' in msg: > - self.fail("Kernel panic reached") > + console_pattern = 'Kernel command line: %s' % kernel_command_line > + self.wait_for_console_pattern(console_pattern)
On 1/31/19 12:46 PM, Wainer dos Santos Moschetta wrote: > Hi Cleber, > > On 01/17/2019 04:56 PM, Cleber Rosa wrote: >> This introduces a utility method that monitors the console device and >> looks for either a message that signals the test success or failure. >> >> Signed-off-by: Cleber Rosa <crosa@redhat.com> >> --- >> tests/acceptance/boot_linux_console.py | 30 ++++++++++++++++++-------- >> 1 file changed, 21 insertions(+), 9 deletions(-) >> >> diff --git a/tests/acceptance/boot_linux_console.py >> b/tests/acceptance/boot_linux_console.py >> index 35b31162d4..278bb2be3d 100644 >> --- a/tests/acceptance/boot_linux_console.py >> +++ b/tests/acceptance/boot_linux_console.py >> @@ -23,6 +23,25 @@ class BootLinuxConsole(Test): >> timeout = 60 >> + def wait_for_console_pattern(self, success_message, >> + failure_message='Kernel panic - not >> syncing'): >> + """ >> + Waits for messages to appear on the console, while logging >> the content >> + >> + :param success_message: if this message appears, test succeeds >> + :param failure_message: if this message appears, test fails >> + """ > > What's the docstring format used here? I am wondering if :type is optional. > > - Wainer > I've been using the same Sphinx-based docstring statements we've been using in Avocado, for the sake of cross reference. So yes, type is optional, and go on the same line, or on a different one with ":type <name of parame>". But, there may be issues that we don't know as we're not building those API docs. IIRC Eduardo Habkost is going to propose a GSOC project related to building API docs. - Cleber.
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py index 35b31162d4..278bb2be3d 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -23,6 +23,25 @@ class BootLinuxConsole(Test): timeout = 60 + def wait_for_console_pattern(self, success_message, + failure_message='Kernel panic - not syncing'): + """ + Waits for messages to appear on the console, while logging the content + + :param success_message: if this message appears, test succeeds + :param failure_message: if this message appears, test fails + """ + console = self.vm.console_socket.makefile() + console_logger = logging.getLogger('console') + while True: + msg = console.readline() + console_logger.debug(msg.strip()) + if success_message in msg: + break + if failure_message in msg: + fail = 'Failure message found in console: %s' % failure_message + self.fail(fail) + def test_x86_64_pc(self): """ :avocado: tags=arch:x86_64 @@ -39,12 +58,5 @@ class BootLinuxConsole(Test): self.vm.add_args('-kernel', kernel_path, '-append', kernel_command_line) self.vm.launch() - console = self.vm.console_socket.makefile() - console_logger = logging.getLogger('console') - while True: - msg = console.readline() - console_logger.debug(msg.strip()) - if 'Kernel command line: %s' % kernel_command_line in msg: - break - if 'Kernel panic - not syncing' in msg: - self.fail("Kernel panic reached") + console_pattern = 'Kernel command line: %s' % kernel_command_line + self.wait_for_console_pattern(console_pattern)
This introduces a utility method that monitors the console device and looks for either a message that signals the test success or failure. Signed-off-by: Cleber Rosa <crosa@redhat.com> --- tests/acceptance/boot_linux_console.py | 30 ++++++++++++++++++-------- 1 file changed, 21 insertions(+), 9 deletions(-)