diff options
-rw-r--r-- | .bzrignore | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 4 | ||||
-rw-r--r-- | tests/scripts/unity.conf | 49 | ||||
-rw-r--r-- | tests/src/Makefile.am | 27 | ||||
-rw-r--r-- | tests/src/X.c | 14 | ||||
-rw-r--r-- | tests/src/unity-system-compositor.c | 89 | ||||
-rwxr-xr-x | tests/test-unity | 2 |
7 files changed, 182 insertions, 4 deletions
@@ -68,6 +68,7 @@ tests/src/test-qt5-greeter tests/src/test-runner tests/src/test-script-hook tests/src/test-session +tests/src/unity-system-compositor tests/src/vnc-client tests/src/X tests/src/Xvnc diff --git a/tests/Makefile.am b/tests/Makefile.am index c415cc8c..18296fb6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -146,7 +146,8 @@ TESTS = \ test-python-power-no-login1 \ test-python-power-no-services \ test-open-file-descriptors \ - test-xdmcp-open-file-descriptors + test-xdmcp-open-file-descriptors \ + test-unity # test-session-exit-error # test-greeter-no-exit @@ -337,6 +338,7 @@ EXTRA_DIST = \ scripts/switch-to-user-logout.conf \ scripts/switch-to-user-no-password.conf \ scripts/system-xauthority.conf \ + scripts/unity.conf \ scripts/util-path.conf \ scripts/user-renamed.conf \ scripts/user-renamed-invalid.conf \ diff --git a/tests/scripts/unity.conf b/tests/scripts/unity.conf new file mode 100644 index 00000000..57b0e5f4 --- /dev/null +++ b/tests/scripts/unity.conf @@ -0,0 +1,49 @@ +# +# Check works with Unity seat type +# + +[LightDM] +minimum-display-number=50 + +[SeatDefaults] +type=unity + +#?RUNNER DAEMON-START + +# System compositor starts +#?UNITY-SYSTEM-COMPOSITOR START + +# X server starts +#?XSERVER :50 START +#?XSERVER :50 INDICATE-READY + +# LightDM connects to X server +#?XSERVER :50 ACCEPT-CONNECT + +# Greeter starts +#?GREETER :50 START +#?XSERVER :50 ACCEPT-CONNECT +#?GREETER :50 CONNECT-XSERVER +#?GREETER :50 CONNECT-TO-DAEMON +#?GREETER :50 CONNECTED-TO-DAEMON + +# Log into account with a password +#?*GREETER :50 AUTHENTICATE USERNAME=have-password1 +#?GREETER :50 SHOW-PROMPT TEXT="Password:" +#?*GREETER :50 RESPOND TEXT="password" +#?GREETER :50 AUTHENTICATION-COMPLETE USERNAME=have-password1 AUTHENTICATED=TRUE +#?*GREETER :50 START-SESSION +#?GREETER :50 TERMINATE SIGNAL=15 + +# Session starts +#?SESSION :50 START USER=have-password1 +#?XSERVER :50 ACCEPT-CONNECT +#?SESSION :50 CONNECT-XSERVER + +# Cleanup +#?*STOP-DAEMON +# Don't know what order they will terminate +#?(SESSION :50 TERMINATE SIGNAL=15|XSERVER :50 TERMINATE SIGNAL=15|UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=15) +#?(SESSION :50 TERMINATE SIGNAL=15|XSERVER :50 TERMINATE SIGNAL=15|UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=15) +#?(SESSION :50 TERMINATE SIGNAL=15|XSERVER :50 TERMINATE SIGNAL=15|UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=15) +#?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/src/Makefile.am b/tests/src/Makefile.am index 00465ef6..2b3561bf 100644 --- a/tests/src/Makefile.am +++ b/tests/src/Makefile.am @@ -1,5 +1,17 @@ -noinst_PROGRAMS = dbus-env test-runner X Xvnc test-gobject-greeter test-session test-script-hook guest-account initctl plymouth vnc-client -dist_noinst_SCRIPTS = lightdm-session test-python-greeter +noinst_PROGRAMS = dbus-env \ + initctl \ + plymouth \ + test-gobject-greeter \ + test-runner \ + test-script-hook \ + test-session \ + guest-account \ + unity-system-compositor \ + vnc-client \ + X \ + Xvnc +dist_noinst_SCRIPTS = lightdm-session \ + test-python-greeter noinst_LTLIBRARIES = libsystem.la libsystem_la_SOURCES = libsystem.c @@ -169,6 +181,17 @@ plymouth_LDADD = \ $(GLIB_LIBS) \ $(GIO_UNIX_LIBS) +unity_system_compositor_SOURCES = unity-system-compositor.c status.c status.h +unity_system_compositor_CFLAGS = \ + $(WARN_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(GIO_CFLAGS) \ + $(GIO_UNIX_CFLAGS) +unity_system_compositor_LDADD = \ + $(GLIB_LIBS) \ + $(GIO_LIBS) \ + $(GIO_UNIX_LIBS) + vnc_client_SOURCES = vnc-client.c status.c status.h vnc_client_CFLAGS = \ $(WARN_CFLAGS) \ diff --git a/tests/src/X.c b/tests/src/X.c index 5318afdd..77846688 100644 --- a/tests/src/X.c +++ b/tests/src/X.c @@ -321,10 +321,20 @@ main (int argc, char **argv) { /* Ignore VT args */ } - else if (g_str_has_prefix (arg, "-novtswitch")) + else if (strcmp (arg, "-novtswitch") == 0) { /* Ignore VT args */ } + else if (strcmp (arg, "-mir") == 0) + { + /* FIXME */ + i++; + } + else if (strcmp (arg, "-mirSocket") == 0) + { + /* FIXME */ + i++; + } else { g_printerr ("Unrecognized option: %s\n" @@ -336,6 +346,8 @@ main (int argc, char **argv) "-query host-name Contact named host for XDMCP\n" "-broadcast Broadcast for XDMCP\n" "-port port-num UDP port number to send messages to\n" + "-mir id Mir ID to use\n" + "-mirSocket name Mir socket to use\n" "vtxx Use virtual terminal xx instead of the next available\n", arg, argv[0]); return EXIT_FAILURE; diff --git a/tests/src/unity-system-compositor.c b/tests/src/unity-system-compositor.c new file mode 100644 index 00000000..9a9382fc --- /dev/null +++ b/tests/src/unity-system-compositor.c @@ -0,0 +1,89 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <errno.h> + +#include "status.h" + +static GMainLoop *loop; +static int exit_status = EXIT_SUCCESS; +static int from_dm_fd, to_dm_fd; + +static void +quit (int status) +{ + exit_status = status; + g_main_loop_quit (loop); +} + +static void +signal_cb (int signum) +{ + status_notify ("UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=%d", signum); + quit (EXIT_SUCCESS); +} + +static void +request_cb (const gchar *request) +{ + if (!request) + { + g_main_loop_quit (loop); + return; + } +} + +typedef enum +{ + USC_MESSAGE_PING = 0, + USC_MESSAGE_PONG = 1, + USC_MESSAGE_READY = 2, + USC_MESSAGE_SESSION_CONNECTED = 3, + USC_MESSAGE_SET_ACTIVE_SESSION = 4 +} USCMessageID; + +static void +write_message (guint16 id, const guint8 *payload, guint16 payload_length) +{ + guint8 *data; + gsize data_length = 4 + payload_length; + + data = g_malloc (data_length); + data[0] = id >> 8; + data[1] = id & 0xFF; + data[2] = payload_length >> 8; + data[3] = payload_length & 0xFF; + memcpy (data + 4, payload, payload_length); + + if (write (to_dm_fd, data, data_length) < 0) + fprintf (stderr, "Failed to write to daemon: %s\n", strerror (errno)); +} + +int +main (int argc, char **argv) +{ + signal (SIGINT, signal_cb); + signal (SIGTERM, signal_cb); + signal (SIGHUP, signal_cb); + +#if !defined(GLIB_VERSION_2_36) + g_type_init (); +#endif + + loop = g_main_loop_new (NULL, FALSE); + + status_connect (request_cb); + + if (argc != 3) + return EXIT_FAILURE; + from_dm_fd = atoi (argv[1]); + to_dm_fd = atoi (argv[2]); + + status_notify ("UNITY-SYSTEM-COMPOSITOR START"); + + write_message (USC_MESSAGE_READY, NULL, 0); + + g_main_loop_run (loop); + + return exit_status; +} diff --git a/tests/test-unity b/tests/test-unity new file mode 100755 index 00000000..c5d0a23c --- /dev/null +++ b/tests/test-unity @@ -0,0 +1,2 @@ +#!/bin/sh +./src/dbus-env ./src/test-runner unity test-gobject-greeter |