]> git.proxmox.com Git - mirror_qemu.git/blame - tests/avocado/machine_aspeed.py
tests/avocado: add timeout to the aspeed tests
[mirror_qemu.git] / tests / avocado / machine_aspeed.py
CommitLineData
438eff63
JL
1# Functional test that boots the ASPEED SoCs with firmware
2#
3# Copyright (C) 2022 ASPEED Technology Inc
4#
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.
7
f7bc7da0
CLG
8import time
9
438eff63
JL
10from avocado_qemu import QemuSystemTest
11from avocado_qemu import wait_for_console_pattern
f7bc7da0 12from avocado_qemu import exec_command
438eff63
JL
13from avocado_qemu import exec_command_and_wait_for_pattern
14from avocado.utils import archive
15
16
17class AST1030Machine(QemuSystemTest):
18 """Boots the zephyr os and checks that the console is operational"""
19
20 timeout = 10
21
22 def test_ast1030_zephyros(self):
23 """
24 :avocado: tags=arch:arm
25 :avocado: tags=machine:ast1030-evb
26 """
27 tar_url = ('https://github.com/AspeedTech-BMC'
28 '/zephyr/releases/download/v00.01.04/ast1030-evb-demo.zip')
29 tar_hash = '4c6a8ce3a8ba76ef1a65dae419ae3409343c4b20'
30 tar_path = self.fetch_asset(tar_url, asset_hash=tar_hash)
31 archive.extract(tar_path, self.workdir)
32 kernel_file = self.workdir + "/ast1030-evb-demo/zephyr.elf"
33 self.vm.set_console()
34 self.vm.add_args('-kernel', kernel_file,
35 '-nographic')
36 self.vm.launch()
37 wait_for_console_pattern(self, "Booting Zephyr OS")
38 exec_command_and_wait_for_pattern(self, "help",
39 "Available commands")
341e21fa
CLG
40
41class AST2x00Machine(QemuSystemTest):
42
b1ceae2f
AB
43 timeout = 90
44
341e21fa
CLG
45 def wait_for_console_pattern(self, success_message, vm=None):
46 wait_for_console_pattern(self, success_message,
47 failure_message='Kernel panic - not syncing',
48 vm=vm)
49
50 def do_test_arm_aspeed(self, image):
51 self.vm.set_console()
52 self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw',
53 '-net', 'nic')
54 self.vm.launch()
55
56 self.wait_for_console_pattern("U-Boot 2016.07")
57 self.wait_for_console_pattern("## Loading kernel from FIT Image at 20080000")
58 self.wait_for_console_pattern("Starting kernel ...")
59 self.wait_for_console_pattern("Booting Linux on physical CPU 0x0")
60 wait_for_console_pattern(self,
61 "aspeed-smc 1e620000.spi: read control register: 203b0641")
62 self.wait_for_console_pattern("ftgmac100 1e660000.ethernet eth0: irq ")
63 self.wait_for_console_pattern("systemd[1]: Set hostname to")
64
65 def test_arm_ast2400_palmetto_openbmc_v2_9_0(self):
66 """
67 :avocado: tags=arch:arm
68 :avocado: tags=machine:palmetto-bmc
69 """
70
71 image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/'
72 'obmc-phosphor-image-palmetto.static.mtd')
73 image_hash = ('3e13bbbc28e424865dc42f35ad672b10f2e82cdb11846bb28fa625b48beafd0d')
74 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
75 algorithm='sha256')
76
77 self.do_test_arm_aspeed(image_path)
78
79 def test_arm_ast2500_romulus_openbmc_v2_9_0(self):
80 """
81 :avocado: tags=arch:arm
82 :avocado: tags=machine:romulus-bmc
83 """
84
85 image_url = ('https://github.com/openbmc/openbmc/releases/download/2.9.0/'
86 'obmc-phosphor-image-romulus.static.mtd')
87 image_hash = ('820341076803f1955bc31e647a512c79f9add4f5233d0697678bab4604c7bb25')
88 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
89 algorithm='sha256')
90
91 self.do_test_arm_aspeed(image_path)
f7bc7da0
CLG
92
93 def do_test_arm_aspeed_buidroot_start(self, image, cpu_id):
94 self.vm.set_console()
95 self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw',
96 '-net', 'nic', '-net', 'user')
97 self.vm.launch()
98
99 self.wait_for_console_pattern('U-Boot 2019.04')
100 self.wait_for_console_pattern('## Loading kernel from FIT Image')
101 self.wait_for_console_pattern('Starting kernel ...')
102 self.wait_for_console_pattern('Booting Linux on physical CPU ' + cpu_id)
103 self.wait_for_console_pattern('lease of 10.0.2.15')
104 self.wait_for_console_pattern('Aspeed EVB')
105 exec_command(self, 'root')
106 time.sleep(0.1)
107
108 def do_test_arm_aspeed_buidroot_poweroff(self):
109 exec_command_and_wait_for_pattern(self, 'poweroff',
110 'reboot: System halted');
111
112 def test_arm_ast2500_evb_builroot(self):
113 """
114 :avocado: tags=arch:arm
115 :avocado: tags=machine:ast2500-evb
116 """
117
118 image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/'
119 'images/ast2500-evb/buildroot-2022.05/flash.img')
120 image_hash = ('549db6e9d8cdaf4367af21c36385a68bb465779c18b5e37094fc7343decccd3f')
121 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
122 algorithm='sha256')
123
7a7308ea
CLG
124 self.vm.add_args('-device',
125 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test');
f7bc7da0 126 self.do_test_arm_aspeed_buidroot_start(image_path, '0x0')
7a7308ea
CLG
127
128 exec_command_and_wait_for_pattern(self,
129 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device',
130 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d');
131 exec_command_and_wait_for_pattern(self,
132 'cat /sys/class/hwmon/hwmon1/temp1_input', '0')
133 self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
134 property='temperature', value=18000);
135 exec_command_and_wait_for_pattern(self,
136 'cat /sys/class/hwmon/hwmon1/temp1_input', '18000')
137
f7bc7da0
CLG
138 self.do_test_arm_aspeed_buidroot_poweroff()
139
140 def test_arm_ast2600_evb_builroot(self):
141 """
142 :avocado: tags=arch:arm
143 :avocado: tags=machine:ast2600-evb
144 """
145
146 image_url = ('https://github.com/legoater/qemu-aspeed-boot/raw/master/'
147 'images/ast2600-evb/buildroot-2022.05/flash.img')
148 image_hash = ('6cc9e7d128fd4fa1fd01c883af67593cae8072c3239a0b8b6ace857f3538a92d')
149 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
150 algorithm='sha256')
151
61cf757d
CLG
152 self.vm.add_args('-device',
153 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test');
3302184f
CLG
154 self.vm.add_args('-device',
155 'ds1338,bus=aspeed.i2c.bus.3,address=0x32');
f7bc7da0 156 self.do_test_arm_aspeed_buidroot_start(image_path, '0xf00')
61cf757d
CLG
157
158 exec_command_and_wait_for_pattern(self,
159 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device',
160 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d');
161 exec_command_and_wait_for_pattern(self,
162 'cat /sys/class/hwmon/hwmon0/temp1_input', '0')
163 self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
164 property='temperature', value=18000);
165 exec_command_and_wait_for_pattern(self,
166 'cat /sys/class/hwmon/hwmon0/temp1_input', '18000')
167
3302184f
CLG
168 exec_command_and_wait_for_pattern(self,
169 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-3/device/new_device',
170 'i2c i2c-3: new_device: Instantiated device ds1307 at 0x32');
171 year = time.strftime("%Y")
172 exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year);
173
f7bc7da0 174 self.do_test_arm_aspeed_buidroot_poweroff()
bceb4d99
CLG
175
176
177 def do_test_arm_aspeed_sdk_start(self, image, cpu_id):
178 self.vm.set_console()
179 self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw',
180 '-net', 'nic', '-net', 'user')
181 self.vm.launch()
182
183 self.wait_for_console_pattern('U-Boot 2019.04')
184 self.wait_for_console_pattern('## Loading kernel from FIT Image')
185 self.wait_for_console_pattern('Starting kernel ...')
186 self.wait_for_console_pattern('Booting Linux on physical CPU ' + cpu_id)
187
188 def test_arm_ast2500_evb_sdk(self):
189 """
190 :avocado: tags=arch:arm
191 :avocado: tags=machine:ast2500-evb
192 """
193
194 image_url = ('https://github.com/AspeedTech-BMC/openbmc/releases/'
195 'download/v08.01/ast2500-default-obmc.tar.gz')
196 image_hash = ('5375f82b4c43a79427909342a1e18b4e48bd663e38466862145d27bb358796fd')
197 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
198 algorithm='sha256')
199 archive.extract(image_path, self.workdir)
200
201 self.do_test_arm_aspeed_sdk_start(
202 self.workdir + '/ast2500-default/image-bmc', '0x0')
203 self.wait_for_console_pattern('ast2500-default login:')
204
205 def test_arm_ast2600_evb_sdk(self):
206 """
207 :avocado: tags=arch:arm
208 :avocado: tags=machine:ast2600-evb
209 """
210
211 image_url = ('https://github.com/AspeedTech-BMC/openbmc/releases/'
212 'download/v08.01/ast2600-default-obmc.tar.gz')
213 image_hash = ('f12ef15e8c1f03a214df3b91c814515c5e2b2f56119021398c1dbdd626817d15')
214 image_path = self.fetch_asset(image_url, asset_hash=image_hash,
215 algorithm='sha256')
216 archive.extract(image_path, self.workdir)
217
218 self.vm.add_args('-device',
219 'tmp105,bus=aspeed.i2c.bus.5,address=0x4d,id=tmp-test');
220 self.vm.add_args('-device',
221 'ds1338,bus=aspeed.i2c.bus.5,address=0x32');
222 self.do_test_arm_aspeed_sdk_start(
223 self.workdir + '/ast2600-default/image-bmc', '0xf00')
224 self.wait_for_console_pattern('ast2600-default login:')
225 exec_command_and_wait_for_pattern(self, 'root', 'Password:')
226 exec_command_and_wait_for_pattern(self, '0penBmc', 'root@ast2600-default:~#')
227
228 exec_command_and_wait_for_pattern(self,
229 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-5/device/new_device',
230 'i2c i2c-5: new_device: Instantiated device lm75 at 0x4d');
231 exec_command_and_wait_for_pattern(self,
232 'cat /sys/class/hwmon/hwmon19/temp1_input', '0')
233 self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
234 property='temperature', value=18000);
235 exec_command_and_wait_for_pattern(self,
236 'cat /sys/class/hwmon/hwmon19/temp1_input', '18000')
237
238 exec_command_and_wait_for_pattern(self,
239 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-5/device/new_device',
240 'i2c i2c-5: new_device: Instantiated device ds1307 at 0x32');
241 year = time.strftime("%Y")
242 exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year);