--- tests/libcacard.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/libcacard.c b/tests/libcacard.c index a6ff49b..2b769be 100644 --- a/tests/libcacard.c +++ b/tests/libcacard.c @@ -17,7 +17,8 @@ events_thread(gpointer arg) while (1) { event = vevent_wait_next_vevent(); - if (event == NULL) { + if (event == NULL || event->type == VEVENT_LAST) { + vevent_delete(event); break; } reader_id = vreader_get_id(event->reader); @@ -88,6 +89,7 @@ static void test_list(void) if (vreader_card_is_present(r) == VREADER_OK) { cards++; } + vreader_free(r); } g_assert_cmpint(cards, ==, 1); vreader_list_delete(list); @@ -206,12 +208,28 @@ static void test_remove(void) status = vreader_remove_reader(reader); g_assert_cmpint(status, ==, VREADER_OK); vreader_free(reader); /* get by id ref */ - vreader_free(reader); + //vreader_free(reader); reader = vreader_get_reader_by_id(0); g_assert_null(reader); } + +static void libcacard_finalize(void) +{ + VReader *reader = vreader_get_reader_by_id(0); + + /* This probably supposed to be a event that terminates the loop */ + vevent_queue_vevent(vevent_new(VEVENT_LAST, reader, NULL)); + + /* join */ + g_thread_join(thread); + + /* Clean up */ + vreader_free(reader); + vreader_free(reader); +} + int main(int argc, char *argv[]) { int ret; @@ -232,8 +250,6 @@ int main(int argc, char *argv[]) g_main_loop_unref(loop); - /* FIXME: no wait to queue a NULL event */ - /* g_thread_join(thread); */ - + libcacard_finalize(); return ret; } -- 2.17.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel