xref: /qemu/tests/functional/test_ppc_40p.py (revision e60938852ff051ab0afeb178af01bba0d63b3bbc)
1407a6883SThomas Huth#!/usr/bin/env python3
2407a6883SThomas Huth#
3407a6883SThomas Huth# Functional test that boots a PReP/40p machine and checks its serial console.
4407a6883SThomas Huth#
5407a6883SThomas Huth# Copyright (c) Philippe Mathieu-Daudé <f4bug@amsat.org>
6407a6883SThomas Huth#
7407a6883SThomas Huth# This work is licensed under the terms of the GNU GPL, version 2 or
8407a6883SThomas Huth# later. See the COPYING file in the top-level directory.
9407a6883SThomas Huth
10407a6883SThomas Huthfrom qemu_test import QemuSystemTest, Asset
113d593860SDaniel P. Berrangéfrom qemu_test import wait_for_console_pattern, skipUntrustedTest
12*fc9fea48SCédric Le Goaterfrom qemu_test import exec_command_and_wait_for_pattern
13407a6883SThomas Huth
14407a6883SThomas Huth
15407a6883SThomas Huthclass IbmPrep40pMachine(QemuSystemTest):
16407a6883SThomas Huth
17407a6883SThomas Huth    timeout = 60
18407a6883SThomas Huth
19407a6883SThomas Huth    ASSET_BIOS = Asset(
20407a6883SThomas Huth        ('http://ftpmirror.your.org/pub/misc/'
21407a6883SThomas Huth         'ftp.software.ibm.com/rs6000/firmware/'
22407a6883SThomas Huth         '7020-40p/P12H0456.IMG'),
23407a6883SThomas Huth        'd957f79c73f760d1455d2286fcd901ed6d06167320eb73511b478a939be25b3f')
24407a6883SThomas Huth    ASSET_NETBSD40 = Asset(
25407a6883SThomas Huth        ('https://archive.netbsd.org/pub/NetBSD-archive/'
26407a6883SThomas Huth         'NetBSD-4.0/prep/installation/floppy/generic_com0.fs'),
27407a6883SThomas Huth        'f86236e9d01b3f0dd0f5d3b8d5bbd40c68e78b4db560a108358f5ad58e636619')
28407a6883SThomas Huth    ASSET_NETBSD71 = Asset(
29407a6883SThomas Huth        ('https://archive.netbsd.org/pub/NetBSD-archive/'
30407a6883SThomas Huth         'NetBSD-7.1.2/iso/NetBSD-7.1.2-prep.iso'),
31407a6883SThomas Huth        'cc7cb290b06aaa839362deb7bd9f417ac5015557db24088508330f76c3f825ec')
32407a6883SThomas Huth
33407a6883SThomas Huth    # 12H0455 PPS Firmware Licensed Materials
34407a6883SThomas Huth    # Property of IBM (C) Copyright IBM Corp. 1994.
35407a6883SThomas Huth    # All rights reserved.
36407a6883SThomas Huth    # U.S. Government Users Restricted Rights - Use, duplication or disclosure
37407a6883SThomas Huth    # restricted by GSA ADP Schedule Contract with IBM Corp.
383d593860SDaniel P. Berrangé    @skipUntrustedTest()
39407a6883SThomas Huth    def test_factory_firmware_and_netbsd(self):
40407a6883SThomas Huth        self.set_machine('40p')
41407a6883SThomas Huth        self.require_accelerator("tcg")
42407a6883SThomas Huth        bios_path = self.ASSET_BIOS.fetch()
43407a6883SThomas Huth        drive_path = self.ASSET_NETBSD40.fetch()
44407a6883SThomas Huth
45407a6883SThomas Huth        self.vm.set_console()
46407a6883SThomas Huth        self.vm.add_args('-bios', bios_path,
47dd6402b3SThomas Huth                         '-drive',
48dd6402b3SThomas Huth                         f"file={drive_path},format=raw,if=floppy,read-only=true")
49407a6883SThomas Huth        self.vm.launch()
50407a6883SThomas Huth        os_banner = 'NetBSD 4.0 (GENERIC) #0: Sun Dec 16 00:49:40 PST 2007'
51407a6883SThomas Huth        wait_for_console_pattern(self, os_banner)
52407a6883SThomas Huth        wait_for_console_pattern(self, 'Model: IBM PPS Model 6015')
53407a6883SThomas Huth
54407a6883SThomas Huth    def test_openbios_192m(self):
55407a6883SThomas Huth        self.set_machine('40p')
56407a6883SThomas Huth        self.require_accelerator("tcg")
57407a6883SThomas Huth        self.vm.set_console()
58407a6883SThomas Huth        self.vm.add_args('-m', '192') # test fw_cfg
59407a6883SThomas Huth
60407a6883SThomas Huth        self.vm.launch()
61407a6883SThomas Huth        wait_for_console_pattern(self, '>> OpenBIOS')
62407a6883SThomas Huth        wait_for_console_pattern(self, '>> Memory: 192M')
63407a6883SThomas Huth        wait_for_console_pattern(self, '>> CPU type PowerPC,604')
64407a6883SThomas Huth
65407a6883SThomas Huth    def test_openbios_and_netbsd(self):
66407a6883SThomas Huth        self.set_machine('40p')
67407a6883SThomas Huth        self.require_accelerator("tcg")
68407a6883SThomas Huth        drive_path = self.ASSET_NETBSD71.fetch()
69407a6883SThomas Huth        self.vm.set_console()
70407a6883SThomas Huth        self.vm.add_args('-cdrom', drive_path,
71407a6883SThomas Huth                         '-boot', 'd')
72407a6883SThomas Huth
73407a6883SThomas Huth        self.vm.launch()
74407a6883SThomas Huth        wait_for_console_pattern(self, 'NetBSD/prep BOOT, Revision 1.9')
75407a6883SThomas Huth
76*fc9fea48SCédric Le Goater    ASSET_40P_SANDALFOOT = Asset(
77*fc9fea48SCédric Le Goater        'http://www.juneau-lug.org/zImage.initrd.sandalfoot',
78*fc9fea48SCédric Le Goater        '749ab02f576c6dc8f33b9fb022ecb44bf6a35a0472f2ea6a5e9956bc15933901')
79*fc9fea48SCédric Le Goater
80*fc9fea48SCédric Le Goater    def test_openbios_and_linux(self):
81*fc9fea48SCédric Le Goater        self.set_machine('40p')
82*fc9fea48SCédric Le Goater        self.require_accelerator("tcg")
83*fc9fea48SCédric Le Goater        drive_path = self.ASSET_40P_SANDALFOOT.fetch()
84*fc9fea48SCédric Le Goater        self.vm.set_console()
85*fc9fea48SCédric Le Goater        self.vm.add_args('-cdrom', drive_path,
86*fc9fea48SCédric Le Goater                         '-boot', 'd')
87*fc9fea48SCédric Le Goater
88*fc9fea48SCédric Le Goater        self.vm.launch()
89*fc9fea48SCédric Le Goater        wait_for_console_pattern(self, 'Please press Enter to activate this console.')
90*fc9fea48SCédric Le Goater        exec_command_and_wait_for_pattern(self, '\012', '#')
91*fc9fea48SCédric Le Goater        exec_command_and_wait_for_pattern(self, 'uname -a', 'Linux ppc 2.4.18')
92*fc9fea48SCédric Le Goater
93407a6883SThomas Huthif __name__ == '__main__':
94407a6883SThomas Huth    QemuSystemTest.main()
95