master
py 94 lines 3.58 KB
Raw
1 #!/usr/bin/env python3
2 #
3 # Functional test that boots the ASPEED machines
4 #
5 # SPDX-License-Identifier: GPL-2.0-or-later
6
7 import os
8 import time
9
10 from qemu_test import Asset
11 from aspeed import AspeedTest
12 from qemu_test import exec_command_and_wait_for_pattern
13
14
15 class AST2600Machine(AspeedTest):
16
17 ASSET_SDK_V1103_AST2600 = Asset(
18 'https://github.com/AspeedTech-BMC/openbmc/releases/download/v11.03/ast2600-default-image.tar.gz',
19 '47e3656a14bf7a4de28d3dfbf48bc2325443bc42d270f3bc82646f92f6dea165')
20
21 def do_ast2600_pcie_test(self):
22 exec_command_and_wait_for_pattern(self,
23 'lspci -s 00:08.0',
24 '00:08.0 PCI bridge: '
25 'ASPEED Technology, Inc. AST1150 PCI-to-PCI Bridge')
26 exec_command_and_wait_for_pattern(self,
27 'lspci -s 01:00.0',
28 '01:00.0 Ethernet controller: '
29 'Intel Corporation 82574L Gigabit Network Connection')
30 exec_command_and_wait_for_pattern(self,
31 'ip addr show dev eth4',
32 'inet 10.0.2.15/24')
33
34 def do_ast2600_i3c_test(self):
35 exec_command_and_wait_for_pattern(self,
36 'i3ctransfer -d /dev/bus/i3c/5-1234567890ab'
37 ' -w 0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef',
38 'Success on message 0')
39 exec_command_and_wait_for_pattern(self,
40 'i3ctransfer -d /dev/bus/i3c/5-1234567890ab -r 8 | grep 0x | xargs',
41 '0x12 0x34 0x56 0x78 0x90 0xab 0xcd 0xef')
42
43 def do_ast2600_usb_ehci_test(self):
44 exec_command_and_wait_for_pattern(self,
45 'lsusb',
46 'QEMU QEMU USB Keyboard')
47
48 def test_arm_ast2600_evb_sdk(self):
49 self.set_machine('ast2600-evb')
50 self.require_netdev('user')
51
52 self.archive_extract(self.ASSET_SDK_V1103_AST2600)
53
54 self.vm.add_args('-device',
55 'tmp105,bus=aspeed.i2c.bus.5,address=0x4d,id=tmp-test')
56 self.vm.add_args('-device',
57 'ds1338,bus=aspeed.i2c.bus.5,address=0x32')
58 self.vm.add_args('-device', 'e1000e,netdev=net1,bus=pcie.0')
59 self.vm.add_args('-netdev', 'user,id=net1')
60 self.vm.add_args('-device',
61 'mock-i3c-target,bus=dw.i3c.5,pid=0xab9078563412')
62 self.vm.add_args('-device', 'usb-kbd,bus=usb-bus.1')
63 self.do_test_arm_aspeed_sdk_start(
64 self.scratch_file("ast2600-default-image", "image-bmc"))
65
66 self.wait_for_console_pattern('login:')
67
68 exec_command_and_wait_for_pattern(self, 'root', 'Password:')
69 exec_command_and_wait_for_pattern(self, '0penBmc',
70 'root@ast2600-default:~#')
71
72 exec_command_and_wait_for_pattern(self,
73 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-5/device/new_device',
74 'i2c i2c-5: new_device: Instantiated device lm75 at 0x4d')
75 exec_command_and_wait_for_pattern(self,
76 'cat /sys/class/hwmon/hwmon19/temp1_input', '0')
77 self.vm.cmd('qom-set', path='/machine/peripheral/tmp-test',
78 property='temperature', value=18000)
79 exec_command_and_wait_for_pattern(self,
80 'cat /sys/class/hwmon/hwmon19/temp1_input', '18000')
81
82 exec_command_and_wait_for_pattern(self,
83 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-5/device/new_device',
84 'i2c i2c-5: new_device: Instantiated device ds1307 at 0x32')
85 year = time.strftime("%Y")
86 exec_command_and_wait_for_pattern(self,
87 '/sbin/hwclock -f /dev/rtc1', year)
88 self.do_ast2600_pcie_test()
89 self.do_ast2600_i3c_test()
90 self.do_ast2600_usb_ehci_test()
91
92
93 if __name__ == '__main__':
94 AspeedTest.main()