1#!/usr/bin/env python3 2# 3# Functional test that boots a Linux kernel and checks the console 4# 5# SPDX-License-Identifier: GPL-2.0-or-later 6 7import os 8import shutil 9 10from qemu_test import LinuxKernelTest, Asset, exec_command_and_wait_for_pattern 11from qemu_test.utils import file_truncate 12 13class EmcraftSf2Machine(LinuxKernelTest): 14 15 ASSET_UBOOT = Asset( 16 ('https://raw.githubusercontent.com/Subbaraya-Sundeep/qemu-test-binaries/' 17 'fe371d32e50ca682391e1e70ab98c2942aeffb01/u-boot'), 18 '5c6a15103375db11b21f2236473679a9dbbed6d89652bfcdd501c263d68ab725') 19 20 ASSET_SPI = Asset( 21 ('https://raw.githubusercontent.com/Subbaraya-Sundeep/qemu-test-binaries/' 22 'fe371d32e50ca682391e1e70ab98c2942aeffb01/spi.bin'), 23 'cd9bdd2c4cb55a59c3adb6bcf74881667c4500dde0570a43aa3be2b17eecfdb6') 24 25 def test_arm_emcraft_sf2(self): 26 self.set_machine('emcraft-sf2') 27 self.require_netdev('user') 28 29 uboot_path = self.ASSET_UBOOT.fetch() 30 spi_path = self.ASSET_SPI.fetch() 31 spi_path_rw = self.scratch_file('spi.bin') 32 shutil.copy(spi_path, spi_path_rw) 33 os.chmod(spi_path_rw, 0o600) 34 35 file_truncate(spi_path_rw, 16 << 20) # Spansion S25FL128SDPBHICO is 16 MiB 36 37 self.vm.set_console() 38 kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE 39 self.vm.add_args('-kernel', uboot_path, 40 '-append', kernel_command_line, 41 '-drive', 'file=' + spi_path_rw + ',if=mtd,format=raw', 42 '-no-reboot') 43 self.vm.launch() 44 self.wait_for_console_pattern('Enter \'help\' for a list') 45 46 exec_command_and_wait_for_pattern(self, 'ifconfig eth0 10.0.2.15', 47 'eth0: link becomes ready') 48 exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2', 49 '3 packets transmitted, 3 packets received, 0% packet loss') 50 51if __name__ == '__main__': 52 LinuxKernelTest.main() 53