~robert-ancell/lightdm/private-mir-connection-merge

« back to all changes in this revision

Viewing changes to tests/src/test-runner.c

  • Committer: Robert Ancell
  • Date: 2013-07-23 02:24:45 UTC
  • mfrom: (1723 trunk)
  • mto: This revision was merged to the branch mainline in revision 1741.
  • Revision ID: robert.ancell@canonical.com-20130723022445-gpaq8vtkp4hods7r
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
395
395
    {
396
396
        sleep (1);
397
397
    }
 
398
    else if (strcmp (name, "LIST-SEATS") == 0)
 
399
    {
 
400
        GVariant *result, *value;
 
401
        GString *status;
 
402
        GVariantIter *iter;
 
403
        const gchar *path;
 
404
        int i = 0;
 
405
 
 
406
        result = g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
 
407
                                              "org.freedesktop.DisplayManager",
 
408
                                              "/org/freedesktop/DisplayManager",
 
409
                                              "org.freedesktop.DBus.Properties",
 
410
                                              "Get",
 
411
                                              g_variant_new ("(ss)", "org.freedesktop.DisplayManager", "Seats"),
 
412
                                              G_VARIANT_TYPE ("(v)"),
 
413
                                              G_DBUS_CALL_FLAGS_NONE,
 
414
                                              1000,
 
415
                                              NULL,
 
416
                                              NULL);
 
417
 
 
418
        status = g_string_new ("RUNNER LIST-SEATS SEATS=");
 
419
        g_variant_get (result, "(v)", &value);
 
420
        g_variant_get (value, "ao", &iter);
 
421
        while (g_variant_iter_loop (iter, "&o", &path))
 
422
        {
 
423
            if (i != 0)
 
424
                g_string_append (status, ",");
 
425
            g_string_append (status, path);
 
426
            i++;
 
427
        }
 
428
        g_variant_unref (value);
 
429
        g_variant_unref (result);
 
430
 
 
431
        check_status (status->str);
 
432
        g_string_free (status, TRUE);
 
433
    }
 
434
    else if (strcmp (name, "LIST-SESSIONS") == 0)
 
435
    {
 
436
        GVariant *result, *value;
 
437
        GString *status;
 
438
        GVariantIter *iter;
 
439
        const gchar *path;
 
440
        int i = 0;
 
441
 
 
442
        result = g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
 
443
                                              "org.freedesktop.DisplayManager",
 
444
                                              "/org/freedesktop/DisplayManager",
 
445
                                              "org.freedesktop.DBus.Properties",
 
446
                                              "Get",
 
447
                                              g_variant_new ("(ss)", "org.freedesktop.DisplayManager", "Sessions"),
 
448
                                              G_VARIANT_TYPE ("(v)"),
 
449
                                              G_DBUS_CALL_FLAGS_NONE,
 
450
                                              1000,
 
451
                                              NULL,
 
452
                                              NULL);
 
453
 
 
454
        status = g_string_new ("RUNNER LIST-SESSIONS SESSIONS=");
 
455
        g_variant_get (result, "(v)", &value);
 
456
        g_variant_get (value, "ao", &iter);
 
457
        while (g_variant_iter_loop (iter, "&o", &path))
 
458
        {
 
459
            if (i != 0)
 
460
                g_string_append (status, ",");
 
461
            g_string_append (status, path);
 
462
            i++;
 
463
        }
 
464
        g_variant_unref (value);
 
465
        g_variant_unref (result);
 
466
 
 
467
        check_status (status->str);
 
468
        g_string_free (status, TRUE);
 
469
    }
398
470
    else if (strcmp (name, "SWITCH-TO-GREETER") == 0)
399
471
    {
400
472
        g_dbus_connection_call_sync (g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL),
544
616
            GError *error = NULL;
545
617
 
546
618
            length = strlen (command);
547
 
            g_socket_send (client->socket, (gchar *) &length, sizeof (length), NULL, &error);
548
 
            g_socket_send (client->socket, command, strlen (command), NULL, &error);
549
 
            if (error)
 
619
            if (g_socket_send (client->socket, (gchar *) &length, sizeof (length), NULL, &error) < 0 ||
 
620
                g_socket_send (client->socket, command, strlen (command), NULL, &error) < 0)
550
621
                g_printerr ("Failed to write to client socket: %s\n", error->message);
551
622
            g_clear_error (&error);
552
623
        }
808
879
}
809
880
 
810
881
static void
811
 
start_upower_daemon ()
 
882
start_upower_daemon (void)
812
883
{
813
884
    service_count++;
814
885
    g_bus_own_name (G_BUS_TYPE_SYSTEM,
1082
1153
                   error->message);
1083
1154
    g_clear_error (&error);
1084
1155
    if (!login1_session_info)
1085
 
        return;
 
1156
        return NULL;
1086
1157
 
1087
1158
    g_dbus_connection_register_object (connection,
1088
1159
                                       session->path,
1259
1330
}
1260
1331
 
1261
1332
static void
1262
 
start_login1_daemon ()
 
1333
start_login1_daemon (void)
1263
1334
{
1264
1335
    service_count++;
1265
1336
    g_bus_own_name (G_BUS_TYPE_SYSTEM,
1378
1449
        gchar **fields;
1379
1450
        guint uid;
1380
1451
        gchar *user_name, *real_name;
1381
 
        GList *link;
1382
1452
        AccountsUser *user = NULL;
1383
 
        GError *error = NULL;
1384
1453
 
1385
1454
        fields = g_strsplit (lines[i], ":", -1);
1386
1455
        if (fields == NULL || g_strv_length (fields) < 7)
1474
1543
    }
1475
1544
    else if (strcmp (method_name, "FindUserByName") == 0)
1476
1545
    {
1477
 
        GList *link;
1478
1546
        AccountsUser *user = NULL;
1479
1547
        gchar *user_name;
1480
1548
 
1660
1728
    if (getenv ("DEBUG"))
1661
1729
        g_string_append (command_line, " --debug");
1662
1730
    g_string_append_printf (command_line, " --cache-dir %s/cache", temp_dir);
1663
 
    g_string_append_printf (command_line, " --xsessions-dir=%s/usr/share/xsessions", temp_dir);
1664
 
    g_string_append_printf (command_line, " --remote-sessions-dir=%s/usr/share/remote-sessions", temp_dir);
1665
 
    g_string_append_printf (command_line, " --xgreeters-dir=%s/usr/share/xgreeters", temp_dir);
1666
1731
 
1667
1732
    test_runner_command = g_strdup_printf ("PATH=%s LD_PRELOAD=%s LD_LIBRARY_PATH=%s LIGHTDM_TEST_ROOT=%s DBUS_SESSION_BUS_ADDRESS=%s %s\n",
1668
1733
                                           g_getenv ("PATH"), g_getenv ("LD_PRELOAD"), g_getenv ("LD_LIBRARY_PATH"), g_getenv ("LIGHTDM_TEST_ROOT"), g_getenv ("DBUS_SESSION_BUS_ADDRESS"),
1820
1885
    /* Set up a skeleton file system */
1821
1886
    g_mkdir_with_parents (g_strdup_printf ("%s/etc", temp_dir), 0755);
1822
1887
    g_mkdir_with_parents (g_strdup_printf ("%s/usr/share", temp_dir), 0755);
1823
 
    g_mkdir_with_parents (g_strdup_printf ("%s/usr/share/xsessions", temp_dir), 0755);
1824
 
    g_mkdir_with_parents (g_strdup_printf ("%s/usr/share/remote-sessions", temp_dir), 0755);
1825
 
    g_mkdir_with_parents (g_strdup_printf ("%s/usr/share/xgreeters", temp_dir), 0755);
 
1888
    g_mkdir_with_parents (g_strdup_printf ("%s/usr/share/lightdm/sessions", temp_dir), 0755);
 
1889
    g_mkdir_with_parents (g_strdup_printf ("%s/usr/share/lightdm/remote-sessions", temp_dir), 0755);
 
1890
    g_mkdir_with_parents (g_strdup_printf ("%s/usr/share/lightdm/greeters", temp_dir), 0755);
1826
1891
    g_mkdir_with_parents (g_strdup_printf ("%s/tmp", temp_dir), 0755);
1827
1892
    g_mkdir_with_parents (g_strdup_printf ("%s/var/run", temp_dir), 0755);
1828
1893
    g_mkdir_with_parents (g_strdup_printf ("%s/var/log", temp_dir), 0755);
1852
1917
        perror ("Failed to copy configuration");
1853
1918
 
1854
1919
    /* Copy over the greeter files */
1855
 
    if (system (g_strdup_printf ("cp %s/xsessions/* %s/usr/share/xsessions", DATADIR, temp_dir)))
1856
 
        perror ("Failed to copy xsessions");
1857
 
    if (system (g_strdup_printf ("cp %s/remote-sessions/* %s/usr/share/remote-sessions", DATADIR, temp_dir)))
 
1920
    if (system (g_strdup_printf ("cp %s/sessions/* %s/usr/share/lightdm/sessions", DATADIR, temp_dir)))
 
1921
        perror ("Failed to copy sessions");
 
1922
    if (system (g_strdup_printf ("cp %s/remote-sessions/* %s/usr/share/lightdm/remote-sessions", DATADIR, temp_dir)))
1858
1923
        perror ("Failed to copy remote sessions");
1859
 
    if (system (g_strdup_printf ("cp %s/xgreeters/* %s/usr/share/xgreeters", DATADIR, temp_dir)))
1860
 
        perror ("Failed to copy xgreeters");
 
1924
    if (system (g_strdup_printf ("cp %s/greeters/* %s/usr/share/lightdm/greeters", DATADIR, temp_dir)))
 
1925
        perror ("Failed to copy greeters");
1861
1926
 
1862
1927
    /* Set up the default greeter */
1863
 
    path = g_build_filename (temp_dir, "usr", "share", "xgreeters", "default.desktop", NULL);
 
1928
    path = g_build_filename (temp_dir, "usr", "share", "lightdm", "greeters", "default.desktop", NULL);
1864
1929
    greeter = g_strdup_printf ("%s.desktop", argv[2]);
1865
1930
    if (symlink (greeter, path) < 0)
1866
1931
    {