diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2013-03-12 10:56:51 +1300 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2013-03-12 10:56:51 +1300 |
commit | 8d8c098c5f2c1491d4325f3102d554ff8dfbb256 (patch) | |
tree | 6d4d8f4ea48d9c4e7254ed229a03e1be64993907 | |
parent | f45ef09a3ebf7e8667ce10d95d8bcb7db6d92cca (diff) | |
download | lightdm-git-8d8c098c5f2c1491d4325f3102d554ff8dfbb256.tar.gz |
Ensure test programs quit when the status socket closes
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | tests/src/Makefile.am | 2 | ||||
-rw-r--r-- | tests/src/X.c | 18 | ||||
-rw-r--r-- | tests/src/Xvnc.c | 12 | ||||
-rw-r--r-- | tests/src/guest-account.c | 7 | ||||
-rw-r--r-- | tests/src/initctl.c | 2 | ||||
-rw-r--r-- | tests/src/plymouth.c | 7 | ||||
-rw-r--r-- | tests/src/status.c | 5 | ||||
-rw-r--r-- | tests/src/test-gobject-greeter.c | 13 | ||||
-rwxr-xr-x | tests/src/test-python-greeter | 5 | ||||
-rw-r--r-- | tests/src/test-qt-greeter.cpp | 11 | ||||
-rw-r--r-- | tests/src/test-script-hook.c | 7 | ||||
-rw-r--r-- | tests/src/test-session.c | 9 | ||||
-rw-r--r-- | tests/src/vnc-client.c | 7 |
14 files changed, 64 insertions, 44 deletions
@@ -1,6 +1,7 @@ Overview of changes in lightdm 1.4.1 - * Fix script hooks no longer working with latest glib + * Fix script hooks no longer working with latest glib + * Ensure test programs quit when the status socket closes Overview of changes in lightdm 1.4.0 diff --git a/tests/src/Makefile.am b/tests/src/Makefile.am index 4e999229..b41af6bc 100644 --- a/tests/src/Makefile.am +++ b/tests/src/Makefile.am @@ -127,7 +127,7 @@ test_session_LDADD = \ $(GIO_UNIX_LIBS) \ $(XCB_LIBS) -initctl_SOURCES = initctl.c status.c status.h +initctl_SOURCES = initctl.c initctl_CFLAGS = \ $(WARN_CFLAGS) \ $(GLIB_CFLAGS) \ diff --git a/tests/src/X.c b/tests/src/X.c index a6aeac44..5318afdd 100644 --- a/tests/src/X.c +++ b/tests/src/X.c @@ -13,6 +13,9 @@ #include "x-authority.h" #include "xdmcp-client.h" +static GMainLoop *loop; +static int exit_status = EXIT_SUCCESS; + static GKeyFile *config; /* Path to lock file */ @@ -48,8 +51,8 @@ cleanup () static void quit (int status) { - cleanup (); - exit (status); + exit_status = status; + g_main_loop_quit (loop); } static void @@ -230,6 +233,12 @@ request_cb (const gchar *request) { gchar *r; + if (!request) + { + g_main_loop_quit (loop); + return; + } + r = g_strdup_printf ("XSERVER :%d CRASH", display_number); if (strcmp (request, r) == 0) { @@ -244,7 +253,6 @@ main (int argc, char **argv) { int i; char *pid_string; - GMainLoop *loop; gboolean listen_tcp = TRUE; gboolean listen_unix = TRUE; gboolean do_xdmcp = FALSE; @@ -432,5 +440,7 @@ main (int argc, char **argv) g_main_loop_run (loop); - return EXIT_SUCCESS; + cleanup (); + + return exit_status; } diff --git a/tests/src/Xvnc.c b/tests/src/Xvnc.c index 6b828c23..e684951b 100644 --- a/tests/src/Xvnc.c +++ b/tests/src/Xvnc.c @@ -12,6 +12,8 @@ #include "x-server.h" #include "x-authority.h" +static GMainLoop *loop; + static GKeyFile *config; /* Path to lock file */ @@ -156,14 +158,18 @@ vnc_data_cb (GIOChannel *channel, GIOCondition condition, gpointer data) } static void -request_cb (const gchar *message) +request_cb (const gchar *request) { + if (!request) + { + g_main_loop_quit (loop); + return; + } } int main (int argc, char **argv) { - GMainLoop *loop; char *pid_string; gboolean listen_tcp = TRUE; gboolean listen_unix = TRUE; @@ -290,5 +296,7 @@ main (int argc, char **argv) g_main_loop_run (loop); + cleanup (); + return EXIT_SUCCESS; } diff --git a/tests/src/guest-account.c b/tests/src/guest-account.c index f45a59e8..55cec6df 100644 --- a/tests/src/guest-account.c +++ b/tests/src/guest-account.c @@ -9,11 +9,6 @@ static GKeyFile *config; -static void -request_cb (const gchar *message) -{ -} - int main (int argc, char **argv) { @@ -23,7 +18,7 @@ main (int argc, char **argv) g_type_init (); #endif - status_connect (request_cb); + status_connect (NULL); 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); diff --git a/tests/src/initctl.c b/tests/src/initctl.c index 63e54ac1..428771f0 100644 --- a/tests/src/initctl.c +++ b/tests/src/initctl.c @@ -2,8 +2,6 @@ #include <string.h> #include <glib.h> -#include "status.h" - int main (int argc, char **argv) { diff --git a/tests/src/plymouth.c b/tests/src/plymouth.c index 3537014e..9fada6d4 100644 --- a/tests/src/plymouth.c +++ b/tests/src/plymouth.c @@ -7,11 +7,6 @@ static GKeyFile *config; -static void -request_cb (const gchar *message) -{ -} - int main (int argc, char **argv) { @@ -19,7 +14,7 @@ main (int argc, char **argv) g_type_init (); #endif - status_connect (request_cb); + status_connect (NULL); 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); diff --git a/tests/src/status.c b/tests/src/status.c index a8a82464..cc9b46a7 100644 --- a/tests/src/status.c +++ b/tests/src/status.c @@ -1,3 +1,4 @@ +#include <stdlib.h> #include <stdio.h> #include <string.h> #include <glib.h> @@ -22,7 +23,11 @@ status_request_cb (GSocket *socket, GIOCondition condition, gpointer data) if (n_read > 0) n_read = g_socket_receive (socket, buffer, length, NULL, &error); if (n_read == 0) + { + if (request_func) + request_func (NULL); return FALSE; + } if (error) g_warning ("Error reading from socket: %s", error->message); g_clear_error (&error); diff --git a/tests/src/test-gobject-greeter.c b/tests/src/test-gobject-greeter.c index 6c6aeb40..6597b92e 100644 --- a/tests/src/test-gobject-greeter.c +++ b/tests/src/test-gobject-greeter.c @@ -8,6 +8,7 @@ #include "status.h" +static GMainLoop *loop; static LightDMGreeter *greeter; static xcb_connection_t *connection = NULL; static GKeyFile *config; @@ -55,6 +56,12 @@ static void request_cb (const gchar *request) { gchar *r; + + if (!request) + { + g_main_loop_quit (loop); + return; + } r = g_strdup_printf ("GREETER %s AUTHENTICATE", getenv ("DISPLAY")); if (strcmp (request, r) == 0) @@ -187,8 +194,6 @@ request_cb (const gchar *request) int main (int argc, char **argv) { - GMainLoop *main_loop; - signal (SIGINT, signal_cb); signal (SIGTERM, signal_cb); @@ -196,7 +201,7 @@ main (int argc, char **argv) g_type_init (); #endif - main_loop = g_main_loop_new (NULL, FALSE); + loop = g_main_loop_new (NULL, FALSE); status_connect (request_cb); @@ -242,7 +247,7 @@ main (int argc, char **argv) if (lightdm_greeter_get_lock_hint (greeter)) status_notify ("GREETER %s LOCK-HINT", getenv ("DISPLAY")); - g_main_loop_run (main_loop); + g_main_loop_run (loop); return EXIT_SUCCESS; } diff --git a/tests/src/test-python-greeter b/tests/src/test-python-greeter index 7c78eedf..2ed1b9fa 100755 --- a/tests/src/test-python-greeter +++ b/tests/src/test-python-greeter @@ -29,13 +29,12 @@ def status_notify (message): def request_cb (channel, condition): sys.stderr.write ("request_cb\n") length = status_socket.recv (4) - sys.stderr.write ("read %d\n" % len (length)) if len (length) == 0: + loop.quit (); return False if len (length) > 0: (l,) = struct.unpack ('i', length) request = status_socket.recv (l) - sys.stderr.write ("read '%s' %d\n" % (request, len (request))) r = 'GREETER %s AUTHENTICATE' % os.getenv ('DISPLAY') if request == r: @@ -103,7 +102,7 @@ def request_cb (channel, condition): path = os.getenv ('LIGHTDM_TEST_ROOT') + '/.status-socket' status_socket = socket.socket (socket.AF_UNIX, socket.SOCK_STREAM) status_socket.connect (path) -GLib.io_add_watch (status_socket.fileno (), GLib.IO_IN, request_cb) +GLib.io_add_watch (status_socket.fileno (), GLib.IO_IN | GLib.IO_HUP, request_cb) status_notify ('GREETER %s START' % os.getenv ('DISPLAY')) diff --git a/tests/src/test-qt-greeter.cpp b/tests/src/test-qt-greeter.cpp index 92f48a26..68ab1674 100644 --- a/tests/src/test-qt-greeter.cpp +++ b/tests/src/test-qt-greeter.cpp @@ -12,6 +12,7 @@ #include "test-qt-greeter.h" #include "status.h" +static QCoreApplication *app = NULL; static QSettings *config = NULL; static TestGreeter *greeter = NULL; @@ -59,6 +60,12 @@ static void request_cb (const gchar *request) { gchar *r; + + if (!request) + { + app->quit (); + return; + } r = g_strdup_printf ("GREETER %s AUTHENTICATE", getenv ("DISPLAY")); if (strcmp (request, r) == 0) @@ -121,7 +128,7 @@ main(int argc, char *argv[]) status_connect (request_cb); - QCoreApplication app(argc, argv); + app = new QCoreApplication (argc, argv); signal (SIGINT, signal_cb); signal (SIGTERM, signal_cb); @@ -156,5 +163,5 @@ main(int argc, char *argv[]) if (greeter->lockHint()) status_notify ("GREETER %s LOCK-HINT", getenv ("DISPLAY")); - return app.exec(); + return app->exec(); } diff --git a/tests/src/test-script-hook.c b/tests/src/test-script-hook.c index e3212005..cf724237 100644 --- a/tests/src/test-script-hook.c +++ b/tests/src/test-script-hook.c @@ -6,11 +6,6 @@ static GKeyFile *config; -static void -request_cb (const gchar *message) -{ -} - int main (int argc, char **argv) { @@ -18,7 +13,7 @@ main (int argc, char **argv) g_type_init (); #endif - status_connect (request_cb); + status_connect (NULL); 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); diff --git a/tests/src/test-session.c b/tests/src/test-session.c index c0d20ba4..49f3f5c0 100644 --- a/tests/src/test-session.c +++ b/tests/src/test-session.c @@ -13,6 +13,8 @@ #include "status.h" +static GMainLoop *loop; + static GString *open_fds; static GKeyFile *config; @@ -30,6 +32,12 @@ static void request_cb (const gchar *request) { gchar *r; + + if (!request) + { + g_main_loop_quit (loop); + return; + } r = g_strdup_printf ("SESSION %s LOGOUT", getenv ("DISPLAY")); if (strcmp (request, r) == 0) @@ -148,7 +156,6 @@ request_cb (const gchar *request) int main (int argc, char **argv) { - GMainLoop *loop; int fd, open_max; open_fds = g_string_new (""); diff --git a/tests/src/vnc-client.c b/tests/src/vnc-client.c index 8577b39d..f4f10444 100644 --- a/tests/src/vnc-client.c +++ b/tests/src/vnc-client.c @@ -9,11 +9,6 @@ static GKeyFile *config; -static void -request_cb (const gchar *message) -{ -} - int main (int argc, char **argv) { @@ -32,7 +27,7 @@ main (int argc, char **argv) g_type_init (); #endif - status_connect (request_cb); + status_connect (NULL); status_notify ("VNC-CLIENT START"); |