Skip to content

Commit 8c8dd70

Browse files
npigginhuth
authored andcommitted
tests/functional/test_ppc64_hv: Simplify console handling
Since functional tests have character-based console output parsing, there is no need for strange hacks to work around old line-based. Signed-off-by: Nicholas Piggin <[email protected]> Message-ID: <[email protected]> Reviewed-by: Thomas Huth <[email protected]> Signed-off-by: Thomas Huth <[email protected]>
1 parent b7edbbf commit 8c8dd70

File tree

1 file changed

+19
-24
lines changed

1 file changed

+19
-24
lines changed

tests/functional/test_ppc64_hv.py

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from qemu_test import QemuSystemTest, Asset
1313
from qemu_test import wait_for_console_pattern, exec_command
1414
from qemu_test import skipIfMissingCommands, skipBigDataTest
15+
from qemu_test import exec_command_and_wait_for_pattern
1516
import os
1617
import time
1718
import subprocess
@@ -73,31 +74,28 @@ def do_start_alpine(self):
7374
"id=drive0,read-only=true")
7475

7576
self.vm.launch()
76-
wait_for_console_pattern(self, 'Welcome to Alpine Linux 3.18')
77-
exec_command(self, 'root')
77+
ps1='localhost:~#'
7878
wait_for_console_pattern(self, 'localhost login:')
79-
wait_for_console_pattern(self, 'You may change this message by editing /etc/motd.')
79+
exec_command_and_wait_for_pattern(self, 'root', ps1)
8080
# If the time is wrong, SSL certificates can fail.
81-
exec_command(self, 'date -s "' + datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S' + '"'))
82-
exec_command(self, 'setup-alpine -qe')
83-
wait_for_console_pattern(self, 'Updating repository indexes... done.')
81+
exec_command_and_wait_for_pattern(self, 'date -s "' + datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S' + '"'), ps1)
82+
ps1='alpine:~#'
83+
exec_command_and_wait_for_pattern(self, 'setup-alpine -qe', ps1)
8484

8585
def do_stop_alpine(self):
86-
exec_command(self, 'poweroff')
86+
exec_command(self, 'echo "TEST ME"')
8787
wait_for_console_pattern(self, 'alpine:~#')
88+
exec_command(self, 'poweroff')
89+
wait_for_console_pattern(self, 'reboot: Power down')
8890
self.vm.wait()
8991

9092
def do_setup_kvm(self):
91-
exec_command(self, 'echo http://dl-cdn.alpinelinux.org/alpine/v3.18/main > /etc/apk/repositories')
92-
wait_for_console_pattern(self, 'alpine:~#')
93-
exec_command(self, 'echo http://dl-cdn.alpinelinux.org/alpine/v3.18/community >> /etc/apk/repositories')
94-
wait_for_console_pattern(self, 'alpine:~#')
95-
exec_command(self, 'apk update')
96-
wait_for_console_pattern(self, 'alpine:~#')
97-
exec_command(self, 'apk add qemu-system-ppc64')
98-
wait_for_console_pattern(self, 'alpine:~#')
99-
exec_command(self, 'modprobe kvm-hv')
100-
wait_for_console_pattern(self, 'alpine:~#')
93+
ps1='alpine:~#'
94+
exec_command_and_wait_for_pattern(self, 'echo http://dl-cdn.alpinelinux.org/alpine/v3.18/main > /etc/apk/repositories', ps1)
95+
exec_command_and_wait_for_pattern(self, 'echo http://dl-cdn.alpinelinux.org/alpine/v3.18/community >> /etc/apk/repositories', ps1)
96+
exec_command_and_wait_for_pattern(self, 'apk update', ps1)
97+
exec_command_and_wait_for_pattern(self, 'apk add qemu-system-ppc64', ps1)
98+
exec_command_and_wait_for_pattern(self, 'modprobe kvm-hv', ps1)
10199

102100
# This uses the host's block device as the source file for guest block
103101
# device for install media. This is a bit hacky but allows reuse of the
@@ -116,15 +114,12 @@ def do_test_kvm(self, hpt=False):
116114
'-kernel /media/nvme0n1/boot/vmlinuz-lts '
117115
'-append \'usbcore.nousb ' + append + '\'')
118116
# Alpine 3.18 kernel seems to crash in XHCI USB driver.
119-
wait_for_console_pattern(self, 'Welcome to Alpine Linux 3.18')
120-
exec_command(self, 'root')
117+
ps1='localhost:~#'
121118
wait_for_console_pattern(self, 'localhost login:')
122-
wait_for_console_pattern(self, 'You may change this message by editing /etc/motd.')
123-
exec_command(self, 'poweroff >& /dev/null')
124-
wait_for_console_pattern(self, 'localhost:~#')
119+
exec_command_and_wait_for_pattern(self, 'root', ps1)
120+
exec_command(self, 'poweroff')
125121
wait_for_console_pattern(self, 'reboot: Power down')
126-
time.sleep(1)
127-
exec_command(self, '')
122+
# Now wait for the host's prompt to come back
128123
wait_for_console_pattern(self, 'alpine:~#')
129124

130125
def test_hv_pseries(self):

0 commit comments

Comments
 (0)