tests/unit/test-qmp-event: Simplify event emission check
commit5712b7e4fbe661338d4581b574eb3b9da9f44915
authorMarkus Armbruster <armbru@redhat.com>
Wed, 22 Nov 2023 07:24:55 +0000 (22 08:24 +0100)
committerThomas Huth <thuth@redhat.com>
Wed, 20 Dec 2023 09:29:23 +0000 (20 10:29 +0100)
tree5653ffa50cebdf95de013c8eaf6524f74cb6d151
parentc363764a6048f64d11c6cabf180154cf6f13ac3a
tests/unit/test-qmp-event: Simplify event emission check

The generated qapi_event_send_FOO() call an event emitter function.
It's test_qapi_event_emit() in this test.  It compares the actual
event to the expected event, and sets a flag to record it was called.
The test functions set expected data and clear the flag before calling
qapi_event_send_FOO(), and check the flag afterwards.

Make test_qapi_event_emit() consume expected data, and the test
functions check it was consumed.  Delete the flag.  This is simpler.
It also catches extraneous calls of test_qapi_event_emit().  Catching
that is not worthwhile, but since the cost is negative...

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20231122072456.2518816-3-armbru@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
tests/unit/test-qmp-event.c