1
2
3
4
5
6
7
8
9
10#include "qemu/osdep.h"
11#include "libqtest.h"
12#include "qapi/qmp/qdict.h"
13
14static void test_panic(void)
15{
16 uint8_t val;
17 QDict *response, *data;
18
19 val = inb(0x505);
20 g_assert_cmpuint(val, ==, 1);
21
22 outb(0x505, 0x1);
23
24 response = qmp_receive();
25 g_assert(qdict_haskey(response, "event"));
26 g_assert_cmpstr(qdict_get_str(response, "event"), ==, "GUEST_PANICKED");
27 g_assert(qdict_haskey(response, "data"));
28 data = qdict_get_qdict(response, "data");
29 g_assert(qdict_haskey(data, "action"));
30 g_assert_cmpstr(qdict_get_str(data, "action"), ==, "pause");
31 QDECREF(response);
32}
33
34int main(int argc, char **argv)
35{
36 int ret;
37
38 g_test_init(&argc, &argv, NULL);
39 qtest_add_func("/pvpanic/panic", test_panic);
40
41 qtest_start("-device pvpanic");
42 ret = g_test_run();
43
44 qtest_end();
45
46 return ret;
47}
48