diff options
-rw-r--r-- | src/display.c | 32 | ||||
-rw-r--r-- | src/greeter.c | 26 | ||||
-rw-r--r-- | src/greeter.h | 1 | ||||
-rw-r--r-- | src/seat.c | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 16 | ||||
-rw-r--r-- | tests/scripts/greeter-fail-start.conf | 2 | ||||
-rw-r--r-- | tests/scripts/greeter-fail-start.script | 21 | ||||
-rw-r--r-- | tests/scripts/greeter-not-installed.conf | 2 | ||||
-rw-r--r-- | tests/scripts/greeter-not-installed.script | 19 | ||||
-rw-r--r-- | tests/scripts/switch-to-user.script | 20 | ||||
-rw-r--r-- | tests/src/test-gobject-greeter.c | 7 | ||||
-rwxr-xr-x | tests/test-greeter-fail-start | 2 | ||||
-rwxr-xr-x | tests/test-greeter-not-installed | 2 |
13 files changed, 116 insertions, 35 deletions
diff --git a/src/display.c b/src/display.c index a441d343..2c4bf493 100644 --- a/src/display.c +++ b/src/display.c @@ -533,6 +533,24 @@ create_session (Display *display, PAMSession *authentication, const gchar *sessi return session; } +static void +display_set_is_ready (Display *display) +{ + if (display->priv->is_ready) + return; + + display->priv->is_ready = TRUE; + g_signal_emit (display, signals[READY], 0); +} + +static void +greeter_connected_cb (Greeter *greeter, Display *display) +{ + // FIXME: Should wait for greeter to signal completely ready if it supports it + g_debug ("Greeter connected, display is ready"); + display_set_is_ready (display); +} + static PAMSession * greeter_start_authentication_cb (Greeter *greeter, const gchar *username, Display *display) { @@ -622,6 +640,7 @@ start_greeter_session (Display *display) return FALSE; display->priv->greeter = greeter_new (display->priv->session); + g_signal_connect (G_OBJECT (display->priv->greeter), "connected", G_CALLBACK (greeter_connected_cb), display); g_signal_connect (G_OBJECT (display->priv->greeter), "start-authentication", G_CALLBACK (greeter_start_authentication_cb), display); g_signal_connect (G_OBJECT (display->priv->greeter), "start-session", G_CALLBACK (greeter_start_session_cb), display); if (display->priv->autologin_timeout) @@ -648,16 +667,6 @@ start_greeter_session (Display *display) return !result; } -static void -display_set_is_ready (Display *display) -{ - if (display->priv->is_ready) - return; - - display->priv->is_ready = TRUE; - g_signal_emit (display, signals[READY], 0); -} - static gboolean display_start_greeter (Display *display) { @@ -678,9 +687,6 @@ display_start_greeter (Display *display) return TRUE; } - // FIXME: Wait for greeter to start - display_set_is_ready (display); - return FALSE; } diff --git a/src/greeter.c b/src/greeter.c index 0cb9fdf5..0bc80c21 100644 --- a/src/greeter.c +++ b/src/greeter.c @@ -19,6 +19,7 @@ #include "ldm-marshal.h" enum { + CONNECTED, START_AUTHENTICATION, START_SESSION, LAST_SIGNAL @@ -194,6 +195,8 @@ handle_connect (Greeter *greeter, const gchar *version) write_string (message, MAX_MESSAGE_LENGTH, value, &offset); } write_message (greeter, message, offset); + + g_signal_emit (greeter, signals[CONNECTED], 0); } static void @@ -656,15 +659,14 @@ greeter_class_init (GreeterClass *klass) klass->start_session = greeter_real_start_session; object_class->finalize = greeter_finalize; - signals[START_SESSION] = - g_signal_new ("start-session", + signals[CONNECTED] = + g_signal_new ("connected", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GreeterClass, start_session), - g_signal_accumulator_true_handled, - NULL, - ldm_marshal_BOOLEAN__STRING, - G_TYPE_BOOLEAN, 1, G_TYPE_STRING); + G_STRUCT_OFFSET (GreeterClass, connected), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); signals[START_AUTHENTICATION] = g_signal_new ("start-authentication", @@ -676,5 +678,15 @@ greeter_class_init (GreeterClass *klass) ldm_marshal_OBJECT__STRING, PAM_SESSION_TYPE, 1, G_TYPE_STRING); + signals[START_SESSION] = + g_signal_new ("start-session", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GreeterClass, start_session), + g_signal_accumulator_true_handled, + NULL, + ldm_marshal_BOOLEAN__STRING, + G_TYPE_BOOLEAN, 1, G_TYPE_STRING); + g_type_class_add_private (klass, sizeof (GreeterPrivate)); } diff --git a/src/greeter.h b/src/greeter.h index 2ff1c890..9d9a7f3e 100644 --- a/src/greeter.h +++ b/src/greeter.h @@ -31,6 +31,7 @@ typedef struct typedef struct { GObjectClass parent_class; + void (*connected)(Greeter *greeter); PAMSession *(*start_authentication)(Greeter *greeter, const gchar *username); gboolean (*start_session)(Greeter *greeter, const gchar *session, gboolean is_guest); } GreeterClass; @@ -437,6 +437,7 @@ static void display_ready_cb (Display *display, Seat *seat) { /* Switch to this new display */ + g_debug ("New display ready, switching to it"); SEAT_GET_CLASS (seat)->set_active_display (seat, display); } diff --git a/tests/Makefile.am b/tests/Makefile.am index 46028000..d3365a64 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,6 +2,8 @@ SUBDIRS = src TESTS = \ test-xserver-fail-start \ + test-greeter-fail-start \ + test-greeter-not-installed \ test-no-config \ test-headless \ test-autologin \ @@ -38,7 +40,6 @@ TESTS = \ # test-autologin-session-exit-error # test-login-gobject-session-exit-error # test-login-qt-session-exit-error -# test-greeter-no-start # test-greeter-no-exit if COMPILE_LIBLIGHTDM_QT @@ -61,7 +62,6 @@ endif # In progress # test-autologin-xserver-crash -# test-xserver-fail-start # test-greeter-xserver-crash EXTRA_DIST = \ @@ -87,6 +87,10 @@ EXTRA_DIST = \ scripts/autologin-session-crash.script \ scripts/autologin-xserver-crash.conf \ scripts/autologin-xserver-crash.script \ + scripts/greeter-fail-start.conf \ + scripts/greeter-fail-start.script \ + scripts/greeter-not-installed.conf \ + scripts/greeter-not-installed.script \ scripts/headless.conf \ scripts/headless.script \ scripts/login.conf \ @@ -122,8 +126,8 @@ EXTRA_DIST = \ scripts/plymouth-active-vt.script \ scripts/plymouth-inactive-vt.conf \ scripts/plymouth-inactive-vt.script \ - scripts/plymouth-xserver-fail-start.conf \ - scripts/plymouth-xserver-fail-start.script \ + scripts/plymouth-no-seat.conf \ + scripts/plymouth-no-seat.script \ scripts/switch-to-greeter.conf \ scripts/switch-to-greeter.script \ scripts/switch-to-guest.conf \ @@ -131,4 +135,6 @@ EXTRA_DIST = \ scripts/switch-to-user.conf \ scripts/switch-to-user.script \ scripts/xdmcp-login.conf \ - scripts/xdmcp-login.script + scripts/xdmcp-login.script \ + scripts/xserver-fail-start.conf \ + scripts/xserver-fail-start.script diff --git a/tests/scripts/greeter-fail-start.conf b/tests/scripts/greeter-fail-start.conf new file mode 100644 index 00000000..7fbc32af --- /dev/null +++ b/tests/scripts/greeter-fail-start.conf @@ -0,0 +1,2 @@ +[test-greeter-config] +return-value=1 diff --git a/tests/scripts/greeter-fail-start.script b/tests/scripts/greeter-fail-start.script new file mode 100644 index 00000000..c01799db --- /dev/null +++ b/tests/scripts/greeter-fail-start.script @@ -0,0 +1,21 @@ +# +# Check that LightDM quits when the greeter fails to start +# +RUNNER DAEMON-START + +# X server starts +XSERVER :50 START +XSERVER :50 INDICATE-READY + +# LightDM connects to X server +XSERVER :50 ACCEPT-CONNECT + +# Greeter fails to start +GREETER START +GREETER EXIT CODE=1 + +# X server stopped +XSERVER :50 TERMINATE SIGNAL=15 + +# Daemon stops with error +RUNNER DAEMON-EXIT STATUS=1 diff --git a/tests/scripts/greeter-not-installed.conf b/tests/scripts/greeter-not-installed.conf new file mode 100644 index 00000000..7fbc32af --- /dev/null +++ b/tests/scripts/greeter-not-installed.conf @@ -0,0 +1,2 @@ +[test-greeter-config] +return-value=1 diff --git a/tests/scripts/greeter-not-installed.script b/tests/scripts/greeter-not-installed.script new file mode 100644 index 00000000..8b84afff --- /dev/null +++ b/tests/scripts/greeter-not-installed.script @@ -0,0 +1,19 @@ +# +# Check that LightDM quits when the greeter does not exist +# +RUNNER DAEMON-START + +# X server starts +XSERVER :50 START +XSERVER :50 INDICATE-READY + +# LightDM connects to X server +XSERVER :50 ACCEPT-CONNECT + +# Invalid greeter attempted, fails to start + +# X server stopped +XSERVER :50 TERMINATE SIGNAL=15 + +# Daemon stops with error +RUNNER DAEMON-EXIT STATUS=1 diff --git a/tests/scripts/switch-to-user.script b/tests/scripts/switch-to-user.script index c946407e..e8864471 100644 --- a/tests/scripts/switch-to-user.script +++ b/tests/scripts/switch-to-user.script @@ -31,17 +31,17 @@ XSERVER :51 INDICATE-READY XSERVER :51 ACCEPT-CONNECT # Existing X server stops, new greeter starts -(XSERVER :50 TERMINATE SIGNAL=15|GREETER TERMINATE SIGNAL=15|GREETER START|GREETER CONNECT-XSERVER :51|XSERVER :51 ACCEPT-CONNECT|GREETER CONNECT-TO-DAEMON|GREETER CONNECTED-TO-DAEMON) -(XSERVER :50 TERMINATE SIGNAL=15|GREETER TERMINATE SIGNAL=15|GREETER START|GREETER CONNECT-XSERVER :51|XSERVER :51 ACCEPT-CONNECT|GREETER CONNECT-TO-DAEMON|GREETER CONNECTED-TO-DAEMON) -(XSERVER :50 TERMINATE SIGNAL=15|GREETER TERMINATE SIGNAL=15|GREETER START|GREETER CONNECT-XSERVER :51|XSERVER :51 ACCEPT-CONNECT|GREETER CONNECT-TO-DAEMON|GREETER CONNECTED-TO-DAEMON) -(XSERVER :50 TERMINATE SIGNAL=15|GREETER TERMINATE SIGNAL=15|GREETER START|GREETER CONNECT-XSERVER :51|XSERVER :51 ACCEPT-CONNECT|GREETER CONNECT-TO-DAEMON|GREETER CONNECTED-TO-DAEMON) -(XSERVER :50 TERMINATE SIGNAL=15|GREETER TERMINATE SIGNAL=15|GREETER START|GREETER CONNECT-XSERVER :51|XSERVER :51 ACCEPT-CONNECT|GREETER CONNECT-TO-DAEMON|GREETER CONNECTED-TO-DAEMON) -(XSERVER :50 TERMINATE SIGNAL=15|GREETER TERMINATE SIGNAL=15|GREETER START|GREETER CONNECT-XSERVER :51|XSERVER :51 ACCEPT-CONNECT|GREETER CONNECT-TO-DAEMON|GREETER CONNECTED-TO-DAEMON) -(XSERVER :50 TERMINATE SIGNAL=15|GREETER TERMINATE SIGNAL=15|GREETER START|GREETER CONNECT-XSERVER :51|XSERVER :51 ACCEPT-CONNECT|GREETER CONNECT-TO-DAEMON|GREETER CONNECTED-TO-DAEMON) - # Alice is automatically selected -GREETER AUTHENTICATE-SELECTED USERNAME=alice -GREETER SHOW-PROMPT TEXT="Password:" +# FIXME: Need to make parallel tests... +(XSERVER :50 TERMINATE SIGNAL=15|GREETER TERMINATE SIGNAL=15|GREETER START|GREETER CONNECT-XSERVER :51|XSERVER :51 ACCEPT-CONNECT|GREETER CONNECT-TO-DAEMON|GREETER CONNECTED-TO-DAEMON|GREETER AUTHENTICATE-SELECTED USERNAME=alice|GREETER SHOW-PROMPT TEXT="Password:") +(XSERVER :50 TERMINATE SIGNAL=15|GREETER TERMINATE SIGNAL=15|GREETER START|GREETER CONNECT-XSERVER :51|XSERVER :51 ACCEPT-CONNECT|GREETER CONNECT-TO-DAEMON|GREETER CONNECTED-TO-DAEMON|GREETER AUTHENTICATE-SELECTED USERNAME=alice|GREETER SHOW-PROMPT TEXT="Password:") +(XSERVER :50 TERMINATE SIGNAL=15|GREETER TERMINATE SIGNAL=15|GREETER START|GREETER CONNECT-XSERVER :51|XSERVER :51 ACCEPT-CONNECT|GREETER CONNECT-TO-DAEMON|GREETER CONNECTED-TO-DAEMON|GREETER AUTHENTICATE-SELECTED USERNAME=alice|GREETER SHOW-PROMPT TEXT="Password:") +(XSERVER :50 TERMINATE SIGNAL=15|GREETER TERMINATE SIGNAL=15|GREETER START|GREETER CONNECT-XSERVER :51|XSERVER :51 ACCEPT-CONNECT|GREETER CONNECT-TO-DAEMON|GREETER CONNECTED-TO-DAEMON|GREETER AUTHENTICATE-SELECTED USERNAME=alice|GREETER SHOW-PROMPT TEXT="Password:") +(XSERVER :50 TERMINATE SIGNAL=15|GREETER TERMINATE SIGNAL=15|GREETER START|GREETER CONNECT-XSERVER :51|XSERVER :51 ACCEPT-CONNECT|GREETER CONNECT-TO-DAEMON|GREETER CONNECTED-TO-DAEMON|GREETER AUTHENTICATE-SELECTED USERNAME=alice|GREETER SHOW-PROMPT TEXT="Password:") +(XSERVER :50 TERMINATE SIGNAL=15|GREETER TERMINATE SIGNAL=15|GREETER START|GREETER CONNECT-XSERVER :51|XSERVER :51 ACCEPT-CONNECT|GREETER CONNECT-TO-DAEMON|GREETER CONNECTED-TO-DAEMON|GREETER AUTHENTICATE-SELECTED USERNAME=alice|GREETER SHOW-PROMPT TEXT="Password:") +(XSERVER :50 TERMINATE SIGNAL=15|GREETER TERMINATE SIGNAL=15|GREETER START|GREETER CONNECT-XSERVER :51|XSERVER :51 ACCEPT-CONNECT|GREETER CONNECT-TO-DAEMON|GREETER CONNECTED-TO-DAEMON|GREETER AUTHENTICATE-SELECTED USERNAME=alice|GREETER SHOW-PROMPT TEXT="Password:") +(XSERVER :50 TERMINATE SIGNAL=15|GREETER TERMINATE SIGNAL=15|GREETER START|GREETER CONNECT-XSERVER :51|XSERVER :51 ACCEPT-CONNECT|GREETER CONNECT-TO-DAEMON|GREETER CONNECTED-TO-DAEMON|GREETER AUTHENTICATE-SELECTED USERNAME=alice|GREETER SHOW-PROMPT TEXT="Password:") +(XSERVER :50 TERMINATE SIGNAL=15|GREETER TERMINATE SIGNAL=15|GREETER START|GREETER CONNECT-XSERVER :51|XSERVER :51 ACCEPT-CONNECT|GREETER CONNECT-TO-DAEMON|GREETER CONNECTED-TO-DAEMON|GREETER AUTHENTICATE-SELECTED USERNAME=alice|GREETER SHOW-PROMPT TEXT="Password:") # Cleanup *STOP-DAEMON diff --git a/tests/src/test-gobject-greeter.c b/tests/src/test-gobject-greeter.c index 293dba67..7c110866 100644 --- a/tests/src/test-gobject-greeter.c +++ b/tests/src/test-gobject-greeter.c @@ -79,6 +79,13 @@ main (int argc, char **argv) if (g_getenv ("LIGHTDM_TEST_CONFIG")) g_key_file_load_from_file (config, g_getenv ("LIGHTDM_TEST_CONFIG"), G_KEY_FILE_NONE, NULL); + if (g_key_file_has_key (config, "test-greeter-config", "return-value", NULL)) + { + int return_value = g_key_file_get_integer (config, "test-greeter-config", "return-value", NULL); + notify_status ("GREETER EXIT CODE=%d", return_value); + return return_value; + } + g_type_init (); main_loop = g_main_loop_new (NULL, FALSE); diff --git a/tests/test-greeter-fail-start b/tests/test-greeter-fail-start new file mode 100755 index 00000000..e330483a --- /dev/null +++ b/tests/test-greeter-fail-start @@ -0,0 +1,2 @@ +#!/bin/sh +./src/test-runner greeter-fail-start test-gobject-greeter diff --git a/tests/test-greeter-not-installed b/tests/test-greeter-not-installed new file mode 100755 index 00000000..d5c030d5 --- /dev/null +++ b/tests/test-greeter-not-installed @@ -0,0 +1,2 @@ +#!/bin/sh +./src/test-runner greeter-not-installed invalid-greeter |