From b01ae077274e579bd09476086b6dc1f3685fc466 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Sat, 24 Mar 2012 14:27:30 -0400 Subject: [PATCH] connection-test: Test fd transport --- tests/connection-test.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/connection-test.c b/tests/connection-test.c index 218bf59..3747857 100644 --- a/tests/connection-test.c +++ b/tests/connection-test.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include "../src/wayland-private.h" #include "test-runner.h" @@ -150,6 +152,7 @@ struct marshal_data { uint32_t u; int32_t i; const char *s; + int h; } value; }; @@ -270,6 +273,21 @@ validate_demarshal_s(struct marshal_data *data, } static void +validate_demarshal_h(struct marshal_data *data, + struct wl_object *object, int fd) +{ + struct stat buf1, buf2; + + assert(fd != data->value.h); + fstat(fd, &buf1); + fstat(data->value.h, &buf2); + assert(buf1.st_dev == buf2.st_dev); + assert(buf1.st_ino == buf2.st_ino); + close(fd); + close(data->value.h); +} + +static void demarshal(struct marshal_data *data, const char *format, uint32_t *msg, void (*func)(void)) { @@ -361,6 +379,7 @@ marshal_demarshal(struct marshal_data *data, TEST(connection_marshal_demarshal) { struct marshal_data data; + char f[] = "/tmp/weston-tests-XXXXXX"; setup_marshal_data(&data); @@ -376,5 +395,10 @@ TEST(connection_marshal_demarshal) marshal_demarshal(&data, (void *) validate_demarshal_s, 28, "s", data.value.s); + data.value.h = mkstemp(f); + assert(data.value.h >= 0); + marshal_demarshal(&data, (void *) validate_demarshal_h, + 8, "h", data.value.h); + release_marshal_data(&data); } -- 2.7.4