]> git.proxmox.com Git - mirror_qemu.git/blame - tests/pvpanic-test.c
Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2017-04-03' into staging
[mirror_qemu.git] / tests / pvpanic-test.c
CommitLineData
abc53733
AF
1/*
2 * QTest testcase for PV Panic
3 *
4 * Copyright (c) 2014 SUSE LINUX Products GmbH
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */
9
681c28a3 10#include "qemu/osdep.h"
abc53733 11#include "libqtest.h"
abc53733
AF
12
13static void test_panic(void)
14{
15 uint8_t val;
627b1a17 16 QDict *response, *data;
abc53733
AF
17
18 val = inb(0x505);
19 g_assert_cmpuint(val, ==, 1);
20
21 outb(0x505, 0x1);
627b1a17
AF
22
23 response = qmp_receive();
24 g_assert(qdict_haskey(response, "event"));
25 g_assert_cmpstr(qdict_get_str(response, "event"), ==, "GUEST_PANICKED");
26 g_assert(qdict_haskey(response, "data"));
27 data = qdict_get_qdict(response, "data");
28 g_assert(qdict_haskey(data, "action"));
29 g_assert_cmpstr(qdict_get_str(data, "action"), ==, "pause");
dc491fea 30 QDECREF(response);
abc53733
AF
31}
32
33int main(int argc, char **argv)
34{
35 int ret;
36
37 g_test_init(&argc, &argv, NULL);
38 qtest_add_func("/pvpanic/panic", test_panic);
39
40 qtest_start("-device pvpanic");
41 ret = g_test_run();
42
43 qtest_end();
44
45 return ret;
46}