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