Andreas Färber | abc5373 | 2014-02-21 20:38:48 +0100 | [diff] [blame] | 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 | |
Andreas Färber | abc5373 | 2014-02-21 20:38:48 +0100 | [diff] [blame] | 10 | #include "qemu/osdep.h" |
Peter Maydell | 681c28a | 2016-02-08 18:08:51 +0000 | [diff] [blame] | 11 | #include "libqtest.h" |
Andreas Färber | abc5373 | 2014-02-21 20:38:48 +0100 | [diff] [blame] | 12 | |
| 13 | static void test_panic(void) |
| 14 | { |
| 15 | uint8_t val; |
Andreas Färber | 627b1a1 | 2014-02-21 21:17:17 +0100 | [diff] [blame] | 16 | QDict *response, *data; |
Andreas Färber | abc5373 | 2014-02-21 20:38:48 +0100 | [diff] [blame] | 17 | |
| 18 | val = inb(0x505); |
| 19 | g_assert_cmpuint(val, ==, 1); |
| 20 | |
| 21 | outb(0x505, 0x1); |
Andreas Färber | 627b1a1 | 2014-02-21 21:17:17 +0100 | [diff] [blame] | 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"); |
Andreas Färber | abc5373 | 2014-02-21 20:38:48 +0100 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | int main(int argc, char **argv) |
| 33 | { |
| 34 | int ret; |
| 35 | |
| 36 | g_test_init(&argc, &argv, NULL); |
| 37 | qtest_add_func("/pvpanic/panic", test_panic); |
| 38 | |
| 39 | qtest_start("-device pvpanic"); |
| 40 | ret = g_test_run(); |
| 41 | |
| 42 | qtest_end(); |
| 43 | |
| 44 | return ret; |
| 45 | } |