summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2014-06-25 00:06:59 +0200
committerPeter Hutterer <peter.hutterer@who-t.net>2014-06-25 10:27:03 +1000
commit89aa3ca176130104f2fc5c034400cbb4c41cf479 (patch)
tree191856156e5f4b7d75340cad4c02b7a70d8ec9b0
parentfaab25c25cd9cf1b76962e9cb8b26c2c754c0cde (diff)
downloadlibinput-89aa3ca176130104f2fc5c034400cbb4c41cf479.tar.gz
test: Add context reference counting test
This test relies on valgrind detecting the leak and use-after-free. Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--test/misc.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/misc.c b/test/misc.c
index ad2e1f66..bea7e889 100644
--- a/test/misc.c
+++ b/test/misc.c
@@ -371,12 +371,32 @@ START_TEST(event_conversion_touch)
}
END_TEST
+START_TEST(context_ref_counting)
+{
+ struct libinput *li;
+
+ /* These tests rely on valgrind to detect memory leak and use after
+ * free errors. */
+
+ li = libinput_path_create_context(&simple_interface, NULL);
+ ck_assert_notnull(li);
+ ck_assert_ptr_eq(libinput_unref(li), NULL);
+
+ li = libinput_path_create_context(&simple_interface, NULL);
+ ck_assert_notnull(li);
+ ck_assert_ptr_eq(libinput_ref(li), li);
+ ck_assert_ptr_eq(libinput_unref(li), li);
+ ck_assert_ptr_eq(libinput_unref(li), NULL);
+}
+END_TEST
+
int main (int argc, char **argv) {
litest_add_no_device("events:conversion", event_conversion_device_notify);
litest_add_no_device("events:conversion", event_conversion_pointer);
litest_add_no_device("events:conversion", event_conversion_pointer_abs);
litest_add_no_device("events:conversion", event_conversion_key);
litest_add_no_device("events:conversion", event_conversion_touch);
+ litest_add_no_device("context:refcount", context_ref_counting);
return litest_run(argc, argv);
}