diff options
author | Alex Bennée <alex.bennee@linaro.org> | 2025-01-08 12:10:40 +0000 |
---|---|---|
committer | Alex Bennée <alex.bennee@linaro.org> | 2025-01-10 11:18:32 +0000 |
commit | b233de2af7ef97f18297ff63d658e449bad6eee3 (patch) | |
tree | 1b0b4b975ec96f02b9faa5aaa4930cdab1b3bd92 | |
parent | d524441a3610ba33c12b641c00d8e6886d411aad (diff) | |
download | qemu-b233de2af7ef97f18297ff63d658e449bad6eee3.zip qemu-b233de2af7ef97f18297ff63d658e449bad6eee3.tar.gz qemu-b233de2af7ef97f18297ff63d658e449bad6eee3.tar.bz2 |
tests/functional: remove hacky sleep from the tests
We have proper detection of prompts now so we don't need to guess with
sleep() sprinkled through the test. The extra step of calling halt is
just to flush the final bits of the log (although the last line is
still missed).
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20250108121054.1126164-19-alex.bennee@linaro.org>
-rwxr-xr-x | tests/functional/test_aarch64_virt.py | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/tests/functional/test_aarch64_virt.py b/tests/functional/test_aarch64_virt.py index 08576b0..2d9995a 100755 --- a/tests/functional/test_aarch64_virt.py +++ b/tests/functional/test_aarch64_virt.py @@ -10,12 +10,12 @@ # # SPDX-License-Identifier: GPL-2.0-or-later -import time import logging from subprocess import check_call, DEVNULL from qemu_test import QemuSystemTest, Asset -from qemu_test import exec_command, wait_for_console_pattern +from qemu_test import exec_command_and_wait_for_pattern +from qemu_test import wait_for_console_pattern from qemu_test import get_qemu_img @@ -107,18 +107,22 @@ class Aarch64VirtMachine(QemuSystemTest): 'virtio-blk-device,drive=scratch') self.vm.launch() - self.wait_for_console_pattern('Welcome to Buildroot') - time.sleep(0.1) - exec_command(self, 'root') - time.sleep(0.1) - exec_command(self, 'dd if=/dev/hwrng of=/dev/vda bs=512 count=4') - time.sleep(0.1) - exec_command(self, 'md5sum /dev/vda') - time.sleep(0.1) - exec_command(self, 'cat /proc/interrupts') - time.sleep(0.1) - exec_command(self, 'cat /proc/self/maps') - time.sleep(0.1) + + ps1='#' + self.wait_for_console_pattern('login:') + + commands = [ + ('root', ps1), + ('cat /proc/interrupts', ps1), + ('cat /proc/self/maps', ps1), + ('uname -a', ps1), + ('dd if=/dev/hwrng of=/dev/vda bs=512 count=4', ps1), + ('md5sum /dev/vda', ps1), + ('halt -n', 'reboot: System halted') + ] + + for cmd, pattern in commands: + exec_command_and_wait_for_pattern(self, cmd, pattern) def test_aarch64_virt_gicv3(self): self.common_aarch64_virt("virt,gic_version=3") |