From 015c9937df08acb97063ae52e90e92b130e9d167 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Thu, 14 May 2015 13:23:05 +1200 Subject: Improve Xvnc tests --- tests/scripts/vnc-command.conf | 16 +++---- tests/scripts/vnc-dimensions.conf | 16 +++---- tests/scripts/vnc-guest.conf | 18 ++++---- tests/scripts/vnc-login.conf | 18 ++++---- tests/scripts/vnc-open-file-descriptors.conf | 18 ++++---- tests/src/Xvnc.c | 65 +++++++++++++++++++++------- tests/src/test-runner.c | 1 + 7 files changed, 93 insertions(+), 59 deletions(-) (limited to 'tests') diff --git a/tests/scripts/vnc-command.conf b/tests/scripts/vnc-command.conf index 3a974b10..fc2bbcb6 100644 --- a/tests/scripts/vnc-command.conf +++ b/tests/scripts/vnc-command.conf @@ -19,22 +19,22 @@ command=Xvnc -option #?VNC-CLIENT CONNECT # Xvnc server starts -#?XSERVER-0 START GEOMETRY=1024x768 DEPTH=8 OPTION=TRUE +#?XVNC-0 START GEOMETRY=1024x768 DEPTH=8 OPTION=TRUE # Daemon connects when X server is ready -#?*XSERVER-0 INDICATE-READY -#?XSERVER-0 INDICATE-READY -#?XSERVER-0 ACCEPT-CONNECT +#?*XVNC-0 INDICATE-READY +#?XVNC-0 INDICATE-READY +#?XVNC-0 ACCEPT-CONNECT # Negotiate with Xvnc -#?*XSERVER-0 START-VNC +#?*XVNC-0 START-VNC #?VNC-CLIENT CONNECTED VERSION="RFB 003.007" -#?XSERVER-0 VNC-CLIENT-CONNECT VERSION="RFB 003.003" +#?XVNC-0 VNC-CLIENT-CONNECT VERSION="RFB 003.003" # Greeter starts and connects to remote X server #?GREETER-X-0 START XDG_SESSION_CLASS=greeter #?LOGIN1 ACTIVATE-SESSION SESSION=c0 -#?XSERVER-0 ACCEPT-CONNECT +#?XVNC-0 ACCEPT-CONNECT #?GREETER-X-0 CONNECT-XSERVER #?GREETER-X-0 CONNECT-TO-DAEMON #?GREETER-X-0 CONNECTED-TO-DAEMON @@ -42,5 +42,5 @@ command=Xvnc -option # Clean up #?*STOP-DAEMON #?GREETER-X-0 TERMINATE SIGNAL=15 -#?XSERVER-0 TERMINATE SIGNAL=15 +#?XVNC-0 TERMINATE SIGNAL=15 #?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/scripts/vnc-dimensions.conf b/tests/scripts/vnc-dimensions.conf index 8acfff16..0e835138 100644 --- a/tests/scripts/vnc-dimensions.conf +++ b/tests/scripts/vnc-dimensions.conf @@ -21,22 +21,22 @@ depth=16 #?VNC-CLIENT CONNECT # Xvnc server starts -#?XSERVER-0 START GEOMETRY=1440x900 DEPTH=16 OPTION=FALSE +#?XVNC-0 START GEOMETRY=1440x900 DEPTH=16 OPTION=FALSE # Daemon connects when X server is ready -#?*XSERVER-0 INDICATE-READY -#?XSERVER-0 INDICATE-READY -#?XSERVER-0 ACCEPT-CONNECT +#?*XVNC-0 INDICATE-READY +#?XVNC-0 INDICATE-READY +#?XVNC-0 ACCEPT-CONNECT # Negotiate with Xvnc -#?*XSERVER-0 START-VNC +#?*XVNC-0 START-VNC #?VNC-CLIENT CONNECTED VERSION="RFB 003.007" -#?XSERVER-0 VNC-CLIENT-CONNECT VERSION="RFB 003.003" +#?XVNC-0 VNC-CLIENT-CONNECT VERSION="RFB 003.003" # Greeter starts and connects to remote X server #?GREETER-X-0 START XDG_SESSION_CLASS=greeter #?LOGIN1 ACTIVATE-SESSION SESSION=c0 -#?XSERVER-0 ACCEPT-CONNECT +#?XVNC-0 ACCEPT-CONNECT #?GREETER-X-0 CONNECT-XSERVER #?GREETER-X-0 CONNECT-TO-DAEMON #?GREETER-X-0 CONNECTED-TO-DAEMON @@ -44,5 +44,5 @@ depth=16 # Clean up #?*STOP-DAEMON #?GREETER-X-0 TERMINATE SIGNAL=15 -#?XSERVER-0 TERMINATE SIGNAL=15 +#?XVNC-0 TERMINATE SIGNAL=15 #?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/scripts/vnc-guest.conf b/tests/scripts/vnc-guest.conf index 10549d93..2d394f12 100644 --- a/tests/scripts/vnc-guest.conf +++ b/tests/scripts/vnc-guest.conf @@ -21,24 +21,24 @@ user-session=default #?VNC-CLIENT CONNECT # Xvnc server starts -#?XSERVER-0 START GEOMETRY=1024x768 DEPTH=8 OPTION=FALSE +#?XVNC-0 START GEOMETRY=1024x768 DEPTH=8 OPTION=FALSE # Daemon connects when X server is ready -#?*XSERVER-0 INDICATE-READY -#?XSERVER-0 INDICATE-READY -#?XSERVER-0 ACCEPT-CONNECT +#?*XVNC-0 INDICATE-READY +#?XVNC-0 INDICATE-READY +#?XVNC-0 ACCEPT-CONNECT # Negotiate with Xvnc -#?*XSERVER-0 START-VNC +#?*XVNC-0 START-VNC #?VNC-CLIENT CONNECTED VERSION="RFB 003.007" # VNC client connects to X server -#?XSERVER-0 VNC-CLIENT-CONNECT VERSION="RFB 003.003" +#?XVNC-0 VNC-CLIENT-CONNECT VERSION="RFB 003.003" # Greeter starts and connects to remote X server #?GREETER-X-0 START XDG_SESSION_CLASS=greeter #?LOGIN1 ACTIVATE-SESSION SESSION=c0 -#?XSERVER-0 ACCEPT-CONNECT +#?XVNC-0 ACCEPT-CONNECT #?GREETER-X-0 CONNECT-XSERVER #?GREETER-X-0 CONNECT-TO-DAEMON #?GREETER-X-0 CONNECTED-TO-DAEMON @@ -55,12 +55,12 @@ user-session=default # Guest session starts #?SESSION-X-0 START XDG_GREETER_DATA_DIR=.*/guest-.* XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=guest-.* #?LOGIN1 ACTIVATE-SESSION SESSION=c1 -#?XSERVER-0 ACCEPT-CONNECT +#?XVNC-0 ACCEPT-CONNECT #?SESSION-X-0 CONNECT-XSERVER # Clean up #?*STOP-DAEMON #?SESSION-X-0 TERMINATE SIGNAL=15 -#?XSERVER-0 TERMINATE SIGNAL=15 +#?XVNC-0 TERMINATE SIGNAL=15 #?GUEST-ACCOUNT REMOVE USERNAME=guest-.* #?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/scripts/vnc-login.conf b/tests/scripts/vnc-login.conf index 63d951eb..2ba177dc 100644 --- a/tests/scripts/vnc-login.conf +++ b/tests/scripts/vnc-login.conf @@ -21,24 +21,24 @@ user-session=default #?VNC-CLIENT CONNECT # Xvnc server starts -#?XSERVER-0 START GEOMETRY=1024x768 DEPTH=8 OPTION=FALSE +#?XVNC-0 START GEOMETRY=1024x768 DEPTH=8 OPTION=FALSE # Daemon connects when X server is ready -#?*XSERVER-0 INDICATE-READY -#?XSERVER-0 INDICATE-READY -#?XSERVER-0 ACCEPT-CONNECT +#?*XVNC-0 INDICATE-READY +#?XVNC-0 INDICATE-READY +#?XVNC-0 ACCEPT-CONNECT # Negotiate with Xvnc -#?*XSERVER-0 START-VNC +#?*XVNC-0 START-VNC #?VNC-CLIENT CONNECTED VERSION="RFB 003.007" # VNC client connects to X server -#?XSERVER-0 VNC-CLIENT-CONNECT VERSION="RFB 003.003" +#?XVNC-0 VNC-CLIENT-CONNECT VERSION="RFB 003.003" # Greeter starts and connects to remote X server #?GREETER-X-0 START XDG_SESSION_CLASS=greeter #?LOGIN1 ACTIVATE-SESSION SESSION=c0 -#?XSERVER-0 ACCEPT-CONNECT +#?XVNC-0 ACCEPT-CONNECT #?GREETER-X-0 CONNECT-XSERVER #?GREETER-X-0 CONNECT-TO-DAEMON #?GREETER-X-0 CONNECTED-TO-DAEMON @@ -54,11 +54,11 @@ user-session=default # Session starts #?SESSION-X-0 START XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1 #?LOGIN1 ACTIVATE-SESSION SESSION=c1 -#?XSERVER-0 ACCEPT-CONNECT +#?XVNC-0 ACCEPT-CONNECT #?SESSION-X-0 CONNECT-XSERVER # Clean up #?*STOP-DAEMON #?SESSION-X-0 TERMINATE SIGNAL=15 -#?XSERVER-0 TERMINATE SIGNAL=15 +#?XVNC-0 TERMINATE SIGNAL=15 #?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/scripts/vnc-open-file-descriptors.conf b/tests/scripts/vnc-open-file-descriptors.conf index 454e449b..323fa39f 100644 --- a/tests/scripts/vnc-open-file-descriptors.conf +++ b/tests/scripts/vnc-open-file-descriptors.conf @@ -21,23 +21,23 @@ user-session=default #?VNC-CLIENT CONNECT # Xvnc server starts -#?XSERVER-0 START GEOMETRY=1024x768 DEPTH=8 OPTION=FALSE +#?XVNC-0 START GEOMETRY=1024x768 DEPTH=8 OPTION=FALSE # Daemon connects when X server is ready -#?*XSERVER-0 INDICATE-READY -#?XSERVER-0 INDICATE-READY -#?XSERVER-0 ACCEPT-CONNECT +#?*XVNC-0 INDICATE-READY +#?XVNC-0 INDICATE-READY +#?XVNC-0 ACCEPT-CONNECT # Negotiate with Xvnc -#?*XSERVER-0 START-VNC +#?*XVNC-0 START-VNC #?VNC-CLIENT CONNECTED VERSION="RFB 003.007" -#?XSERVER-0 VNC-CLIENT-CONNECT VERSION="RFB 003.003" +#?XVNC-0 VNC-CLIENT-CONNECT VERSION="RFB 003.003" # Greeter starts and connects to remote X server #?GREETER-X-0 START XDG_SESSION_CLASS=greeter #?LOGIN1 ACTIVATE-SESSION SESSION=c0 -#?XSERVER-0 ACCEPT-CONNECT +#?XVNC-0 ACCEPT-CONNECT #?GREETER-X-0 CONNECT-XSERVER #?GREETER-X-0 CONNECT-TO-DAEMON #?GREETER-X-0 CONNECTED-TO-DAEMON @@ -53,7 +53,7 @@ user-session=default # Session starts #?SESSION-X-0 START XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1 #?LOGIN1 ACTIVATE-SESSION SESSION=c1 -#?XSERVER-0 ACCEPT-CONNECT +#?XVNC-0 ACCEPT-CONNECT #?SESSION-X-0 CONNECT-XSERVER # Check file descriptors @@ -63,5 +63,5 @@ user-session=default # Clean up #?*STOP-DAEMON #?SESSION-X-0 TERMINATE SIGNAL=15 -#?XSERVER-0 TERMINATE SIGNAL=15 +#?XVNC-0 TERMINATE SIGNAL=15 #?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/src/Xvnc.c b/tests/src/Xvnc.c index 971ddcef..56dada4f 100644 --- a/tests/src/Xvnc.c +++ b/tests/src/Xvnc.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -13,6 +14,7 @@ #include "x-authority.h" static GMainLoop *loop; +static int exit_status = EXIT_SUCCESS; static GKeyFile *config; @@ -43,8 +45,8 @@ cleanup (void) static void quit (int status) { - cleanup (); - exit (status); + exit_status = status; + g_main_loop_quit (loop); } static gboolean @@ -73,15 +75,8 @@ sigterm_cb (gpointer user_data) static void client_connected_cb (XServer *server, XClient *client) { - gchar *auth_error = NULL; - status_notify ("%s ACCEPT-CONNECT", id); - - if (auth_error) - x_client_send_failed (client, auth_error); - else - x_client_send_success (client); - g_free (auth_error); + x_client_send_success (client); } static void @@ -146,6 +141,7 @@ request_cb (const gchar *name, GHashTable *params) int main (int argc, char **argv) { + int i; char *pid_string; gboolean use_inetd = FALSE; gboolean has_option = FALSE; @@ -153,7 +149,6 @@ main (int argc, char **argv) gint depth = 8; gchar *lock_filename; int lock_file; - int i; #if !defined(GLIB_VERSION_2_36) g_type_init (); @@ -220,7 +215,7 @@ main (int argc, char **argv) } } - id = g_strdup_printf ("XSERVER-%d", display_number); + id = g_strdup_printf ("XVNC-%d", display_number); status_connect (request_cb, id); @@ -249,6 +244,44 @@ main (int argc, char **argv) g_free (lock_filename); lock_file = open (lock_path, O_CREAT | O_EXCL | O_WRONLY, 0444); if (lock_file < 0) + { + char *lock_contents = NULL; + + if (g_file_get_contents (lock_path, &lock_contents, NULL, NULL)) + { + gchar *proc_filename; + pid_t pid; + + pid = atol (lock_contents); + g_free (lock_contents); + + proc_filename = g_strdup_printf ("/proc/%d", pid); + if (!g_file_test (proc_filename, G_FILE_TEST_EXISTS)) + { + gchar *socket_dir; + gchar *socket_filename; + gchar *socket_path; + + socket_dir = g_build_filename (g_getenv ("LIGHTDM_TEST_ROOT"), "tmp", ".X11-unix", NULL); + g_mkdir_with_parents (socket_dir, 0755); + + socket_filename = g_strdup_printf ("X%d", display_number); + socket_path = g_build_filename (socket_dir, socket_filename, NULL); + + g_printerr ("Breaking lock on non-existant process %d\n", pid); + unlink (lock_path); + unlink (socket_path); + + g_free (socket_dir); + g_free (socket_filename); + g_free (socket_path); + } + g_free (proc_filename); + + lock_file = open (lock_path, O_CREAT | O_EXCL | O_WRONLY, 0444); + } + } + if (lock_file < 0) { fprintf (stderr, "Fatal server error:\n" @@ -257,22 +290,22 @@ main (int argc, char **argv) " and start again.\n", display_number, lock_path); g_free (lock_path); lock_path = NULL; - quit (EXIT_FAILURE); + return EXIT_FAILURE; } pid_string = g_strdup_printf ("%10ld", (long) getpid ()); if (write (lock_file, pid_string, strlen (pid_string)) < 0) { g_warning ("Error writing PID file: %s", strerror (errno)); - quit (EXIT_FAILURE); + return EXIT_FAILURE; } g_free (pid_string); if (!x_server_start (xserver)) - quit (EXIT_FAILURE); + return EXIT_FAILURE; g_main_loop_run (loop); cleanup (); - return EXIT_SUCCESS; + return exit_status; } diff --git a/tests/src/test-runner.c b/tests/src/test-runner.c index fad4b746..5d8ae691 100644 --- a/tests/src/test-runner.c +++ b/tests/src/test-runner.c @@ -966,6 +966,7 @@ handle_command (const gchar *command) else if (g_str_has_prefix (name, "SESSION-") || g_str_has_prefix (name, "GREETER-") || g_str_has_prefix (name, "XSERVER-") || + g_str_has_prefix (name, "XVNC-") || strcmp (name, "UNITY-SYSTEM-COMPOSITOR") == 0) { GList *link; -- cgit v1.2.1 From 575c10bf301f156f8e23f6288d4ad3b4cfed32f3 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Thu, 14 May 2015 16:12:06 +1200 Subject: Use new Xmir binary when running X under Unity System Compositor --- tests/Makefile.am | 2 + tests/scripts/unity-autologin-legacy.conf | 42 +++ tests/scripts/unity-autologin.conf | 12 +- tests/scripts/unity-compositor-command.conf | 12 +- tests/scripts/unity-compositor-crash.conf | 12 +- tests/scripts/unity-compositor-next-session.conf | 24 +- tests/scripts/unity-login.conf | 14 +- tests/scripts/unity-mir-greeter-x-session.conf | 12 +- tests/scripts/unity-mir-session-x-greeter.conf | 12 +- tests/scripts/unity-plymouth.conf | 12 +- tests/scripts/unity-script-hooks.conf | 24 +- tests/scripts/unity-switch.conf | 38 +-- tests/src/Makefile.am | 14 + tests/src/Xmir.c | 311 +++++++++++++++++++++++ tests/src/libsystem.c | 9 + tests/src/test-runner.c | 1 + tests/test-unity-autologin-legacy | 2 + 17 files changed, 467 insertions(+), 86 deletions(-) create mode 100644 tests/scripts/unity-autologin-legacy.conf create mode 100644 tests/src/Xmir.c create mode 100755 tests/test-unity-autologin-legacy (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 7b2d22ae..c5d93f4e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -207,6 +207,7 @@ TESTS = \ test-unity-compositor-next-session \ test-unity-compositor-mir-next-session \ test-unity-autologin \ + test-unity-autologin-legacy \ test-unity-login \ test-unity-switch \ test-unity-plymouth \ @@ -522,6 +523,7 @@ EXTRA_DIST = \ scripts/switch-to-user-resettable.conf \ scripts/system-xauthority.conf \ scripts/unity-autologin.conf \ + scripts/unity-autologin-legacy.conf \ scripts/unity-compositor-command.conf \ scripts/unity-compositor-crash.conf \ scripts/unity-compositor-fail-ready.conf \ diff --git a/tests/scripts/unity-autologin-legacy.conf b/tests/scripts/unity-autologin-legacy.conf new file mode 100644 index 00000000..c1a13e1f --- /dev/null +++ b/tests/scripts/unity-autologin-legacy.conf @@ -0,0 +1,42 @@ +# +# Check use legacy X command if Xmir not present +# + +[test-xmir] +hide=true + +[Seat:*] +type=unity +autologin-user=have-password1 +user-session=default + +#?*START-DAEMON +#?RUNNER DAEMON-START + +# System compositor starts +#?UNITY-SYSTEM-COMPOSITOR START FILE=/run/mir_socket VT=7 XDG_VTNR=7 +#?*UNITY-SYSTEM-COMPOSITOR READY + +# X server starts +#?XSERVER-0 START SEAT=seat0 MIR-ID=x-0 + +# Daemon connects when X server is ready +#?*XSERVER-0 INDICATE-READY +#?XSERVER-0 INDICATE-READY +#?XSERVER-0 ACCEPT-CONNECT + +# Session starts +#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1 +#?LOGIN1 ACTIVATE-SESSION SESSION=c0 +#?XSERVER-0 ACCEPT-CONNECT +#?SESSION-X-0 CONNECT-XSERVER + +# System compositor switches to session +#?UNITY-SYSTEM-COMPOSITOR SET-ACTIVE-SESSION ID=x-0 + +# Cleanup +#?*STOP-DAEMON +#?SESSION-X-0 TERMINATE SIGNAL=15 +#?XSERVER-0 TERMINATE SIGNAL=15 +#?UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=15 +#?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/scripts/unity-autologin.conf b/tests/scripts/unity-autologin.conf index 5df08807..841300ba 100644 --- a/tests/scripts/unity-autologin.conf +++ b/tests/scripts/unity-autologin.conf @@ -15,17 +15,17 @@ user-session=default #?*UNITY-SYSTEM-COMPOSITOR READY # X server starts -#?XSERVER-0 START SEAT=seat0 MIR-ID=x-0 +#?XMIR-0 START SEAT=seat0 MIR-ID=x-0 # Daemon connects when X server is ready -#?*XSERVER-0 INDICATE-READY -#?XSERVER-0 INDICATE-READY -#?XSERVER-0 ACCEPT-CONNECT +#?*XMIR-0 INDICATE-READY +#?XMIR-0 INDICATE-READY +#?XMIR-0 ACCEPT-CONNECT # Session starts #?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1 #?LOGIN1 ACTIVATE-SESSION SESSION=c0 -#?XSERVER-0 ACCEPT-CONNECT +#?XMIR-0 ACCEPT-CONNECT #?SESSION-X-0 CONNECT-XSERVER # System compositor switches to session @@ -34,6 +34,6 @@ user-session=default # Cleanup #?*STOP-DAEMON #?SESSION-X-0 TERMINATE SIGNAL=15 -#?XSERVER-0 TERMINATE SIGNAL=15 +#?XMIR-0 TERMINATE SIGNAL=15 #?UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=15 #?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/scripts/unity-compositor-command.conf b/tests/scripts/unity-compositor-command.conf index dfdede5e..204ea24d 100644 --- a/tests/scripts/unity-compositor-command.conf +++ b/tests/scripts/unity-compositor-command.conf @@ -15,17 +15,17 @@ unity-compositor-command=unity-system-compositor --test #?*UNITY-SYSTEM-COMPOSITOR READY # X server starts -#?XSERVER-0 START SEAT=seat0 MIR-ID=x-0 +#?XMIR-0 START SEAT=seat0 MIR-ID=x-0 # Daemon connects when X server is ready -#?*XSERVER-0 INDICATE-READY -#?XSERVER-0 INDICATE-READY -#?XSERVER-0 ACCEPT-CONNECT +#?*XMIR-0 INDICATE-READY +#?XMIR-0 INDICATE-READY +#?XMIR-0 ACCEPT-CONNECT # Greeter starts #?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter #?LOGIN1 ACTIVATE-SESSION SESSION=c0 -#?XSERVER-0 ACCEPT-CONNECT +#?XMIR-0 ACCEPT-CONNECT #?GREETER-X-0 CONNECT-XSERVER #?GREETER-X-0 CONNECT-TO-DAEMON #?GREETER-X-0 CONNECTED-TO-DAEMON @@ -36,6 +36,6 @@ unity-compositor-command=unity-system-compositor --test # Cleanup #?*STOP-DAEMON #?GREETER-X-0 TERMINATE SIGNAL=15 -#?XSERVER-0 TERMINATE SIGNAL=15 +#?XMIR-0 TERMINATE SIGNAL=15 #?UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=15 #?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/scripts/unity-compositor-crash.conf b/tests/scripts/unity-compositor-crash.conf index 8557e731..cd88e1db 100644 --- a/tests/scripts/unity-compositor-crash.conf +++ b/tests/scripts/unity-compositor-crash.conf @@ -13,17 +13,17 @@ type=unity #?*UNITY-SYSTEM-COMPOSITOR READY # X server starts -#?XSERVER-0 START SEAT=seat0 MIR-ID=x-0 +#?XMIR-0 START SEAT=seat0 MIR-ID=x-0 # Daemon connects when X server is ready -#?*XSERVER-0 INDICATE-READY -#?XSERVER-0 INDICATE-READY -#?XSERVER-0 ACCEPT-CONNECT +#?*XMIR-0 INDICATE-READY +#?XMIR-0 INDICATE-READY +#?XMIR-0 ACCEPT-CONNECT # Greeter starts #?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter #?LOGIN1 ACTIVATE-SESSION SESSION=c0 -#?XSERVER-0 ACCEPT-CONNECT +#?XMIR-0 ACCEPT-CONNECT #?GREETER-X-0 CONNECT-XSERVER #?GREETER-X-0 CONNECT-TO-DAEMON #?GREETER-X-0 CONNECTED-TO-DAEMON @@ -36,5 +36,5 @@ type=unity # Daemon exits with error code #?GREETER-X-0 TERMINATE SIGNAL=15 -#?XSERVER-0 TERMINATE SIGNAL=15 +#?XMIR-0 TERMINATE SIGNAL=15 #?RUNNER DAEMON-EXIT STATUS=1 diff --git a/tests/scripts/unity-compositor-next-session.conf b/tests/scripts/unity-compositor-next-session.conf index b8c8b1c4..73191d53 100644 --- a/tests/scripts/unity-compositor-next-session.conf +++ b/tests/scripts/unity-compositor-next-session.conf @@ -16,25 +16,25 @@ autologin-in-background=true #?*UNITY-SYSTEM-COMPOSITOR READY # Greeter session -#?XSERVER-0 START SEAT=seat0 MIR-ID=x-0 -#?*XSERVER-0 INDICATE-READY -#?XSERVER-0 INDICATE-READY -#?XSERVER-0 ACCEPT-CONNECT +#?XMIR-0 START SEAT=seat0 MIR-ID=x-0 +#?*XMIR-0 INDICATE-READY +#?XMIR-0 INDICATE-READY +#?XMIR-0 ACCEPT-CONNECT #?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter #?LOGIN1 ACTIVATE-SESSION SESSION=c0 -#?XSERVER-0 ACCEPT-CONNECT +#?XMIR-0 ACCEPT-CONNECT #?GREETER-X-0 CONNECT-XSERVER #?GREETER-X-0 CONNECT-TO-DAEMON #?GREETER-X-0 CONNECTED-TO-DAEMON # Background session -#?XSERVER-1 START SEAT=seat0 MIR-ID=x-1 -#?*XSERVER-1 INDICATE-READY -#?XSERVER-1 INDICATE-READY -#?XSERVER-1 ACCEPT-CONNECT +#?XMIR-1 START SEAT=seat0 MIR-ID=x-1 +#?*XMIR-1 INDICATE-READY +#?XMIR-1 INDICATE-READY +#?XMIR-1 ACCEPT-CONNECT #?SESSION-X-1 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password2 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password2 #?LOGIN1 ACTIVATE-SESSION SESSION=c0 -#?XSERVER-1 ACCEPT-CONNECT +#?XMIR-1 ACCEPT-CONNECT #?SESSION-X-1 CONNECT-XSERVER # System compositor switches to greeter @@ -52,8 +52,8 @@ autologin-in-background=true # Cleanup #?*STOP-DAEMON #?GREETER-X-0 TERMINATE SIGNAL=15 -#?XSERVER-0 TERMINATE SIGNAL=15 -#?XSERVER-1 TERMINATE SIGNAL=15 +#?XMIR-0 TERMINATE SIGNAL=15 +#?XMIR-1 TERMINATE SIGNAL=15 #?SESSION-X-1 TERMINATE SIGNAL=15 #?UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=15 #?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/scripts/unity-login.conf b/tests/scripts/unity-login.conf index 00ca640c..025c0a65 100644 --- a/tests/scripts/unity-login.conf +++ b/tests/scripts/unity-login.conf @@ -14,17 +14,17 @@ user-session=default #?*UNITY-SYSTEM-COMPOSITOR READY # X server starts -#?XSERVER-0 START SEAT=seat0 MIR-ID=x-0 +#?XMIR-0 START SEAT=seat0 MIR-ID=x-0 # Daemon connects when X server is ready -#?*XSERVER-0 INDICATE-READY -#?XSERVER-0 INDICATE-READY -#?XSERVER-0 ACCEPT-CONNECT +#?*XMIR-0 INDICATE-READY +#?XMIR-0 INDICATE-READY +#?XMIR-0 ACCEPT-CONNECT # Greeter starts #?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter #?LOGIN1 ACTIVATE-SESSION SESSION=c0 -#?XSERVER-0 ACCEPT-CONNECT +#?XMIR-0 ACCEPT-CONNECT #?GREETER-X-0 CONNECT-XSERVER #?GREETER-X-0 CONNECT-TO-DAEMON #?GREETER-X-0 CONNECTED-TO-DAEMON @@ -43,12 +43,12 @@ user-session=default # Session starts #?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1 #?LOGIN1 ACTIVATE-SESSION SESSION=c1 -#?XSERVER-0 ACCEPT-CONNECT +#?XMIR-0 ACCEPT-CONNECT #?SESSION-X-0 CONNECT-XSERVER # Cleanup #?*STOP-DAEMON #?SESSION-X-0 TERMINATE SIGNAL=15 -#?XSERVER-0 TERMINATE SIGNAL=15 +#?XMIR-0 TERMINATE SIGNAL=15 #?UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=15 #?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/scripts/unity-mir-greeter-x-session.conf b/tests/scripts/unity-mir-greeter-x-session.conf index d96ebbb1..11261429 100644 --- a/tests/scripts/unity-mir-greeter-x-session.conf +++ b/tests/scripts/unity-mir-greeter-x-session.conf @@ -28,17 +28,17 @@ user-session=default #?*GREETER-MIR-greeter-0 START-SESSION # X server starts -#?XSERVER-0 START SEAT=seat0 MIR-ID=x-0 +#?XMIR-0 START SEAT=seat0 MIR-ID=x-0 # Daemon connects when X server is ready -#?*XSERVER-0 INDICATE-READY -#?XSERVER-0 INDICATE-READY -#?XSERVER-0 ACCEPT-CONNECT +#?*XMIR-0 INDICATE-READY +#?XMIR-0 INDICATE-READY +#?XMIR-0 ACCEPT-CONNECT # Session starts #?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/no-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=no-password1 #?LOGIN1 ACTIVATE-SESSION SESSION=c1 -#?XSERVER-0 ACCEPT-CONNECT +#?XMIR-0 ACCEPT-CONNECT #?SESSION-X-0 CONNECT-XSERVER # System compositor switches to session @@ -50,6 +50,6 @@ user-session=default # Cleanup #?*STOP-DAEMON #?SESSION-X-0 TERMINATE SIGNAL=15 -#?XSERVER-0 TERMINATE SIGNAL=15 +#?XMIR-0 TERMINATE SIGNAL=15 #?UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=15 #?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/scripts/unity-mir-session-x-greeter.conf b/tests/scripts/unity-mir-session-x-greeter.conf index 046aa578..229f0a65 100644 --- a/tests/scripts/unity-mir-session-x-greeter.conf +++ b/tests/scripts/unity-mir-session-x-greeter.conf @@ -14,17 +14,17 @@ user-session=mir #?*UNITY-SYSTEM-COMPOSITOR READY # X server starts -#?XSERVER-0 START SEAT=seat0 MIR-ID=x-0 +#?XMIR-0 START SEAT=seat0 MIR-ID=x-0 # Daemon connects when X server is ready -#?*XSERVER-0 INDICATE-READY -#?XSERVER-0 INDICATE-READY -#?XSERVER-0 ACCEPT-CONNECT +#?*XMIR-0 INDICATE-READY +#?XMIR-0 INDICATE-READY +#?XMIR-0 ACCEPT-CONNECT # Greeter starts #?GREETER-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter #?LOGIN1 ACTIVATE-SESSION SESSION=c0 -#?XSERVER-0 ACCEPT-CONNECT +#?XMIR-0 ACCEPT-CONNECT #?GREETER-X-0 CONNECT-XSERVER #?GREETER-X-0 CONNECT-TO-DAEMON #?GREETER-X-0 CONNECTED-TO-DAEMON @@ -46,7 +46,7 @@ user-session=mir # Greeter quits once session ready #?GREETER-X-0 TERMINATE SIGNAL=15 -#?XSERVER-0 TERMINATE SIGNAL=15 +#?XMIR-0 TERMINATE SIGNAL=15 # Cleanup #?*STOP-DAEMON diff --git a/tests/scripts/unity-plymouth.conf b/tests/scripts/unity-plymouth.conf index 66f3b637..c927839a 100644 --- a/tests/scripts/unity-plymouth.conf +++ b/tests/scripts/unity-plymouth.conf @@ -25,17 +25,17 @@ active=true #?*UNITY-SYSTEM-COMPOSITOR READY # X server starts -#?XSERVER-0 START SEAT=seat0 MIR-ID=x-0 +#?XMIR-0 START SEAT=seat0 MIR-ID=x-0 # Daemon connects when X server is ready -#?*XSERVER-0 INDICATE-READY -#?XSERVER-0 INDICATE-READY -#?XSERVER-0 ACCEPT-CONNECT +#?*XMIR-0 INDICATE-READY +#?XMIR-0 INDICATE-READY +#?XMIR-0 ACCEPT-CONNECT # Session starts #?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1 #?LOGIN1 ACTIVATE-SESSION SESSION=c0 -#?XSERVER-0 ACCEPT-CONNECT +#?XMIR-0 ACCEPT-CONNECT #?SESSION-X-0 CONNECT-XSERVER # System compositor switches to session @@ -44,6 +44,6 @@ active=true # Cleanup #?*STOP-DAEMON #?SESSION-X-0 TERMINATE SIGNAL=15 -#?XSERVER-0 TERMINATE SIGNAL=15 +#?XMIR-0 TERMINATE SIGNAL=15 #?UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=15 #?RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/scripts/unity-script-hooks.conf b/tests/scripts/unity-script-hooks.conf index bad4a70e..65ec8718 100644 --- a/tests/scripts/unity-script-hooks.conf +++ b/tests/scripts/unity-script-hooks.conf @@ -20,12 +20,12 @@ user-session=default #?*UNITY-SYSTEM-COMPOSITOR READY # X server starts -#?XSERVER-0 START SEAT=seat0 MIR-ID=x-0 +#?XMIR-0 START SEAT=seat0 MIR-ID=x-0 # Daemon connects when X server is ready -#?*XSERVER-0 INDICATE-READY -#?XSERVER-0 INDICATE-READY -#?XSERVER-0 ACCEPT-CONNECT +#?*XMIR-0 INDICATE-READY +#?XMIR-0 INDICATE-READY +#?XMIR-0 ACCEPT-CONNECT #?SCRIPT-HOOK DISPLAY-SETUP #?SCRIPT-HOOK SESSION-SETUP USER=have-password1 @@ -33,7 +33,7 @@ user-session=default # Session starts #?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1 #?LOGIN1 ACTIVATE-SESSION SESSION=c0 -#?XSERVER-0 ACCEPT-CONNECT +#?XMIR-0 ACCEPT-CONNECT #?SESSION-X-0 CONNECT-XSERVER # System compositor switches to session @@ -46,18 +46,18 @@ user-session=default #?SCRIPT-HOOK SESSION-CLEANUP USER=have-password1 # X server stops -#?XSERVER-0 TERMINATE SIGNAL=15 +#?XMIR-0 TERMINATE SIGNAL=15 # Script hooks run #?SCRIPT-HOOK DISPLAY-STOPPED # X server starts -#?XSERVER-1 START SEAT=seat0 MIR-ID=x-1 +#?XMIR-1 START SEAT=seat0 MIR-ID=x-1 # Daemon connects when X server is ready -#?*XSERVER-1 INDICATE-READY -#?XSERVER-1 INDICATE-READY -#?XSERVER-1 ACCEPT-CONNECT +#?*XMIR-1 INDICATE-READY +#?XMIR-1 INDICATE-READY +#?XMIR-1 ACCEPT-CONNECT # Script hooks run #?SCRIPT-HOOK DISPLAY-SETUP @@ -66,7 +66,7 @@ user-session=default # Greeter starts #?GREETER-X-1 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter #?LOGIN1 ACTIVATE-SESSION SESSION=c1 -#?XSERVER-1 ACCEPT-CONNECT +#?XMIR-1 ACCEPT-CONNECT #?GREETER-X-1 CONNECT-XSERVER #?GREETER-X-1 CONNECT-TO-DAEMON #?GREETER-X-1 CONNECTED-TO-DAEMON @@ -77,7 +77,7 @@ user-session=default # Cleanup #?*STOP-DAEMON #?GREETER-X-1 TERMINATE SIGNAL=15 -#?XSERVER-1 TERMINATE SIGNAL=15 +#?XMIR-1 TERMINATE SIGNAL=15 # Script hooks run #?SCRIPT-HOOK DISPLAY-STOPPED diff --git a/tests/scripts/unity-switch.conf b/tests/scripts/unity-switch.conf index d63416ea..51cf79d1 100644 --- a/tests/scripts/unity-switch.conf +++ b/tests/scripts/unity-switch.conf @@ -15,17 +15,17 @@ user-session=default #?*UNITY-SYSTEM-COMPOSITOR READY # X server starts -#?XSERVER-0 START SEAT=seat0 MIR-ID=x-0 +#?XMIR-0 START SEAT=seat0 MIR-ID=x-0 # Daemon connects when X server is ready -#?*XSERVER-0 INDICATE-READY -#?XSERVER-0 INDICATE-READY -#?XSERVER-0 ACCEPT-CONNECT +#?*XMIR-0 INDICATE-READY +#?XMIR-0 INDICATE-READY +#?XMIR-0 ACCEPT-CONNECT # Session starts #?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1 #?LOGIN1 ACTIVATE-SESSION SESSION=c0 -#?XSERVER-0 ACCEPT-CONNECT +#?XMIR-0 ACCEPT-CONNECT #?SESSION-X-0 CONNECT-XSERVER # System compositor switches to session @@ -36,12 +36,12 @@ user-session=default #?RUNNER SWITCH-TO-GREETER # New X server starts -#?XSERVER-1 START SEAT=seat0 MIR-ID=x-1 +#?XMIR-1 START SEAT=seat0 MIR-ID=x-1 # Daemon connects when X server is ready -#?*XSERVER-1 INDICATE-READY -#?XSERVER-1 INDICATE-READY -#?XSERVER-1 ACCEPT-CONNECT +#?*XMIR-1 INDICATE-READY +#?XMIR-1 INDICATE-READY +#?XMIR-1 ACCEPT-CONNECT # Lock session #?LOGIN1 LOCK-SESSION SESSION=c0 @@ -49,7 +49,7 @@ user-session=default # Greeter starts #?GREETER-X-1 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter #?LOGIN1 ACTIVATE-SESSION SESSION=c1 -#?XSERVER-1 ACCEPT-CONNECT +#?XMIR-1 ACCEPT-CONNECT #?GREETER-X-1 CONNECT-XSERVER #?GREETER-X-1 CONNECT-TO-DAEMON #?GREETER-X-1 CONNECTED-TO-DAEMON @@ -66,23 +66,23 @@ user-session=default # New session starts #?SESSION-X-1 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/no-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=no-password1 #?LOGIN1 ACTIVATE-SESSION SESSION=c2 -#?XSERVER-1 ACCEPT-CONNECT +#?XMIR-1 ACCEPT-CONNECT #?SESSION-X-1 CONNECT-XSERVER # Logout of new session #?*SESSION-X-1 LOGOUT -#?XSERVER-1 TERMINATE SIGNAL=15 +#?XMIR-1 TERMINATE SIGNAL=15 # X server starts -#?XSERVER-2 START SEAT=seat0 MIR-ID=x-2 -#?*XSERVER-2 INDICATE-READY -#?XSERVER-2 INDICATE-READY -#?XSERVER-2 ACCEPT-CONNECT +#?XMIR-2 START SEAT=seat0 MIR-ID=x-2 +#?*XMIR-2 INDICATE-READY +#?XMIR-2 INDICATE-READY +#?XMIR-2 ACCEPT-CONNECT # Greeter starts #?GREETER-X-2 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter #?LOGIN1 ACTIVATE-SESSION SESSION=c3 -#?XSERVER-2 ACCEPT-CONNECT +#?XMIR-2 ACCEPT-CONNECT #?GREETER-X-2 CONNECT-XSERVER #?GREETER-X-2 CONNECT-TO-DAEMON #?GREETER-X-2 CONNECTED-TO-DAEMON @@ -93,8 +93,8 @@ user-session=default # Cleanup #?*STOP-DAEMON #?SESSION-X-0 TERMINATE SIGNAL=15 -#?XSERVER-0 TERMINATE SIGNAL=15 +#?XMIR-0 TERMINATE SIGNAL=15 #?GREETER-X-2 TERMINATE SIGNAL=15 -#?XSERVER-2 TERMINATE SIGNAL=15 +#?XMIR-2 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 0afdeadb..d769f027 100644 --- a/tests/src/Makefile.am +++ b/tests/src/Makefile.am @@ -11,6 +11,7 @@ noinst_PROGRAMS = dbus-env \ unity-system-compositor \ vnc-client \ X \ + Xmir \ Xvnc dist_noinst_SCRIPTS = lightdm-session \ test-python-greeter @@ -75,6 +76,19 @@ X_LDADD = \ $(GIO_LIBS) \ $(GIO_UNIX_LIBS) +Xmir_SOURCES = Xmir.c x-authority.c x-authority.h x-common.c x-common.h x-server.c x-server.h status.c status.h +Xmir_CFLAGS = \ + $(WARN_CFLAGS) \ + $(GOBJECT_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(GIO_CFLAGS) \ + $(GIO_UNIX_CFLAGS) +Xmir_LDADD = \ + $(GOBJECT_LIBS) \ + $(GLIB_LIBS) \ + $(GIO_LIBS) \ + $(GIO_UNIX_LIBS) + Xvnc_SOURCES = Xvnc.c x-authority.c x-authority.h x-common.c x-common.h x-server.c x-server.h status.c status.h Xvnc_CFLAGS = \ $(WARN_CFLAGS) \ diff --git a/tests/src/Xmir.c b/tests/src/Xmir.c new file mode 100644 index 00000000..8220a51e --- /dev/null +++ b/tests/src/Xmir.c @@ -0,0 +1,311 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "status.h" +#include "x-server.h" +#include "x-authority.h" +#include "xdmcp-client.h" + +static GMainLoop *loop; +static int exit_status = EXIT_SUCCESS; + +static GKeyFile *config; + +/* Path to lock file */ +static gchar *lock_path = NULL; + +/* Path to authority database to use */ +static gchar *auth_path = NULL; + +/* ID to use for test reporting */ +static gchar *id; + +/* Display number being served */ +static int display_number = 0; + +/* VT being run on */ +static int vt_number = -1; + +/* X server */ +static XServer *xserver = NULL; + +static void +cleanup (void) +{ + if (lock_path) + unlink (lock_path); + if (xserver) + g_object_unref (xserver); +} + +static void +quit (int status) +{ + exit_status = status; + g_main_loop_quit (loop); +} + +static gboolean +sighup_cb (gpointer user_data) +{ + status_notify ("%s DISCONNECT-CLIENTS", id); + return TRUE; +} + +static gboolean +sigint_cb (gpointer user_data) +{ + status_notify ("%s TERMINATE SIGNAL=%d", id, SIGINT); + quit (EXIT_SUCCESS); + return TRUE; +} + +static gboolean +sigterm_cb (gpointer user_data) +{ + status_notify ("%s TERMINATE SIGNAL=%d", id, SIGTERM); + quit (EXIT_SUCCESS); + return TRUE; +} + +static void +client_connected_cb (XServer *server, XClient *client) +{ + status_notify ("%s ACCEPT-CONNECT", id); + x_client_send_success (client); +} + +static void +client_disconnected_cb (XServer *server, XClient *client) +{ + g_signal_handlers_disconnect_matched (client, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, NULL); +} + +static void +request_cb (const gchar *name, GHashTable *params) +{ + if (!name) + { + g_main_loop_quit (loop); + return; + } + + if (strcmp (name, "INDICATE-READY") == 0) + { + void *handler; + + handler = signal (SIGUSR1, SIG_IGN); + if (handler == SIG_IGN) + { + status_notify ("%s INDICATE-READY", id); + kill (getppid (), SIGUSR1); + } + signal (SIGUSR1, handler); + } +} + +int +main (int argc, char **argv) +{ + int i; + char *pid_string; + gchar *seat = NULL; + gchar *mir_id = NULL; + gchar *lock_filename; + gboolean sharevts = FALSE; + int lock_file; + GString *status_text; + +#if !defined(GLIB_VERSION_2_36) + g_type_init (); +#endif + + loop = g_main_loop_new (NULL, FALSE); + + g_unix_signal_add (SIGINT, sigint_cb, NULL); + g_unix_signal_add (SIGTERM, sigterm_cb, NULL); + g_unix_signal_add (SIGHUP, sighup_cb, NULL); + + for (i = 1; i < argc; i++) + { + char *arg = argv[i]; + + if (arg[0] == ':') + { + display_number = atoi (arg + 1); + } + else if (strcmp (arg, "-auth") == 0) + { + auth_path = argv[i+1]; + i++; + } + else if (strcmp (arg, "-nolisten") == 0) + { + char *protocol = argv[i+1]; + i++; + if (strcmp (protocol, "tcp") == 0) + ;//listen_tcp = FALSE; + else if (strcmp (protocol, "unix") == 0) + ;//listen_unix = FALSE; + } + else if (strcmp (arg, "-nr") == 0) + { + } + else if (strcmp (arg, "-background") == 0) + { + /* Ignore arg */ + i++; + } + else if (g_str_has_prefix (arg, "vt")) + { + vt_number = atoi (arg + 2); + } + else if (strcmp (arg, "-novtswitch") == 0) + { + /* Ignore VT args */ + } + else if (strcmp (arg, "-seat") == 0) + { + seat = argv[i+1]; + i++; + } + else if (strcmp (arg, "-sharevts") == 0) + { + sharevts = TRUE; + } + else if (strcmp (arg, "-mir") == 0) + { + mir_id = argv[i+1]; + i++; + } + else if (strcmp (arg, "-mirSocket") == 0) + { + /* FIXME */ + i++; + } + else + { + g_printerr ("Unrecognized option: %s\n" + "Use: %s [:] [option]\n" + "-auth file Select authorization file\n" + "-nolisten protocol Don't listen on protocol\n" + "-background [none] Create root window with no background\n" + "-nr (Ubuntu-specific) Synonym for -background none\n" + "-seat string seat to run on\n" + "-sharevts share VTs with another X server\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; + } + } + + id = g_strdup_printf ("XMIR-%d", display_number); + + status_connect (request_cb, id); + + xserver = x_server_new (display_number); + g_signal_connect (xserver, X_SERVER_SIGNAL_CLIENT_CONNECTED, G_CALLBACK (client_connected_cb), NULL); + g_signal_connect (xserver, X_SERVER_SIGNAL_CLIENT_DISCONNECTED, G_CALLBACK (client_disconnected_cb), NULL); + + status_text = g_string_new (""); + g_string_printf (status_text, "%s START", id); + if (vt_number >= 0) + g_string_append_printf (status_text, " VT=%d", vt_number); + if (seat != NULL) + g_string_append_printf (status_text, " SEAT=%s", seat); + if (sharevts) + g_string_append (status_text, " SHAREVTS=TRUE"); + if (mir_id != NULL) + g_string_append_printf (status_text, " MIR-ID=%s", mir_id); + status_notify ("%s", status_text->str); + g_string_free (status_text, TRUE); + + config = g_key_file_new (); + g_key_file_load_from_file (config, g_build_filename (g_getenv ("LIGHTDM_TEST_ROOT"), "script", NULL), G_KEY_FILE_NONE, NULL); + + if (g_key_file_has_key (config, "test-xserver-config", "return-value", NULL)) + { + int return_value = g_key_file_get_integer (config, "test-xserver-config", "return-value", NULL); + status_notify ("%s EXIT CODE=%d", id, return_value); + return return_value; + } + + lock_filename = g_strdup_printf (".X%d-lock", display_number); + lock_path = g_build_filename (g_getenv ("LIGHTDM_TEST_ROOT"), "tmp", lock_filename, NULL); + g_free (lock_filename); + lock_file = open (lock_path, O_CREAT | O_EXCL | O_WRONLY, 0444); + if (lock_file < 0) + { + char *lock_contents = NULL; + + if (g_file_get_contents (lock_path, &lock_contents, NULL, NULL)) + { + gchar *proc_filename; + pid_t pid; + + pid = atol (lock_contents); + g_free (lock_contents); + + proc_filename = g_strdup_printf ("/proc/%d", pid); + if (!g_file_test (proc_filename, G_FILE_TEST_EXISTS)) + { + gchar *socket_dir; + gchar *socket_filename; + gchar *socket_path; + + socket_dir = g_build_filename (g_getenv ("LIGHTDM_TEST_ROOT"), "tmp", ".X11-unix", NULL); + g_mkdir_with_parents (socket_dir, 0755); + + socket_filename = g_strdup_printf ("X%d", display_number); + socket_path = g_build_filename (socket_dir, socket_filename, NULL); + + g_printerr ("Breaking lock on non-existant process %d\n", pid); + unlink (lock_path); + unlink (socket_path); + + g_free (socket_dir); + g_free (socket_filename); + g_free (socket_path); + } + g_free (proc_filename); + + lock_file = open (lock_path, O_CREAT | O_EXCL | O_WRONLY, 0444); + } + } + if (lock_file < 0) + { + fprintf (stderr, + "Fatal server error:\n" + "Server is already active for display %d\n" + " If this server is no longer running, remove %s\n" + " and start again.\n", display_number, lock_path); + g_free (lock_path); + lock_path = NULL; + return EXIT_FAILURE; + } + pid_string = g_strdup_printf ("%10ld", (long) getpid ()); + if (write (lock_file, pid_string, strlen (pid_string)) < 0) + { + g_warning ("Error writing PID file: %s", strerror (errno)); + return EXIT_FAILURE; + } + g_free (pid_string); + + if (!x_server_start (xserver)) + return EXIT_FAILURE; + + g_main_loop_run (loop); + + cleanup (); + + return exit_status; +} diff --git a/tests/src/libsystem.c b/tests/src/libsystem.c index 97791d16..1d6fffd3 100644 --- a/tests/src/libsystem.c +++ b/tests/src/libsystem.c @@ -178,6 +178,14 @@ setresuid (uid_t ruid, uid_t uuid, uid_t suid) static gchar * redirect_path (const gchar *path) { + /* Hide Xmir for legacy tests */ + if (g_str_has_suffix (path, "/Xmir")) + { + connect_status (); + if (g_key_file_get_boolean (config, "test-xmir", "hide", NULL)) + return NULL; + } + // Don't redirect if inside the running directory if (g_str_has_prefix (path, g_getenv ("LIGHTDM_TEST_ROOT"))) return g_strdup (path); @@ -1928,3 +1936,4 @@ xcb_disconnect (xcb_connection_t *c) g_object_unref (c->socket); free (c); } + diff --git a/tests/src/test-runner.c b/tests/src/test-runner.c index 5d8ae691..8497f66b 100644 --- a/tests/src/test-runner.c +++ b/tests/src/test-runner.c @@ -966,6 +966,7 @@ handle_command (const gchar *command) else if (g_str_has_prefix (name, "SESSION-") || g_str_has_prefix (name, "GREETER-") || g_str_has_prefix (name, "XSERVER-") || + g_str_has_prefix (name, "XMIR-") || g_str_has_prefix (name, "XVNC-") || strcmp (name, "UNITY-SYSTEM-COMPOSITOR") == 0) { diff --git a/tests/test-unity-autologin-legacy b/tests/test-unity-autologin-legacy new file mode 100755 index 00000000..1282544b --- /dev/null +++ b/tests/test-unity-autologin-legacy @@ -0,0 +1,2 @@ +#!/bin/sh +./src/dbus-env ./src/test-runner unity-autologin-legacy test-gobject-greeter -- cgit v1.2.1 From c37e435dcfd8336f38f907994b879174db5ee55f Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Mon, 18 May 2015 15:48:35 +1200 Subject: Fix configuration loading with new [Seat:*] section --- tests/scripts/seatdefaults-still-supported.conf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/scripts/seatdefaults-still-supported.conf b/tests/scripts/seatdefaults-still-supported.conf index 1af19721..9daef83c 100644 --- a/tests/scripts/seatdefaults-still-supported.conf +++ b/tests/scripts/seatdefaults-still-supported.conf @@ -1,7 +1,10 @@ # -# Check LightDM still supports (now deprecated) config section [SeatDefaults] +# Check LightDM still supports (now deprecated) config section [SeatDefaults] and these options override [Seat:*] # +[Seat:*] +user-session=alternative + [SeatDefaults] autologin-user=have-password1 user-session=default -- cgit v1.2.1