diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2011-06-16 13:55:14 +1000 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2011-06-16 13:55:14 +1000 |
commit | 97bae4223a6ff42938c0910e964920a4f5b80dda (patch) | |
tree | 1893e24a5c13db69962f6c4413c57675c38e062e /tests | |
parent | c0ae97f137edf254dd5df7dfdc7719e3d4560772 (diff) | |
download | lightdm-97bae4223a6ff42938c0910e964920a4f5b80dda.tar.gz |
Add a test for checking returns to greeter when session quits
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 3 | ||||
-rw-r--r-- | tests/data/xsessions/test-session-crash.desktop | 4 | ||||
-rw-r--r-- | tests/data/xsessions/test-session-logout.desktop | 4 | ||||
-rw-r--r-- | tests/scripts/autologin.script | 1 | ||||
-rw-r--r-- | tests/scripts/login-gobject-invalid-user.script | 1 | ||||
-rw-r--r-- | tests/scripts/login-gobject-logout.conf | 6 | ||||
-rw-r--r-- | tests/scripts/login-gobject-logout.script | 31 | ||||
-rw-r--r-- | tests/scripts/login-gobject-wrong-password.script | 1 | ||||
-rw-r--r-- | tests/scripts/login-gobject.script | 1 | ||||
-rw-r--r-- | tests/scripts/no-config.script | 1 | ||||
-rw-r--r-- | tests/src/test-gobject-greeter.c | 3 | ||||
-rw-r--r-- | tests/src/test-session.c | 20 | ||||
-rw-r--r-- | tests/src/test-xserver.c | 32 | ||||
-rwxr-xr-x | tests/test-login-gobject-logout | 2 |
14 files changed, 100 insertions, 10 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index c7276cff..c3e96a67 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -6,7 +6,8 @@ TESTS = \ test-autologin \ test-login-gobject \ test-login-gobject-wrong-password \ - test-login-gobject-invalid-user + test-login-gobject-invalid-user \ + test-login-gobject-logout EXTRA_DIST = \ $(TESTS) \ diff --git a/tests/data/xsessions/test-session-crash.desktop b/tests/data/xsessions/test-session-crash.desktop new file mode 100644 index 00000000..f0ae5a35 --- /dev/null +++ b/tests/data/xsessions/test-session-crash.desktop @@ -0,0 +1,4 @@ +[Desktop Entry] +Name=Test +Comment=LightDM test session (crashes) +Exec=test-session --crash diff --git a/tests/data/xsessions/test-session-logout.desktop b/tests/data/xsessions/test-session-logout.desktop new file mode 100644 index 00000000..39de5937 --- /dev/null +++ b/tests/data/xsessions/test-session-logout.desktop @@ -0,0 +1,4 @@ +[Desktop Entry] +Name=Test +Comment=LightDM test session (logs out after 1s) +Exec=test-session --logout diff --git a/tests/scripts/autologin.script b/tests/scripts/autologin.script index 67ce5663..53afcacd 100644 --- a/tests/scripts/autologin.script +++ b/tests/scripts/autologin.script @@ -1,5 +1,6 @@ RUNNER DAEMON-START XSERVER :.* START +XSERVER :.* INDICATE-READY XSERVER :.* ACCEPT-CONNECT SESSION START USER=alice XSERVER :.* ACCEPT-CONNECT diff --git a/tests/scripts/login-gobject-invalid-user.script b/tests/scripts/login-gobject-invalid-user.script index 4d1f371a..cc9fce8f 100644 --- a/tests/scripts/login-gobject-invalid-user.script +++ b/tests/scripts/login-gobject-invalid-user.script @@ -1,5 +1,6 @@ RUNNER DAEMON-START XSERVER :.* START +XSERVER :.* INDICATE-READY XSERVER :.* ACCEPT-CONNECT GREETER START XSERVER :.* ACCEPT-CONNECT diff --git a/tests/scripts/login-gobject-logout.conf b/tests/scripts/login-gobject-logout.conf new file mode 100644 index 00000000..988c6db7 --- /dev/null +++ b/tests/scripts/login-gobject-logout.conf @@ -0,0 +1,6 @@ +[LightDM] +seats=test-seat + +[test-seat] +greeter-theme=login-alice +session=test-session-logout diff --git a/tests/scripts/login-gobject-logout.script b/tests/scripts/login-gobject-logout.script new file mode 100644 index 00000000..ae4bb0b0 --- /dev/null +++ b/tests/scripts/login-gobject-logout.script @@ -0,0 +1,31 @@ +RUNNER DAEMON-START +XSERVER :.* START +XSERVER :.* INDICATE-READY +XSERVER :.* ACCEPT-CONNECT +GREETER START +XSERVER :.* ACCEPT-CONNECT +GREETER CONNECT-XSERVER :.* +GREETER CONNECT-TO-DAEMON +GREETER CONNECTED-TO-DAEMON +GREETER LOGIN USERNAME=alice +GREETER SHOW-PROMPT TEXT="Password:" +GREETER PROVIDE-SECRET TEXT="password" +GREETER AUTHENTICATION-COMPLETE AUTHENTICATED=TRUE +GREETER QUIT +SESSION START USER=alice +XSERVER :.* ACCEPT-CONNECT +SESSION CONNECT-XSERVER +SESSION LOGOUT +XSERVER :.* DISCONNECT-CLIENTS +XSERVER :.* INDICATE-READY +XSERVER :.* ACCEPT-CONNECT +GREETER START +XSERVER :.* ACCEPT-CONNECT +GREETER CONNECT-XSERVER :.* +GREETER CONNECT-TO-DAEMON +GREETER CONNECTED-TO-DAEMON +*STOP-DAEMON +# Don't know what order they will terminate +(GREETER TERMINATE SIGNAL=15|XSERVER :.* TERMINATE SIGNAL=15) +(GREETER TERMINATE SIGNAL=15|XSERVER :.* TERMINATE SIGNAL=15) +RUNNER DAEMON-EXIT STATUS=0 diff --git a/tests/scripts/login-gobject-wrong-password.script b/tests/scripts/login-gobject-wrong-password.script index d1e05ee9..74b8568b 100644 --- a/tests/scripts/login-gobject-wrong-password.script +++ b/tests/scripts/login-gobject-wrong-password.script @@ -1,5 +1,6 @@ RUNNER DAEMON-START XSERVER :.* START +XSERVER :.* INDICATE-READY XSERVER :.* ACCEPT-CONNECT GREETER START XSERVER :.* ACCEPT-CONNECT diff --git a/tests/scripts/login-gobject.script b/tests/scripts/login-gobject.script index fae91933..59075191 100644 --- a/tests/scripts/login-gobject.script +++ b/tests/scripts/login-gobject.script @@ -1,5 +1,6 @@ RUNNER DAEMON-START XSERVER :.* START +XSERVER :.* INDICATE-READY XSERVER :.* ACCEPT-CONNECT GREETER START XSERVER :.* ACCEPT-CONNECT diff --git a/tests/scripts/no-config.script b/tests/scripts/no-config.script index 0b08e882..f9077b87 100644 --- a/tests/scripts/no-config.script +++ b/tests/scripts/no-config.script @@ -1,5 +1,6 @@ RUNNER DAEMON-START XSERVER :.* START +XSERVER :.* INDICATE-READY XSERVER :.* ACCEPT-CONNECT GREETER START XSERVER :.* ACCEPT-CONNECT diff --git a/tests/src/test-gobject-greeter.c b/tests/src/test-gobject-greeter.c index 55e9a627..cf973e95 100644 --- a/tests/src/test-gobject-greeter.c +++ b/tests/src/test-gobject-greeter.c @@ -13,11 +13,12 @@ connected_cb (LdmGreeter *greeter) notify_status ("GREETER CONNECTED-TO-DAEMON"); username = ldm_greeter_get_string_property (greeter, "username"); - if (username) + if (username && ldm_greeter_get_is_first (greeter)) { notify_status ("GREETER LOGIN USERNAME=%s", username); ldm_greeter_login (greeter, username); } + g_free (username); } static void diff --git a/tests/src/test-session.c b/tests/src/test-session.c index 05f549d2..2c66dcdb 100644 --- a/tests/src/test-session.c +++ b/tests/src/test-session.c @@ -1,6 +1,9 @@ #include <stdlib.h> #include <stdio.h> +#include <string.h> #include <signal.h> +#include <sys/types.h> +#include <unistd.h> #include <xcb/xcb.h> #include <glib.h> @@ -21,7 +24,7 @@ main (int argc, char **argv) signal (SIGINT, quit_cb); signal (SIGTERM, quit_cb); - + notify_status ("SESSION START USER=%s", getenv ("USER")); loop = g_main_loop_new (NULL, FALSE); @@ -36,6 +39,21 @@ main (int argc, char **argv) notify_status ("SESSION CONNECT-XSERVER"); + if (argc > 1) + { + if (strcmp (argv[1], "--logout") == 0) + { + sleep (1); + notify_status ("SESSION LOGOUT"); + return EXIT_SUCCESS; + } + else if (strcmp (argv[1], "--crash") == 0) + { + notify_status ("SESSION CRASH"); + kill (getpid (), SIGSEGV); + } + } + g_main_loop_run (loop); return EXIT_SUCCESS; diff --git a/tests/src/test-xserver.c b/tests/src/test-xserver.c index e6052f4f..7ad5b3ee 100644 --- a/tests/src/test-xserver.c +++ b/tests/src/test-xserver.c @@ -303,10 +303,31 @@ quit (int status) } static void +indicate_ready () +{ + void *handler; + handler = signal (SIGUSR1, SIG_IGN); + if (handler == SIG_IGN) + { + notify_status ("XSERVER :%d INDICATE-READY", display_number); + kill (getppid (), SIGUSR1); + } + signal (SIGUSR1, handler); +} + +static void signal_cb (int signum) { - notify_status ("XSERVER :%d TERMINATE SIGNAL=%d", display_number, signum); - quit (EXIT_SUCCESS); + if (signum == SIGHUP) + { + notify_status ("XSERVER :%d DISCONNECT-CLIENTS", display_number); + indicate_ready (); + } + else + { + notify_status ("XSERVER :%d TERMINATE SIGNAL=%d", display_number, signum); + quit (EXIT_SUCCESS); + } } int @@ -317,10 +338,10 @@ main (int argc, char **argv) char *pid_string; GMainLoop *loop; int lock_file; - void *handler; signal (SIGINT, signal_cb); signal (SIGTERM, signal_cb); + signal (SIGHUP, signal_cb); for (i = 1; i < argc; i++) { @@ -398,10 +419,7 @@ main (int argc, char **argv) g_io_add_watch (g_io_channel_unix_new (s), G_IO_IN, socket_connect_cb, NULL); /* Indicate ready if parent process has requested it */ - handler = signal (SIGUSR1, SIG_IGN); - if (handler == SIG_IGN) - kill (getppid (), SIGUSR1); - signal (SIGUSR1, handler); + indicate_ready (); g_main_loop_run (loop); diff --git a/tests/test-login-gobject-logout b/tests/test-login-gobject-logout new file mode 100755 index 00000000..ed49d930 --- /dev/null +++ b/tests/test-login-gobject-logout @@ -0,0 +1,2 @@ +#!/bin/sh +./src/test-runner login-gobject-logout |