tests: destroy client in keyboard-test

Fixes all the leaks reported by ASan in this test.

The manual keyboard release in
keyboard_timestamps_stop_after_client_releases_wl_keyboard is slightly
awkward as we need to open-code a part of input_destroy() to avoid
double-freeing keyboard->wl_keyboard.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 3 years ago committed by Pekka Paalanen
parent 2516e3308d
commit ef8d652023
  1. 10
      tests/keyboard-test.c

@ -105,6 +105,8 @@ TEST(simple_keyboard_test)
break; break;
} }
} }
client_destroy(client);
} }
TEST(keyboard_key_event_time) TEST(keyboard_key_event_time)
@ -123,6 +125,8 @@ TEST(keyboard_key_event_time)
assert(timespec_eq(&keyboard->key_time_timespec, &t2)); assert(timespec_eq(&keyboard->key_time_timespec, &t2));
input_timestamps_destroy(input_ts); input_timestamps_destroy(input_ts);
client_destroy(client);
} }
TEST(keyboard_timestamps_stop_after_input_timestamps_object_is_destroyed) TEST(keyboard_timestamps_stop_after_input_timestamps_object_is_destroyed)
@ -141,6 +145,8 @@ TEST(keyboard_timestamps_stop_after_input_timestamps_object_is_destroyed)
send_key(client, &t2, 1, WL_KEYBOARD_KEY_STATE_RELEASED); send_key(client, &t2, 1, WL_KEYBOARD_KEY_STATE_RELEASED);
assert(keyboard->key_time_msec == timespec_to_msec(&t2)); assert(keyboard->key_time_msec == timespec_to_msec(&t2));
assert(timespec_is_zero(&keyboard->key_time_timespec)); assert(timespec_is_zero(&keyboard->key_time_timespec));
client_destroy(client);
} }
TEST(keyboard_timestamps_stop_after_client_releases_wl_keyboard) TEST(keyboard_timestamps_stop_after_client_releases_wl_keyboard)
@ -166,4 +172,8 @@ TEST(keyboard_timestamps_stop_after_client_releases_wl_keyboard)
assert(timespec_eq(&keyboard->input_timestamp, &t_other)); assert(timespec_eq(&keyboard->input_timestamp, &t_other));
input_timestamps_destroy(input_ts); input_timestamps_destroy(input_ts);
free(client->input->keyboard);
client->input->keyboard = NULL;
client_destroy(client);
} }

Loading…
Cancel
Save