And here's a second round with free()s for the asprintf()s.

On 21/08/14 11:46 AM, Derek Foreman wrote:
> This is my first attempt at a patch to allow running weston-keyboard,
> desktop-shell and screenshooter out of the build directory so make check
> doesn't do funny things...
> 
> 
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
> 
>From 7a5bcfaf48693018c5bbe3779bbd9d080d4e436f Mon Sep 17 00:00:00 2001
From: Derek Foreman <der...@osg.samsung.com>
Date: Thu, 21 Aug 2014 11:32:38 -0500
Subject: [PATCH] tests: allow running make check without make install

desktop shell and weston keyboard both refer to themselves prefixed by
LIBEXECDIR, however this is only valid once installed.  make check will
currently either fail or run pre-existing versions.

This patch adds a way to override that location by setting the env var
WESTON_BUILD_DIR - which is then set by the test env script so make check
will test the versions in the build directory regardless of whether they're
installed or not.
---
 desktop-shell/shell.c  |  7 +++++--
 shared/config-parser.c | 12 ++++++++++++
 shared/config-parser.h |  3 +++
 src/screenshooter.c    |  6 +++++-
 src/text-backend.c     |  6 +++++-
 tests/weston-tests-env |  2 ++
 6 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index e3abaad..1e7e7ed 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -567,7 +567,7 @@ shell_configuration(struct desktop_shell *shell)
 {
 	struct weston_config_section *section;
 	int duration;
-	char *s;
+	char *s, *client;
 
 	section = weston_config_get_section(shell->compositor->config,
 					    "screensaver", NULL, NULL);
@@ -578,8 +578,11 @@ shell_configuration(struct desktop_shell *shell)
 
 	section = weston_config_get_section(shell->compositor->config,
 					    "shell", NULL, NULL);
+	asprintf(&client, "%s/%s", weston_config_get_libexec_dir(),
+				   WESTON_SHELL_CLIENT);
 	weston_config_section_get_string(section,
-					 "client", &s, LIBEXECDIR "/" WESTON_SHELL_CLIENT);
+					 "client", &s, client);
+	free(client);
 	shell->client = s;
 	weston_config_section_get_string(section,
 					 "binding-modifier", &s, "super");
diff --git a/shared/config-parser.c b/shared/config-parser.c
index 8defbbb..4542ca6 100644
--- a/shared/config-parser.c
+++ b/shared/config-parser.c
@@ -282,6 +282,18 @@ weston_config_section_get_bool(struct weston_config_section *section,
 	return 0;
 }
 
+WL_EXPORT
+const char *
+weston_config_get_libexec_dir(void)
+{
+	const char *path = getenv("WESTON_BUILD_DIR");
+
+	if (path)
+		return path;
+
+	return LIBEXECDIR;
+}
+
 static struct weston_config_section *
 config_add_section(struct weston_config *config, const char *name)
 {
diff --git a/shared/config-parser.h b/shared/config-parser.h
index 745562b..1ecc8cc 100644
--- a/shared/config-parser.h
+++ b/shared/config-parser.h
@@ -92,6 +92,9 @@ int
 weston_config_section_get_bool(struct weston_config_section *section,
 			       const char *key,
 			       int *value, int default_value);
+const char *
+weston_config_get_libexec_dir(void);
+
 struct weston_config *
 weston_config_parse(const char *name);
 
diff --git a/src/screenshooter.c b/src/screenshooter.c
index 4403933..af2c754 100644
--- a/src/screenshooter.c
+++ b/src/screenshooter.c
@@ -286,12 +286,16 @@ screenshooter_binding(struct weston_seat *seat, uint32_t time, uint32_t key,
 		      void *data)
 {
 	struct screenshooter *shooter = data;
-	const char *screenshooter_exe = LIBEXECDIR "/weston-screenshooter";
+	char *screenshooter_exe;
+
+	asprintf(&screenshooter_exe, "%s/%s", weston_config_get_libexec_dir(),
+					      "/weston-screenshooter");
 
 	if (!shooter->client)
 		shooter->client = weston_client_launch(shooter->ec,
 					&shooter->process,
 					screenshooter_exe, screenshooter_sigchld);
+	free(screenshooter_exe);
 }
 
 struct weston_recorder {
diff --git a/src/text-backend.c b/src/text-backend.c
index 1d549d4..7d2a064 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -937,12 +937,16 @@ static void
 text_backend_configuration(struct text_backend *text_backend)
 {
 	struct weston_config_section *section;
+	char *client;
 
 	section = weston_config_get_section(text_backend->compositor->config,
 					    "input-method", NULL, NULL);
+	asprintf(&client, "%s/weston-keyboard",
+		 weston_config_get_libexec_dir());
 	weston_config_section_get_string(section, "path",
 					 &text_backend->input_method.path,
-					 LIBEXECDIR "/weston-keyboard");
+					 client);
+	free(client);
 }
 
 static void
diff --git a/tests/weston-tests-env b/tests/weston-tests-env
index 473e092..e332354 100755
--- a/tests/weston-tests-env
+++ b/tests/weston-tests-env
@@ -28,6 +28,7 @@ XWAYLAND_PLUGIN=$abs_builddir/.libs/xwayland.so
 
 case $TESTNAME in
 	*.la|*.so)
+		WESTON_BUILD_DIR=$abs_builddir \
 		$WESTON --backend=$BACKEND \
 			--no-config \
 			--shell=$SHELL_PLUGIN \
@@ -37,6 +38,7 @@ case $TESTNAME in
 			&> "$OUTLOG"
 		;;
 	*)
+		WESTON_BUILD_DIR=$abs_builddir \
 		WESTON_TEST_CLIENT_PATH=$abs_builddir/$TESTNAME $WESTON \
 			--socket=test-$(basename $TESTNAME) \
 			--backend=$BACKEND \
-- 
2.1.0.rc1

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to