[PATCH weston 3/6] weston-test: Get the test client path from args
Pekka Paalanen
ppaalanen at gmail.com
Fri Apr 26 02:28:10 PDT 2013
On Tue, 23 Apr 2013 14:54:47 +0200
Quentin Glidic <sardemff7+wayland at sardemff7.net> wrote:
> From: Quentin Glidic <sardemff7+git at sardemff7.net>
>
> Signed-off-by: Quentin Glidic <sardemff7+git at sardemff7.net>
> ---
> tests/weston-test.c | 18 ++++++++++++------
> tests/weston-tests-env | 3 ++-
> 2 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/tests/weston-test.c b/tests/weston-test.c
> index 55c5da4..c19db3a 100644
> --- a/tests/weston-test.c
> +++ b/tests/weston-test.c
> @@ -29,6 +29,7 @@
> #include "wayland-test-server-protocol.h"
>
> struct weston_test {
> + char *client;
> struct weston_compositor *compositor;
> struct weston_layer layer;
> struct weston_process process;
> @@ -202,19 +203,15 @@ idle_launch_client(void *data)
> struct weston_test *test = data;
> pid_t pid;
> sigset_t allsigs;
> - char *path;
>
> - path = getenv("WESTON_TEST_CLIENT_PATH");
> - if (path == NULL)
> - exit(EXIT_FAILURE);
> pid = fork();
> if (pid == -1)
> exit(EXIT_FAILURE);
> if (pid == 0) {
> sigfillset(&allsigs);
> sigprocmask(SIG_UNBLOCK, &allsigs, NULL);
> - execl(path, path, NULL);
> - weston_log("compositor: executing '%s' failed: %m\n", path);
> + execl(test->client, test->client, NULL);
> + weston_log("compositor: executing '%s' failed: %m\n", test->client);
> exit(EXIT_FAILURE);
> }
>
> @@ -229,6 +226,7 @@ module_init(struct weston_compositor *ec,
> {
> struct weston_test *test;
> struct wl_event_loop *loop;
> + int i;
>
> test = malloc(sizeof *test);
> if (test == NULL)
> @@ -242,6 +240,14 @@ module_init(struct weston_compositor *ec,
> test, bind_test) == NULL)
> return -1;
>
> + if (*argc < 2)
> + exit(EXIT_FAILURE);
> + test->client = strdup(argv[1]);
> + for (i = 1; i < *argc; ++i)
> + argv[i] = argv[i+1];
> + *argc = i-1;
> +
> +
> loop = wl_display_get_event_loop(ec->wl_display);
> wl_event_loop_add_idle(loop, idle_launch_client, test);
>
> diff --git a/tests/weston-tests-env b/tests/weston-tests-env
> index 2e5fa95..8ae0bcf 100755
> --- a/tests/weston-tests-env
> +++ b/tests/weston-tests-env
> @@ -27,10 +27,11 @@ case $1 in
> &> "$OUTLOG"
> ;;
> *)
> - WESTON_TEST_CLIENT_PATH=$abs_builddir/$1 $WESTON \
> + $WESTON \
> --socket=test-$(basename $1) \
> --backend=$BACKEND \
> --log="$SERVERLOG" \
> --modules=$abs_builddir/.libs/weston-test.so,xwayland.so \
> + $abs_builddir/$1 \
> &> "$OUTLOG"
> esac
Hi Quentin,
it seems quite fragile to use an anonymous argument. What if something
else used an anonymous argument, too? Who gets what will start to
depend on the module loading order.
Why not use the command line parser with a real long option?
Thanks,
pq
More information about the wayland-devel
mailing list