mirror of https://gitee.com/openkylin/qemu.git
tests/test-qmp-event: Check event is actually emitted
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20200317115459.31821-11-armbru@redhat.com>
This commit is contained in:
parent
052be50cf4
commit
11deae8cd2
|
@ -26,6 +26,7 @@
|
|||
|
||||
typedef struct TestEventData {
|
||||
QDict *expect;
|
||||
bool emitted;
|
||||
} TestEventData;
|
||||
|
||||
TestEventData *test_event_data;
|
||||
|
@ -52,7 +53,7 @@ void test_qapi_event_emit(test_QAPIEvent event, QDict *d)
|
|||
qdict_del(d, "timestamp");
|
||||
|
||||
g_assert(qobject_is_equal(QOBJECT(d), QOBJECT(test_event_data->expect)));
|
||||
|
||||
test_event_data->emitted = true;
|
||||
}
|
||||
|
||||
static void event_prepare(TestEventData *data,
|
||||
|
@ -87,6 +88,7 @@ static void test_event_a(TestEventData *data,
|
|||
{
|
||||
data->expect = qdict_from_jsonf_nofail("{ 'event': 'EVENT_A' }");
|
||||
qapi_event_send_event_a();
|
||||
g_assert(data->emitted);
|
||||
qobject_unref(data->expect);
|
||||
}
|
||||
|
||||
|
@ -95,6 +97,7 @@ static void test_event_b(TestEventData *data,
|
|||
{
|
||||
data->expect = qdict_from_jsonf_nofail("{ 'event': 'EVENT_B' }");
|
||||
qapi_event_send_event_b();
|
||||
g_assert(data->emitted);
|
||||
qobject_unref(data->expect);
|
||||
}
|
||||
|
||||
|
@ -107,6 +110,7 @@ static void test_event_c(TestEventData *data,
|
|||
"{ 'event': 'EVENT_C', 'data': {"
|
||||
" 'a': 1, 'b': { 'integer': 2, 'string': 'test1' }, 'c': 'test2' } }");
|
||||
qapi_event_send_event_c(true, 1, true, &b, "test2");
|
||||
g_assert(data->emitted);
|
||||
qobject_unref(data->expect);
|
||||
}
|
||||
|
||||
|
@ -132,6 +136,7 @@ static void test_event_d(TestEventData *data,
|
|||
" 'string': 'test2', 'enum2': 'value2' },"
|
||||
" 'b': 'test3', 'enum3': 'value3' } }");
|
||||
qapi_event_send_event_d(&a, "test3", false, NULL, true, ENUM_ONE_VALUE3);
|
||||
g_assert(data->emitted);
|
||||
qobject_unref(data->expect);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue