|
| 1 | +#!/usr/bin/python3 |
| 2 | +# |
| 3 | +# Kernel needs: |
| 4 | +# CONFIG_SERIAL_PMACZILOG=y |
| 5 | +# CONFIG_SERIAL_PMACZILOG_TTYS=y |
| 6 | +# CONFIG_SERIAL_PMACZILOG_CONSOLE=y |
| 7 | +# CONFIG_DEVTMPFS=y |
| 8 | +# CONFIG_DEVTMPFS_MOUNT=y |
| 9 | +# CONFIG_NE2K_PCI=y |
| 10 | +# |
| 11 | +# $ cd ~/src/linux |
| 12 | +# $ make |
| 13 | +# $ ~/src/ci-scripts/scripts/boot/qemu-g3beige |
| 14 | +# |
| 15 | +# Or: |
| 16 | +# |
| 17 | +# export VMLINUX_PATH=~/src/linux/vmlinux |
| 18 | +# export KERNEL_RELEASE_PATH=~/src/linux/include/config/kernel.release |
| 19 | +# |
| 20 | +# Optional: |
| 21 | +# export QEMU_SYSTEM_PPC=~/src/qemu/ppc-softmmu/qemu-system-ppc |
| 22 | +# export ROOT_DISK_PATH=~/some/directory |
| 23 | +# Expects ppc-rootfs.cpio.gz in ROOT_DISK_PATH |
| 24 | + |
| 25 | +import logging |
| 26 | +import os, sys |
| 27 | +sys.path.append(f'{os.path.dirname(sys.argv[0])}/../../lib') |
| 28 | + |
| 29 | +from qemu import qemu_command, qemu_net_setup |
| 30 | +from pexpect_utils import * |
| 31 | +from utils import * |
| 32 | + |
| 33 | + |
| 34 | +def main(): |
| 35 | + setup_logging() |
| 36 | + setup_timeout(60) |
| 37 | + |
| 38 | + expected_release = get_expected_release() |
| 39 | + if expected_release is None: |
| 40 | + return False |
| 41 | + |
| 42 | + vmlinux = get_vmlinux() |
| 43 | + if vmlinux is None: |
| 44 | + return False |
| 45 | + |
| 46 | + p = PexpectHelper() |
| 47 | + cmd = qemu_command(qemu='qemu-system-ppc', machine='g3beige', vmlinux=vmlinux, cmdline='noreboot') |
| 48 | + p.spawn(cmd, logfile=open('console.log', 'w')) |
| 49 | + |
| 50 | + standard_boot(p) |
| 51 | + |
| 52 | + p.send("echo -n 'booted-revision: '; uname -r") |
| 53 | + p.expect(f'booted-revision: {expected_release}') |
| 54 | + p.expect_prompt() |
| 55 | + |
| 56 | + p.send('cat /proc/cpuinfo') |
| 57 | + p.expect('AAPL,PowerMac G3 MacRISC') |
| 58 | + p.expect_prompt() |
| 59 | + |
| 60 | + if os.environ.get('QEMU_NET_TESTS', True) != '0': |
| 61 | + qemu_net_setup(p) |
| 62 | + ping_test(p) |
| 63 | + wget_test(p) |
| 64 | + |
| 65 | + p.send('halt') |
| 66 | + p.wait_for_exit() |
| 67 | + |
| 68 | + if filter_log_warnings(open('console.log'), open('warnings.txt', 'w')): |
| 69 | + logging.error('Errors/warnings seen in console.log') |
| 70 | + return False |
| 71 | + |
| 72 | + logging.info('Test completed OK') |
| 73 | + |
| 74 | + return True |
| 75 | + |
| 76 | + |
| 77 | +sys.exit(0 if main() else 1) |
0 commit comments