[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 22/26] tests/functional: Convert the emcraft_sf2 avocado test
From: |
Thomas Huth |
Subject: |
[PULL 22/26] tests/functional: Convert the emcraft_sf2 avocado test |
Date: |
Wed, 11 Dec 2024 10:00:06 +0100 |
A pretty straight-forward conversion of the emcraft_sf2 boot
test to the functional framework.
This was the last test that used file_truncate() in
boot_linux_console.py, so we can remove that function from that
file now, too.
Message-ID: <20241206102358.1186644-3-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
MAINTAINERS | 1 +
tests/avocado/boot_linux_console.py | 44 --------------------
tests/functional/meson.build | 1 +
tests/functional/test_arm_emcraft_sf2.py | 52 ++++++++++++++++++++++++
4 files changed, 54 insertions(+), 44 deletions(-)
create mode 100755 tests/functional/test_arm_emcraft_sf2.py
diff --git a/MAINTAINERS b/MAINTAINERS
index 86cac83221..435a87b146 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1116,6 +1116,7 @@ L: qemu-arm@nongnu.org
S: Maintained
F: hw/arm/msf2-som.c
F: docs/system/arm/emcraft-sf2.rst
+F: tests/functional/test_arm_emcraft_sf2.py
ASPEED BMCs
M: Cédric Le Goater <clg@kaod.org>
diff --git a/tests/avocado/boot_linux_console.py
b/tests/avocado/boot_linux_console.py
index 44ee50c469..5d5795e41b 100644
--- a/tests/avocado/boot_linux_console.py
+++ b/tests/avocado/boot_linux_console.py
@@ -30,11 +30,6 @@
def pow2ceil(x):
return 1 if x == 0 else 2**(x - 1).bit_length()
-def file_truncate(path, size):
- if size != os.path.getsize(path):
- with open(path, 'ab+') as fd:
- fd.truncate(size)
-
"""
Expand file size to next power of 2
"""
@@ -137,45 +132,6 @@ def test_arm_virt(self):
console_pattern = 'Kernel command line: %s' % kernel_command_line
self.wait_for_console_pattern(console_pattern)
- def test_arm_emcraft_sf2(self):
- """
- :avocado: tags=arch:arm
- :avocado: tags=machine:emcraft-sf2
- :avocado: tags=endian:little
- :avocado: tags=u-boot
- :avocado: tags=accel:tcg
- """
- self.require_netdev('user')
-
- uboot_url = ('https://raw.githubusercontent.com/'
- 'Subbaraya-Sundeep/qemu-test-binaries/'
- 'fe371d32e50ca682391e1e70ab98c2942aeffb01/u-boot')
- uboot_hash = 'cbb8cbab970f594bf6523b9855be209c08374ae2'
- uboot_path = self.fetch_asset(uboot_url, asset_hash=uboot_hash)
- spi_url = ('https://raw.githubusercontent.com/'
- 'Subbaraya-Sundeep/qemu-test-binaries/'
- 'fe371d32e50ca682391e1e70ab98c2942aeffb01/spi.bin')
- spi_hash = '65523a1835949b6f4553be96dec1b6a38fb05501'
- spi_path = self.fetch_asset(spi_url, asset_hash=spi_hash)
- spi_path_rw = os.path.join(self.workdir, os.path.basename(spi_path))
- shutil.copy(spi_path, spi_path_rw)
-
- file_truncate(spi_path_rw, 16 << 20) # Spansion S25FL128SDPBHICO is 16
MiB
-
- self.vm.set_console()
- kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE
- self.vm.add_args('-kernel', uboot_path,
- '-append', kernel_command_line,
- '-drive', 'file=' + spi_path_rw +
',if=mtd,format=raw',
- '-no-reboot')
- self.vm.launch()
- self.wait_for_console_pattern('Enter \'help\' for a list')
-
- exec_command_and_wait_for_pattern(self, 'ifconfig eth0 10.0.2.15',
- 'eth0: link becomes ready')
- exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2',
- '3 packets transmitted, 3 packets received, 0% packet loss')
-
def test_arm_exynos4210_initrd(self):
"""
:avocado: tags=arch:arm
diff --git a/tests/functional/meson.build b/tests/functional/meson.build
index 6e22d8f4f0..af38494e14 100644
--- a/tests/functional/meson.build
+++ b/tests/functional/meson.build
@@ -71,6 +71,7 @@ tests_arm_system_thorough = [
'arm_bpim2u',
'arm_canona1100',
'arm_collie',
+ 'arm_emcraft_sf2',
'arm_integratorcp',
'arm_orangepi',
'arm_raspi2',
diff --git a/tests/functional/test_arm_emcraft_sf2.py
b/tests/functional/test_arm_emcraft_sf2.py
new file mode 100755
index 0000000000..ada4dfd82e
--- /dev/null
+++ b/tests/functional/test_arm_emcraft_sf2.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python3
+#
+# Functional test that boots a Linux kernel and checks the console
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import os
+import shutil
+
+from qemu_test import LinuxKernelTest, Asset, exec_command_and_wait_for_pattern
+from qemu_test.utils import file_truncate
+
+class EmcraftSf2Machine(LinuxKernelTest):
+
+ ASSET_UBOOT = Asset(
+
('https://raw.githubusercontent.com/Subbaraya-Sundeep/qemu-test-binaries/'
+ 'fe371d32e50ca682391e1e70ab98c2942aeffb01/u-boot'),
+ '5c6a15103375db11b21f2236473679a9dbbed6d89652bfcdd501c263d68ab725')
+
+ ASSET_SPI = Asset(
+
('https://raw.githubusercontent.com/Subbaraya-Sundeep/qemu-test-binaries/'
+ 'fe371d32e50ca682391e1e70ab98c2942aeffb01/spi.bin'),
+ 'cd9bdd2c4cb55a59c3adb6bcf74881667c4500dde0570a43aa3be2b17eecfdb6')
+
+ def test_arm_emcraft_sf2(self):
+ self.set_machine('emcraft-sf2')
+ self.require_netdev('user')
+
+ uboot_path = self.ASSET_UBOOT.fetch()
+ spi_path = self.ASSET_SPI.fetch()
+ spi_path_rw = os.path.join(self.workdir, 'spi.bin')
+ shutil.copy(spi_path, spi_path_rw)
+ os.chmod(spi_path_rw, 0o600)
+
+ file_truncate(spi_path_rw, 16 << 20) # Spansion S25FL128SDPBHICO is 16
MiB
+
+ self.vm.set_console()
+ kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE
+ self.vm.add_args('-kernel', uboot_path,
+ '-append', kernel_command_line,
+ '-drive', 'file=' + spi_path_rw +
',if=mtd,format=raw',
+ '-no-reboot')
+ self.vm.launch()
+ self.wait_for_console_pattern('Enter \'help\' for a list')
+
+ exec_command_and_wait_for_pattern(self, 'ifconfig eth0 10.0.2.15',
+ 'eth0: link becomes ready')
+ exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2',
+ '3 packets transmitted, 3 packets received, 0% packet loss')
+
+if __name__ == '__main__':
+ LinuxKernelTest.main()
--
2.47.1
- [PULL 08/26] s390x/cpumodel: Add ptff Query Time-Stamp Event (QTSE) support, (continued)
- [PULL 08/26] s390x/cpumodel: Add ptff Query Time-Stamp Event (QTSE) support, Thomas Huth, 2024/12/11
- [PULL 12/26] s390x/cpumodel: add Miscellaneous-Instruction-Extensions Facility 4, Thomas Huth, 2024/12/11
- [PULL 10/26] s390x/cpumodel: add Concurrent-functions facility support, Thomas Huth, 2024/12/11
- [PULL 13/26] s390x/cpumodel: add Vector-Packed-Decimal-Enhancement facility 3, Thomas Huth, 2024/12/11
- [PULL 16/26] s390x/cpumodel: correct PLO feature wording, Thomas Huth, 2024/12/11
- [PULL 18/26] s390x/cpumodel: gen17 model, Thomas Huth, 2024/12/11
- [PULL 06/26] s390x/cpumodel: add msa12 changes, Thomas Huth, 2024/12/11
- [PULL 07/26] s390x/cpumodel: add msa13 subfunctions, Thomas Huth, 2024/12/11
- [PULL 09/26] linux-headers: Update to Linux 6.13-rc1, Thomas Huth, 2024/12/11
- [PULL 19/26] tests/functional: Bump the timeout of the sh4_tuxrun test, Thomas Huth, 2024/12/11
- [PULL 22/26] tests/functional: Convert the emcraft_sf2 avocado test,
Thomas Huth <=
- [PULL 24/26] tests/functional: Convert the cubieboard avocado tests, Thomas Huth, 2024/12/11
- [PULL 25/26] tests/functional: remove unused system imports, Thomas Huth, 2024/12/11
- [PULL 26/26] tests/functional: remove pointless with statement, Thomas Huth, 2024/12/11
- [PULL 23/26] tests/functional: Convert the smdkc210 avocado test, Thomas Huth, 2024/12/11
- [PULL 11/26] s390x/cpumodel: add Vector Enhancements facility 3, Thomas Huth, 2024/12/11
- [PULL 14/26] s390x/cpumodel: add Ineffective-nonconstrained-transaction facility, Thomas Huth, 2024/12/11
- [PULL 20/26] MAINTAINERS: Cover the tests/functional/test_sh4eb_r2d.py file, Thomas Huth, 2024/12/11
- [PULL 15/26] s390x/cpumodel: Add Sequential-Instruction-Fetching facility, Thomas Huth, 2024/12/11
- [PULL 17/26] s390x/cpumodel: Add PLO-extension facility, Thomas Huth, 2024/12/11
- [PULL 21/26] tests/functional: Convert the xlnx_versal_virt avocado test, Thomas Huth, 2024/12/11