1#!/usr/bin/env python3
2#
3# Check for crash when using empty -cpu option
4#
5# Copyright (c) 2019 Red Hat, Inc.
6#
7# Author:
8#  Eduardo Habkost <ehabkost@redhat.com>
9#
10# This work is licensed under the terms of the GNU GPL, version 2 or
11# later.  See the COPYING file in the top-level directory.
12from qemu_test import QemuSystemTest
13
14class EmptyCPUModel(QemuSystemTest):
15    def test(self):
16        self.vm.add_args('-S', '-display', 'none', '-machine', 'none', '-cpu', '')
17        self.vm.set_qmp_monitor(enabled=False)
18        self.vm.launch()
19        self.vm.wait()
20        self.assertEqual(self.vm.exitcode(), 1, "QEMU exit code should be 1")
21        self.assertRegex(self.vm.get_log(), r'-cpu option cannot be empty')
22
23if __name__ == '__main__':
24    QemuSystemTest.main()
25