[PATCH] socket-test: don't try to be clever, fail if no XDG_RUNTIME_DIR is set

Kristian Høgsberg hoegsberg at gmail.com
Tue Aug 14 07:11:34 PDT 2012


On Tue, Aug 14, 2012 at 11:53:08AM +0200, Philipp Brüschweiler wrote:
> Not only setenv(), also putenv() allocates memory on my system
> (glibc 2.16.0). Just fail with a clear message if XDG_RUNTIME_DIR is
> not set.

Yeah, lets just require this.

Kristian

> https://bugs.freedesktop.org/show_bug.cgi?id=52618
> ---
>  tests/socket-test.c | 21 ++++++++++-----------
>  1 Datei geändert, 10 Zeilen hinzugefügt(+), 11 Zeilen entfernt(-)
> 
> diff --git a/tests/socket-test.c b/tests/socket-test.c
> index 0ee5ad0..f0c06f4 100644
> --- a/tests/socket-test.c
> +++ b/tests/socket-test.c
> @@ -36,17 +36,20 @@ static const struct sockaddr_un example_sockaddr_un;
>  
>  #define TOO_LONG (1 + sizeof example_sockaddr_un.sun_path)
>  
> +/* Ensure the connection doesn't fail due to lack of XDG_RUNTIME_DIR. */
> +static void require_xdg_runtime_dir()
> +{
> +	char *val = getenv("XDG_RUNTIME_DIR");
> +	if (!val)
> +		assert(0 && "set $XDG_RUNTIME_DIR to run this test");
> +}
> +
>  TEST(socket_path_overflow_client_connect)
>  {
>  	char path[TOO_LONG];
>  	struct wl_display *d;
> -	int ret;
>  
> -	/* Ensure the connection doesn't fail due to lack of
> -	   XDG_RUNTIME_DIR. Don't use setenv(), as that allocates
> -	   memory and creates a spurious memory leak failure. */
> -	ret = putenv("XDG_RUNTIME_DIR=.");
> -	assert(ret == 0);
> +	require_xdg_runtime_dir();
>  
>  	memset(path, 'a', sizeof path);
>  	path[sizeof path - 1] = '\0';
> @@ -62,11 +65,7 @@ TEST(socket_path_overflow_server_create)
>  	struct wl_display *d;
>  	int ret;
>  
> -	/* Ensure the connection doesn't fail due to lack of
> -	   XDG_RUNTIME_DIR. Don't use setenv(), as that allocates
> -	   memory and creates a spurious memory leak failure. */
> -	ret = putenv("XDG_RUNTIME_DIR=.");
> -	assert(ret == 0);
> +	require_xdg_runtime_dir();
>  
>  	memset(path, 'a', sizeof path);
>  	path[sizeof path - 1] = '\0';
> -- 
> 1.7.11.4
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list