1#!/usr/bin/env python3
2#
3# Boot Linux kernel on a mac99 and g3beige ppc machine and check the console
4#
5# SPDX-License-Identifier: GPL-2.0-or-later
6
7from qemu_test import LinuxKernelTest, Asset
8from qemu_test.utils import archive_extract
9
10class MacTest(LinuxKernelTest):
11
12    ASSET_DAY15 = Asset(
13        'https://www.qemu-advent-calendar.org/2018/download/day15.tar.xz',
14        '03e0757c131d2959decf293a3572d3b96c5a53587165bf05ce41b2818a2bccd5')
15
16    def do_day15_test(self):
17        # mac99 also works with kvm_pr but we don't have a reliable way at
18        # the moment (e.g. by looking at /proc/modules) to detect whether
19        # we're running kvm_hv or kvm_pr. For now let's disable this test
20        # if we don't have TCG support.
21        self.require_accelerator("tcg")
22
23        file_path = self.ASSET_DAY15.fetch()
24        archive_extract(file_path, self.workdir)
25        self.vm.add_args('-M', 'graphics=off')
26        self.launch_kernel(self.workdir + '/day15/invaders.elf',
27                           wait_for='QEMU advent calendar')
28
29    def test_ppc_g3beige(self):
30        self.set_machine('g3beige')
31        self.do_day15_test()
32
33    def test_ppc_mac99(self):
34        self.set_machine('mac99')
35        self.do_day15_test()
36
37if __name__ == '__main__':
38    LinuxKernelTest.main()
39