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