disas/nanomips: Expand Dis_info struct
[qemu/armbru.git] / tests / avocado / machine_aspeed.py
blobfba6527026813c409e463a80dea6f453b37411b5
1 # Functional test that boots the ASPEED SoCs with firmware
3 # Copyright (C) 2022 ASPEED Technology Inc
5 # This work is licensed under the terms of the GNU GPL, version 2 or
6 # later. See the COPYING file in the top-level directory.
8 import time
9 import os
11 from avocado_qemu import QemuSystemTest
12 from avocado_qemu import wait_for_console_pattern
13 from avocado_qemu import exec_command
14 from avocado_qemu import exec_command_and_wait_for_pattern
15 from avocado.utils import archive
16 from avocado import skipIf
19 class AST1030Machine(QemuSystemTest):
20 """Boots the zephyr os and checks that the console is operational"""
22 timeout = 10
24 def test_ast1030_zephyros(self):
25 """
26 :avocado: tags=arch:arm
27 :avocado: tags=machine:ast1030-evb
28 """
29 tar_url = ('https://github.com/AspeedTech-BMC'
30 '/zephyr/releases/download/v00.01.04/ast1030-evb-demo.zip')
31 tar_hash = '4c6a8ce3a8ba76ef1a65dae419ae3409343c4b20'
32 tar_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
33 archive.extract(tar_path, self.workdir)
34 kernel_file = self.workdir + "/ast1030-evb-demo/zephyr.elf"
35 self.vm.set_console()
36 self.vm.add_args('-kernel', kernel_file,
37 '-nographic')
38 self.vm.launch()
39 wait_for_console_pattern(self, "Booting Zephyr OS")
40 exec_command_and_wait_for_pattern(self, "help",
41 "Available commands")
43 class AST2x00Machine(QemuSystemTest):
45 timeout = 90
47 def wait_for_console_pattern(self, success_message, vm=None):
48 wait_for_console_pattern(self, success_message,
49 failure_message='Kernel panic - not syncing',
50 vm=vm)
52 def do_test_arm_aspeed(self, image):
53 self.vm.set_console()
54 self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw',
55 '-net', 'nic')
56 self.vm.launch()
58 self.wait_for_console_pattern("U-Boot 2016.07")
59 self.wait_for_console_pattern("## Loading kernel from FIT Image at 20080000")
60 self.wait_for_console_pattern("Starting kernel ...")
61 self.wait_for_console_pattern("Booting Linux on physical CPU 0x0")
62 wait_for_console_pattern(self,
63 "aspeed-smc 1e620000.spi: read control register: 203b0641")
64 self.wait_for_console_pattern("ftgmac100 1e660000.ethernet eth0: irq ")
65 self.wait_for_console_pattern("systemd[1]: Set hostname to")
67 def test_arm_ast2400_palmetto_openbmc_v2_9_0(self):
68 """
69 :avocado: tags=arch:arm
70 :avocado: tags=machine:palmetto-bmc
71 """
73 image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/'
74 'obmc-phosphor-image-palmetto.static.mtd')
75 image_hash = ('3e13bbbc28e424865dc42f35ad672b10f2e82cdb11846bb28fa625b48beafd0d')
76 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
77 algorithm='sha256')
79 self.do_test_arm_aspeed(image_path)
81 def test_arm_ast2500_romulus_openbmc_v2_9_0(self):
82 """
83 :avocado: tags=arch:arm
84 :avocado: tags=machine:romulus-bmc
85 """
87 image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/'
88 'obmc-phosphor-image-romulus.static.mtd')
89 image_hash = ('820341076803f1955bc31e647a512c79f9add4f5233d0697678bab4604c7bb25')
90 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
91 algorithm='sha256')
93 self.do_test_arm_aspeed(image_path)
95 def do_test_arm_aspeed_buildroot_start(self, image, cpu_id):
96 self.require_netdev('user')
98 self.vm.set_console()
99 self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw',
100 '-net', 'nic', '-net', 'user')
101 self.vm.launch()
103 self.wait_for_console_pattern('U-Boot 2019.04')
104 self.wait_for_console_pattern('## Loading kernel from FIT Image')
105 self.wait_for_console_pattern('Starting kernel ...')
106 self.wait_for_console_pattern('Booting Linux on physical CPU ' + cpu_id)
107 self.wait_for_console_pattern('lease of 10.0.2.15')
108 # the line before login:
109 self.wait_for_console_pattern('Aspeed EVB')
110 time.sleep(0.1)
111 exec_command(self, 'root')
112 time.sleep(0.1)
114 def do_test_arm_aspeed_buildroot_poweroff(self):
115 exec_command_and_wait_for_pattern(self, 'poweroff',
116 'reboot: System halted');
118 def test_arm_ast2500_evb_buildroot(self):
120 :avocado: tags=arch:arm
121 :avocado: tags=machine:ast2500-evb
124 image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/'
125 'images/ast2500-evb/buildroot-2022.05/flash.img')
126 image_hash = ('549db6e9d8cdaf4367af21c36385a68bb465779c18b5e37094fc7343decccd3f')
127 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
128 algorithm='sha256')
130 self.vm.add_args('-device',
131 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test');
132 self.do_test_arm_aspeed_buildroot_start(image_path, '0x0')
134 exec_command_and_wait_for_pattern(self,
135 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device',
136 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d');
137 exec_command_and_wait_for_pattern(self,
138 'cat /sys/class/hwmon/hwmon1/temp1_input', '0')
139 self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
140 property='temperature', value=18000);
141 exec_command_and_wait_for_pattern(self,
142 'cat /sys/class/hwmon/hwmon1/temp1_input', '18000')
144 self.do_test_arm_aspeed_buildroot_poweroff()
146 def test_arm_ast2600_evb_buildroot(self):
148 :avocado: tags=arch:arm
149 :avocado: tags=machine:ast2600-evb
152 image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/'
153 'images/ast2600-evb/buildroot-2022.05/flash.img')
154 image_hash = ('6cc9e7d128fd4fa1fd01c883af67593cae8072c3239a0b8b6ace857f3538a92d')
155 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
156 algorithm='sha256')
158 self.vm.add_args('-device',
159 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test');
160 self.vm.add_args('-device',
161 'ds1338,bus=aspeed.i2c.bus.3,address=0x32');
162 self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00')
164 exec_command_and_wait_for_pattern(self,
165 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device',
166 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d');
167 exec_command_and_wait_for_pattern(self,
168 'cat /sys/class/hwmon/hwmon0/temp1_input', '0')
169 self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
170 property='temperature', value=18000);
171 exec_command_and_wait_for_pattern(self,
172 'cat /sys/class/hwmon/hwmon0/temp1_input', '18000')
174 exec_command_and_wait_for_pattern(self,
175 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-3/device/new_device',
176 'i2c i2c-3: new_device: Instantiated device ds1307 at 0x32');
177 year = time.strftime("%Y")
178 exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year);
180 self.do_test_arm_aspeed_buildroot_poweroff()
183 class AST2x00MachineSDK(QemuSystemTest):
185 # FIXME: Although these tests boot a whole distro they are still
186 # slower than comparable machine models. There may be some
187 # optimisations which bring down the runtime. In the meantime they
188 # have generous timeouts and are disable for CI which aims for all
189 # tests to run in less than 60 seconds.
190 timeout = 240
192 def wait_for_console_pattern(self, success_message, vm=None):
193 wait_for_console_pattern(self, success_message,
194 failure_message='Kernel panic - not syncing',
195 vm=vm)
197 def do_test_arm_aspeed_sdk_start(self, image, cpu_id):
198 self.require_netdev('user')
199 self.vm.set_console()
200 self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw',
201 '-net', 'nic', '-net', 'user')
202 self.vm.launch()
204 self.wait_for_console_pattern('U-Boot 2019.04')
205 self.wait_for_console_pattern('## Loading kernel from FIT Image')
206 self.wait_for_console_pattern('Starting kernel ...')
207 self.wait_for_console_pattern('Booting Linux on physical CPU ' + cpu_id)
209 @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
210 def test_arm_ast2500_evb_sdk(self):
212 :avocado: tags=arch:arm
213 :avocado: tags=machine:ast2500-evb
216 image_url = ('https://github.com/AspeedTech-BMC/openbmc/releases/'
217 'download/v08.01/ast2500-default-obmc.tar.gz')
218 image_hash = ('5375f82b4c43a79427909342a1e18b4e48bd663e38466862145d27bb358796fd')
219 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
220 algorithm='sha256')
221 archive.extract(image_path, self.workdir)
223 self.do_test_arm_aspeed_sdk_start(
224 self.workdir + '/ast2500-default/image-bmc', '0x0')
225 self.wait_for_console_pattern('ast2500-default login:')
227 @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
228 def test_arm_ast2600_evb_sdk(self):
230 :avocado: tags=arch:arm
231 :avocado: tags=machine:ast2600-evb
234 image_url = ('https://github.com/AspeedTech-BMC/openbmc/releases/'
235 'download/v08.01/ast2600-default-obmc.tar.gz')
236 image_hash = ('f12ef15e8c1f03a214df3b91c814515c5e2b2f56119021398c1dbdd626817d15')
237 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
238 algorithm='sha256')
239 archive.extract(image_path, self.workdir)
241 self.vm.add_args('-device',
242 'tmp105,bus=aspeed.i2c.bus.5,address=0x4d,id=tmp-test');
243 self.vm.add_args('-device',
244 'ds1338,bus=aspeed.i2c.bus.5,address=0x32');
245 self.do_test_arm_aspeed_sdk_start(
246 self.workdir + '/ast2600-default/image-bmc', '0xf00')
247 self.wait_for_console_pattern('ast2600-default login:')
248 exec_command_and_wait_for_pattern(self, 'root', 'Password:')
249 exec_command_and_wait_for_pattern(self, '0penBmc', 'root@ast2600-default:~#')
251 exec_command_and_wait_for_pattern(self,
252 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-5/device/new_device',
253 'i2c i2c-5: new_device: Instantiated device lm75 at 0x4d');
254 exec_command_and_wait_for_pattern(self,
255 'cat /sys/class/hwmon/hwmon19/temp1_input', '0')
256 self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
257 property='temperature', value=18000);
258 exec_command_and_wait_for_pattern(self,
259 'cat /sys/class/hwmon/hwmon19/temp1_input', '18000')
261 exec_command_and_wait_for_pattern(self,
262 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-5/device/new_device',
263 'i2c i2c-5: new_device: Instantiated device ds1307 at 0x32');
264 year = time.strftime("%Y")
265 exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year);