On Tue, 23 Feb 2016 08:25:23 +0800 Jonas Ådahl <jad...@gmail.com> wrote:
> On Mon, Feb 22, 2016 at 02:35:42PM -0800, Bryce Harrington wrote: > > On Mon, Feb 22, 2016 at 03:03:11PM +0100, Marek Chalupa wrote: > > > Hi > > > > > > On 02/22/16 06:52, Jonas Ådahl wrote: > > > >Add a test case that tests the servers behaviour when creating a pool > > > >of size 0. The test suite will do the memory and fd leak check for us, > > > >so the test case is only a triggerer. > > > > > > > >Signed-off-by: Jonas Ådahl <jad...@gmail.com> > > > >--- > > > > Makefile.am | 5 ++- > > > > tests/shm-test.c | 108 > > > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > > > 2 files changed, 112 insertions(+), 1 deletion(-) > > > > create mode 100644 tests/shm-test.c > > > >+#include <assert.h> > > > >+#include <linux/memfd.h> > > > >+#include <stdbool.h> > > > >+#include <string.h> > > > >+#include <sys/syscall.h> > > > >+#include <unistd.h> > > > >+ > > > >+#include "wayland-client.h" > > > >+#include "test-runner.h" > > > >+#include "test-compositor.h" > > > >+ > > > >+static void > > > >+registry_handle_global(void *data, struct wl_registry *registry, > > > >+ uint32_t id, const char *interface, uint32_t > > > >version) > > > >+{ > > > >+ bool *tested = data; > > > >+ struct wl_shm *shm; > > > >+ int fd, ret; > > > >+ struct wl_shm_pool *pool; > > > >+ > > > >+ if (strcmp (interface, "wl_shm")) > > > >+ return; > > > >+ > > > >+ shm = wl_registry_bind(registry, id, &wl_shm_interface, 1); > > > >+ assert(shm); > > > >+ > > > >+ fd = syscall(__NR_memfd_create, "wayland-tests", MFD_CLOEXEC); > > > > > > memfd_create is rather new syscall, I think that this test won't > > > compile on older systems. Shouldn't we guard it somehow? For > > > example: > > > https://github.com/systemd/kdbus/commit/392f91521592869d67d29a231211b93aa2069dc9 > > > > > > > Good point, on ubuntu 14.04 for example: > > > > CC tests/shm-test.o > > tests/shm-test.c:27:25: fatal error: linux/memfd.h: No such file or > > directory > > #include <linux/memfd.h> > > ^ > > compilation terminated. > > > > > > I'd be okay with having this SKIP on older kernels; better to have the > > test than not, and eventually distros will all catch up. > > > > But is there a different syscall or set of calls that would work on the > > older kernels? Would be nice to get fuller coverage out of this test. > > The other way is to create anonymous files etc. I was lazy as this > didn't need to copy that functio here (os_create_anonymous_file()) but > if we want to support testing on older systems, I guess I'll just drop > the memfd thing and go via tmpfs instead. I suspect BSD won't have memfd > as well so it'd be more portable as well. Yes, please, os_create_anonymous_file(). Memfd is a whole another story. Thanks, pq
pgpxN1plDCjVB.pgp
Description: OpenPGP digital signature
_______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/wayland-devel