tests: fix all leaks in devices-test

This fixes all ASan reported leaks in this test.

This test program has several tests named *_multiple that just run
another test function 30 times. Previously without cleanup all the
created clients would be left lingering, but now they are torn down. Ths
might cause a change in test behaviour, although that was never the
intention:

> It is intentional to run it so many times, but it is not intentional
> to run a hundred clients at a time.  The problem is that currently we
> have no destroy function for client.  However, the clients do not run
> simultaneously but serially, so the effect should be the same as if
> we'd destroy them (after the client finishes its body, it just 'is'
> and does nothing until the process exits)

- the original review discussion in
https://lists.freedesktop.org/archives/wayland-devel/2015-March/020957.html

The intention for the repeat testing is that as the Weston instance
remains from test to another, each test needs to undo its changes to the
devices. Failing to correcntly undo would accumulate devices.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 3 years ago
parent f6acdc5db0
commit 591fa3b95b
  1. 20
      tests/devices-test.c

@ -106,6 +106,8 @@ TEST(seat_capabilities_test)
assert(cl->input->pointer);
assert(cl->input->keyboard);
assert(cl->input->touch);
client_destroy(cl);
}
#define COUNT 15
@ -144,6 +146,8 @@ TEST(multiple_device_add_and_remove)
assert(cl->input->pointer);
assert(cl->input->keyboard);
assert(cl->input->touch);
client_destroy(cl);
}
TEST(device_release_before_destroy)
@ -181,6 +185,8 @@ TEST(device_release_before_destroy)
client_roundtrip(cl);
assert(cl->input->caps == WL_SEAT_CAPABILITY_ALL);
client_destroy(cl);
}
TEST(device_release_before_destroy_multiple)
@ -190,12 +196,6 @@ TEST(device_release_before_destroy_multiple)
/* if weston crashed during this test, then there is
* some inconsistency */
for (i = 0; i < 30; ++i) {
/* Fifty times run the previous test. This will create
* fifty clients, because we don't have any
* way how to destroy them (worth of adding!). Only one
* client will run at a time though and so should have no
* effect on the result of the test (after the client
* finishes its body, it just 'is' and does nothing). */
device_release_before_destroy();
}
}
@ -237,6 +237,8 @@ TEST(device_release_after_destroy)
client_roundtrip(cl);
assert(cl->input->caps == WL_SEAT_CAPABILITY_ALL);
client_destroy(cl);
}
TEST(device_release_after_destroy_multiple)
@ -310,6 +312,8 @@ TEST(get_device_after_destroy)
client_roundtrip(cl);
assert(cl->input->caps == WL_SEAT_CAPABILITY_ALL);
client_destroy(cl);
}
TEST(get_device_after_destroy_multiple)
@ -331,6 +335,8 @@ TEST(seats_have_names)
wl_list_for_each(input, &cl->inputs, link) {
assert(input->seat_name);
}
client_destroy(cl);
}
TEST(seat_destroy_and_recreate)
@ -353,4 +359,6 @@ TEST(seat_destroy_and_recreate)
assert(cl->input->pointer);
assert(cl->input->keyboard);
assert(cl->input->touch);
client_destroy(cl);
}

Loading…
Cancel
Save