~robert-ancell/lightdm/enable-tests

« back to all changes in this revision

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

  • Committer: Robert Ancell
  • Date: 2014-02-27 02:52:26 UTC
  • mfrom: (1754.1.153 trunk)
  • Revision ID: robert.ancell@canonical.com-20140227025226-ehwun36yxpjbuha7
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
122
122
} StatusClient;
123
123
static GList *status_clients = NULL;
124
124
 
125
 
static void run_lightdm (void);
 
125
static void ready (void);
126
126
static void quit (int status);
127
127
static void check_status (const gchar *status);
128
128
static AccountsUser *get_accounts_user_by_uid (guint uid);
403
403
        g_hash_table_insert (params, param_name, param_value);
404
404
    }
405
405
 
406
 
    if (strcmp (name, "WAIT") == 0)
 
406
    if (strcmp (name, "START-DAEMON") == 0)
 
407
    {
 
408
        GString *command_line;
 
409
        gchar **lightdm_argv;
 
410
        pid_t lightdm_pid;
 
411
        GError *error = NULL;
 
412
 
 
413
        command_line = g_string_new ("lightdm");
 
414
        if (getenv ("DEBUG"))
 
415
            g_string_append (command_line, " --debug");
 
416
        g_string_append_printf (command_line, " --cache-dir %s/cache", temp_dir);
 
417
 
 
418
        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",
 
419
                                               g_getenv ("PATH"), g_getenv ("LD_PRELOAD"), g_getenv ("LD_LIBRARY_PATH"), g_getenv ("LIGHTDM_TEST_ROOT"), g_getenv ("DBUS_SESSION_BUS_ADDRESS"),
 
420
                                               command_line->str);
 
421
 
 
422
        if (!g_shell_parse_argv (command_line->str, NULL, &lightdm_argv, &error))
 
423
        {
 
424
            g_warning ("Error parsing command line: %s", error->message);
 
425
            quit (EXIT_FAILURE);
 
426
        }
 
427
        g_clear_error (&error);
 
428
 
 
429
        if (!g_spawn_async (NULL, lightdm_argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, NULL, NULL, &lightdm_pid, &error))
 
430
        {
 
431
            g_warning ("Error launching LightDM: %s", error->message);
 
432
            quit (EXIT_FAILURE);
 
433
        }
 
434
        g_clear_error (&error);
 
435
        lightdm_process = watch_process (lightdm_pid);
 
436
 
 
437
        check_status ("RUNNER DAEMON-START");
 
438
    }
 
439
    else if (strcmp (name, "WAIT") == 0)
407
440
    {
408
441
        /* Use a main loop so that our DBus functions are still responsive */
409
442
        GMainLoop *loop = g_main_loop_new (NULL, FALSE);
798
831
    line->done = TRUE;
799
832
 
800
833
    /* Restart timeout */
801
 
    g_source_remove (status_timeout);
 
834
    if (status_timeout)
 
835
        g_source_remove (status_timeout);
802
836
    status_timeout = g_timeout_add (status_timeout_ms, status_timeout_cb, NULL);
803
837
 
804
838
    run_commands ();
969
1003
 
970
1004
    service_count--;
971
1005
    if (service_count == 0)
972
 
        run_lightdm ();
 
1006
        ready ();
973
1007
}
974
1008
 
975
1009
static void
1205
1239
 
1206
1240
    service_count--;
1207
1241
    if (service_count == 0)
1208
 
        run_lightdm ();
 
1242
        ready ();
1209
1243
}
1210
1244
 
1211
1245
static void
1460
1494
 
1461
1495
    service_count--;
1462
1496
    if (service_count == 0)
1463
 
        run_lightdm ();
 
1497
        ready ();
1464
1498
}
1465
1499
 
1466
1500
static void
1862
1896
 
1863
1897
    service_count--;
1864
1898
    if (service_count == 0)
1865
 
        run_lightdm ();
 
1899
        ready ();
1866
1900
}
1867
1901
 
1868
1902
static void
1880
1914
}
1881
1915
 
1882
1916
static void
1883
 
run_lightdm (void)
 
1917
ready (void)
1884
1918
{
1885
 
    GString *command_line;
1886
 
    gchar **lightdm_argv;
1887
 
    pid_t lightdm_pid;
1888
 
    GError *error = NULL;
1889
 
 
1890
1919
    run_commands ();
1891
 
 
1892
 
    status_timeout = g_timeout_add (status_timeout_ms, status_timeout_cb, NULL);
1893
 
 
1894
 
    command_line = g_string_new ("lightdm");
1895
 
    if (getenv ("DEBUG"))
1896
 
        g_string_append (command_line, " --debug");
1897
 
    g_string_append_printf (command_line, " --cache-dir %s/cache", temp_dir);
1898
 
 
1899
 
    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",
1900
 
                                           g_getenv ("PATH"), g_getenv ("LD_PRELOAD"), g_getenv ("LD_LIBRARY_PATH"), g_getenv ("LIGHTDM_TEST_ROOT"), g_getenv ("DBUS_SESSION_BUS_ADDRESS"),
1901
 
                                           command_line->str);
1902
 
 
1903
 
    if (!g_shell_parse_argv (command_line->str, NULL, &lightdm_argv, &error))
1904
 
    {
1905
 
        g_warning ("Error parsing command line: %s", error->message);
1906
 
        quit (EXIT_FAILURE);
1907
 
    }
1908
 
    g_clear_error (&error);
1909
 
 
1910
 
    if (!g_spawn_async (NULL, lightdm_argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, NULL, NULL, &lightdm_pid, &error))
1911
 
    {
1912
 
        g_warning ("Error launching LightDM: %s", error->message);
1913
 
        quit (EXIT_FAILURE);
1914
 
    }
1915
 
    g_clear_error (&error);
1916
 
    lightdm_process = watch_process (lightdm_pid);
1917
 
 
1918
 
    check_status ("RUNNER DAEMON-START");
1919
1920
}
1920
1921
 
1921
1922
static gboolean