qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* what is the right way for an avocado test to do "wait for text that doesn't end in newline" ?
@ 2024-10-01 12:43 Peter Maydell
  2024-10-01 16:21 ` Alex Bennée
  2024-10-01 16:29 ` Daniel P. Berrangé
  0 siblings, 2 replies; 3+ messages in thread
From: Peter Maydell @ 2024-10-01 12:43 UTC (permalink / raw)
  To: QEMU Developers
  Cc: Thomas Huth, Cleber Rosa, Phil Mathieu-Daudé,
	Wainer dos Santos Moschetta, John Snow

One common thing to want to do in an avocado test is log into
the guest. The obvious way to do that would seem to be:

         self.wait_for_console_pattern('login:')
         exec_command(self, 'root')
         self.wait_for_console_pattern('Password:')
         exec_command(self, "passw0rd")

This doesn't work; Thomas tells me that's because the
wait_for_console_pattern function requires that the guest outputs
a newline, but the 'login:' and 'Password:' prompt lines don't
have a newline after them.

What is the right way to do this common thing?

In tests/avocado at the moment we have:

tests/avocado/machine_aspeed.py:
        self.wait_for_console_pattern("the last line before login:")
        time.sleep(0.1)
        exec_command(self, 'root')
        time.sleep(0.1)
        exec_command(self, "passw0rd")

This is flaky -- on my machine the test times out once in every
two or three iterations.
run_tuxtest_tests also tries the same sleep trick.

tests/functional/test_ppc64_hv.py:
        wait_for_console_pattern(self, 'Welcome to Alpine Linux 3.18')
        exec_command(self, 'root')
        wait_for_console_pattern(self, 'localhost login:')
which sends the login username and *then* waits for the login prompt.

tests/avocado/boot_linux_console.py:
doesn't try to log in, just ends the test at login:
        self.wait_for_console_pattern('gsj login:')
This test has been marked as "might timeout", which suggests this
isn't actually effective...

thanks
-- PMM


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-01 16:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-01 12:43 what is the right way for an avocado test to do "wait for text that doesn't end in newline" ? Peter Maydell
2024-10-01 16:21 ` Alex Bennée
2024-10-01 16:29 ` Daniel P. Berrangé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).