db-move: moved webkitgtk-6.0 from [testing] to [extra] (x86_64)
[arch-packages.git] / gstreamer / trunk / 0003-tests-allocators-Fix-fdmem-test-with-recent-GLib.patch
blob141f5b61799a5b0e353fe875a68d481fb695d51b
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: "Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
3 Date: Mon, 10 Apr 2023 16:06:19 +0200
4 Subject: [PATCH] tests: allocators: Fix fdmem test with recent GLib
6 The test failed with recent GLib, where `g_close` emits a critical
7 warning on EBADF. Remove the `g_close` check from `test_fdmem` and add
8 another version that tests `GST_FD_MEMORY_FLAG_DONT_CLOSE`.
10 We will depend on the Valgrind test run to warn us about leaked FDs.
12 Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2480
13 ---
14 .../tests/check/libs/allocators.c | 39 ++++++++++++++++++-
15 1 file changed, 38 insertions(+), 1 deletion(-)
17 diff --git a/subprojects/gst-plugins-base/tests/check/libs/allocators.c b/subprojects/gst-plugins-base/tests/check/libs/allocators.c
18 index 6b974b2900e9..c8ee75bcdbe3 100644
19 --- a/subprojects/gst-plugins-base/tests/check/libs/allocators.c
20 +++ b/subprojects/gst-plugins-base/tests/check/libs/allocators.c
21 @@ -95,21 +95,58 @@ GST_START_TEST (test_fdmem)
22 gst_memory_unmap (mem, &info);
24 gst_memory_unref (mem);
25 - fail_unless (g_close (fd, NULL) == 0);
26 + gst_object_unref (alloc);
29 +GST_END_TEST;
31 +GST_START_TEST (test_fdmem_dont_close)
33 + GstAllocator *alloc;
34 + GstMemory *mem;
35 + GstMapInfo info;
36 + GError *error = NULL;
37 + int fd;
38 + const char *data = "0123456789";
40 + fd = g_file_open_tmp (NULL, NULL, &error);
41 + fail_if (error);
42 + fail_unless (write (fd, data, 10) == 10);
44 + alloc = gst_fd_allocator_new ();
45 + fail_unless (alloc);
46 + mem = gst_fd_allocator_alloc (alloc, fd, 10,
47 + GST_FD_MEMORY_FLAG_KEEP_MAPPED | GST_FD_MEMORY_FLAG_DONT_CLOSE);
49 + fail_unless (gst_memory_map (mem, &info, GST_MAP_READ));
50 + fail_unless (info.data[5] == '5');
51 + gst_memory_unmap (mem, &info);
53 + fail_unless (gst_memory_map (mem, &info, GST_MAP_WRITE));
54 + info.data[5] = 'X';
55 + gst_memory_unmap (mem, &info);
57 + fail_unless (gst_memory_map (mem, &info, GST_MAP_READ));
58 + fail_unless (info.data[5] == 'X');
59 + gst_memory_unmap (mem, &info);
61 + gst_memory_unref (mem);
62 + fail_unless (g_close (fd, NULL));
63 gst_object_unref (alloc);
66 GST_END_TEST;
68 static Suite *
69 allocators_suite (void)
71 Suite *s = suite_create ("allocators");
72 TCase *tc_chain = tcase_create ("general");
74 suite_add_tcase (s, tc_chain);
75 tcase_add_test (tc_chain, test_dmabuf);
76 tcase_add_test (tc_chain, test_fdmem);
77 + tcase_add_test (tc_chain, test_fdmem_dont_close);
79 return s;