1*d9dff75bSThomas Huth#!/usr/bin/env python3 2*d9dff75bSThomas Huth# 3*d9dff75bSThomas Huth# Functional test that boots known good tuxboot images the same way 4*d9dff75bSThomas Huth# that tuxrun (www.tuxrun.org) does. This tool is used by things like 5*d9dff75bSThomas Huth# the LKFT project to run regression tests on kernels. 6*d9dff75bSThomas Huth# 7*d9dff75bSThomas Huth# Copyright (c) 2023 Linaro Ltd. 8*d9dff75bSThomas Huth# 9*d9dff75bSThomas Huth# Author: 10*d9dff75bSThomas Huth# Alex Bennée <alex.bennee@linaro.org> 11*d9dff75bSThomas Huth# 12*d9dff75bSThomas Huth# SPDX-License-Identifier: GPL-2.0-or-later 13*d9dff75bSThomas Huth 14*d9dff75bSThomas Huthimport tempfile 15*d9dff75bSThomas Huth 16*d9dff75bSThomas Huthfrom qemu_test import run_cmd, Asset 17*d9dff75bSThomas Huthfrom qemu_test.tuxruntest import TuxRunBaselineTest 18*d9dff75bSThomas Huth 19*d9dff75bSThomas Huthclass TuxRunPPC64Test(TuxRunBaselineTest): 20*d9dff75bSThomas Huth 21*d9dff75bSThomas Huth def ppc64_common_tuxrun(self, kernel_asset, rootfs_asset, prefix): 22*d9dff75bSThomas Huth self.set_machine('pseries') 23*d9dff75bSThomas Huth self.cpu='POWER10' 24*d9dff75bSThomas Huth self.console='hvc0' 25*d9dff75bSThomas Huth self.root='sda' 26*d9dff75bSThomas Huth self.extradev='spapr-vscsi' 27*d9dff75bSThomas Huth # add device args to command line. 28*d9dff75bSThomas Huth self.require_netdev('user') 29*d9dff75bSThomas Huth self.vm.add_args('-netdev', 'user,id=vnet,hostfwd=:127.0.0.1:0-:22', 30*d9dff75bSThomas Huth '-device', 'virtio-net,netdev=vnet') 31*d9dff75bSThomas Huth self.vm.add_args('-netdev', '{"type":"user","id":"hostnet0"}', 32*d9dff75bSThomas Huth '-device', '{"driver":"virtio-net-pci","netdev":' 33*d9dff75bSThomas Huth '"hostnet0","id":"net0","mac":"52:54:00:4c:e3:86",' 34*d9dff75bSThomas Huth '"bus":"pci.0","addr":"0x9"}') 35*d9dff75bSThomas Huth self.vm.add_args('-device', '{"driver":"qemu-xhci","p2":15,"p3":15,' 36*d9dff75bSThomas Huth '"id":"usb","bus":"pci.0","addr":"0x2"}') 37*d9dff75bSThomas Huth self.vm.add_args('-device', '{"driver":"virtio-scsi-pci","id":"scsi0"' 38*d9dff75bSThomas Huth ',"bus":"pci.0","addr":"0x3"}') 39*d9dff75bSThomas Huth self.vm.add_args('-device', '{"driver":"virtio-serial-pci","id":' 40*d9dff75bSThomas Huth '"virtio-serial0","bus":"pci.0","addr":"0x4"}') 41*d9dff75bSThomas Huth self.vm.add_args('-device', '{"driver":"scsi-cd","bus":"scsi0.0"' 42*d9dff75bSThomas Huth ',"channel":0,"scsi-id":0,"lun":0,"device_id":' 43*d9dff75bSThomas Huth '"drive-scsi0-0-0-0","id":"scsi0-0-0-0"}') 44*d9dff75bSThomas Huth self.vm.add_args('-device', '{"driver":"virtio-balloon-pci",' 45*d9dff75bSThomas Huth '"id":"balloon0","bus":"pci.0","addr":"0x6"}') 46*d9dff75bSThomas Huth self.vm.add_args('-audiodev', '{"id":"audio1","driver":"none"}') 47*d9dff75bSThomas Huth self.vm.add_args('-device', '{"driver":"usb-tablet","id":"input0"' 48*d9dff75bSThomas Huth ',"bus":"usb.0","port":"1"}') 49*d9dff75bSThomas Huth self.vm.add_args('-device', '{"driver":"usb-kbd","id":"input1"' 50*d9dff75bSThomas Huth ',"bus":"usb.0","port":"2"}') 51*d9dff75bSThomas Huth self.vm.add_args('-device', '{"driver":"VGA","id":"video0",' 52*d9dff75bSThomas Huth '"vgamem_mb":16,"bus":"pci.0","addr":"0x7"}') 53*d9dff75bSThomas Huth self.vm.add_args('-object', '{"qom-type":"rng-random","id":"objrng0"' 54*d9dff75bSThomas Huth ',"filename":"/dev/urandom"}', 55*d9dff75bSThomas Huth '-device', '{"driver":"virtio-rng-pci","rng":"objrng0"' 56*d9dff75bSThomas Huth ',"id":"rng0","bus":"pci.0","addr":"0x8"}') 57*d9dff75bSThomas Huth self.vm.add_args('-object', '{"qom-type":"cryptodev-backend-builtin",' 58*d9dff75bSThomas Huth '"id":"objcrypto0","queues":1}', 59*d9dff75bSThomas Huth '-device', '{"driver":"virtio-crypto-pci",' 60*d9dff75bSThomas Huth '"cryptodev":"objcrypto0","id":"crypto0","bus"' 61*d9dff75bSThomas Huth ':"pci.0","addr":"0xa"}') 62*d9dff75bSThomas Huth self.vm.add_args('-device', '{"driver":"spapr-pci-host-bridge"' 63*d9dff75bSThomas Huth ',"index":1,"id":"pci.1"}') 64*d9dff75bSThomas Huth self.vm.add_args('-device', '{"driver":"spapr-vscsi","id":"scsi1"' 65*d9dff75bSThomas Huth ',"reg":12288}') 66*d9dff75bSThomas Huth self.vm.add_args('-m', '2G,slots=32,maxmem=4G', 67*d9dff75bSThomas Huth '-object', 'memory-backend-ram,id=ram1,size=1G', 68*d9dff75bSThomas Huth '-device', 'pc-dimm,id=dimm1,memdev=ram1') 69*d9dff75bSThomas Huth 70*d9dff75bSThomas Huth # Create a temporary qcow2 and launch the test-case 71*d9dff75bSThomas Huth with tempfile.NamedTemporaryFile(prefix=prefix, 72*d9dff75bSThomas Huth suffix='.qcow2') as qcow2: 73*d9dff75bSThomas Huth run_cmd([self.qemu_img, 'create', '-f', 'qcow2', qcow2.name, ' 1G']) 74*d9dff75bSThomas Huth 75*d9dff75bSThomas Huth self.vm.add_args('-drive', 'file=' + qcow2.name + 76*d9dff75bSThomas Huth ',format=qcow2,if=none,id=' 77*d9dff75bSThomas Huth 'drive-virtio-disk1', 78*d9dff75bSThomas Huth '-device', 'virtio-blk-pci,bus=pci.0,' 79*d9dff75bSThomas Huth 'addr=0xb,drive=drive-virtio-disk1,id=virtio-disk1' 80*d9dff75bSThomas Huth ',bootindex=2') 81*d9dff75bSThomas Huth self.common_tuxrun(kernel_asset, rootfs_asset=rootfs_asset, 82*d9dff75bSThomas Huth drive="scsi-hd") 83*d9dff75bSThomas Huth 84*d9dff75bSThomas Huth ASSET_PPC64_KERNEL = Asset( 85*d9dff75bSThomas Huth 'https://storage.tuxboot.com/20230331/ppc64/vmlinux', 86*d9dff75bSThomas Huth '1d953e81a4379e537fc8e41e05a0a59d9b453eef97aa03d47866c6c45b00bdff') 87*d9dff75bSThomas Huth ASSET_PPC64_ROOTFS = Asset( 88*d9dff75bSThomas Huth 'https://storage.tuxboot.com/20230331/ppc64/rootfs.ext4.zst', 89*d9dff75bSThomas Huth 'f22a9b9e924174a4c199f4c7e5d91a2339fcfe51c6eafd0907dc3e09b64ab728') 90*d9dff75bSThomas Huth 91*d9dff75bSThomas Huth def test_ppc64(self): 92*d9dff75bSThomas Huth self.ppc64_common_tuxrun(kernel_asset=self.ASSET_PPC64_KERNEL, 93*d9dff75bSThomas Huth rootfs_asset=self.ASSET_PPC64_ROOTFS, 94*d9dff75bSThomas Huth prefix='tuxrun_ppc64_') 95*d9dff75bSThomas Huth 96*d9dff75bSThomas Huth ASSET_PPC64LE_KERNEL = Asset( 97*d9dff75bSThomas Huth 'https://storage.tuxboot.com/20230331/ppc64le/vmlinux', 98*d9dff75bSThomas Huth '979eb61b445a010fb13e2b927126991f8ceef9c590fa2be0996c00e293e80cf2') 99*d9dff75bSThomas Huth ASSET_PPC64LE_ROOTFS = Asset( 100*d9dff75bSThomas Huth 'https://storage.tuxboot.com/20230331/ppc64le/rootfs.ext4.zst', 101*d9dff75bSThomas Huth 'b442678c93fb8abe1f7d3bfa20556488de6b475c22c8fed363f42cf81a0a3906') 102*d9dff75bSThomas Huth 103*d9dff75bSThomas Huth def test_ppc64le(self): 104*d9dff75bSThomas Huth self.ppc64_common_tuxrun(kernel_asset=self.ASSET_PPC64LE_KERNEL, 105*d9dff75bSThomas Huth rootfs_asset=self.ASSET_PPC64LE_ROOTFS, 106*d9dff75bSThomas Huth prefix='tuxrun_ppc64le_') 107*d9dff75bSThomas Huth 108*d9dff75bSThomas Huth 109*d9dff75bSThomas Huthif __name__ == '__main__': 110*d9dff75bSThomas Huth TuxRunBaselineTest.main() 111