static void test_dynamic_globalprop(void)
{
    g_test_trap_subprocess("/qdev/properties/dynamic/global/subprocess", 0, 0);
    g_test_trap_assert_passed();
    g_test_trap_assert_stderr_unmatched("*prop1*");
    g_test_trap_assert_stderr_unmatched("*prop2*");
    g_test_trap_assert_stderr("*Warning: global dynamic-prop-type-bad.prop3 has invalid class name\n*");
    g_test_trap_assert_stderr_unmatched("*prop4*");
    g_test_trap_assert_stderr("*Warning: global nohotplug-type.prop5=105 not used\n*");
    g_test_trap_assert_stderr("*Warning: global nondevice-type.prop6 has invalid class name\n*");
    g_test_trap_assert_stdout("");
}
Beispiel #2
0
static void
test_syslog_normal (Fixture *f,
    gconstpointer data)
{
  if (g_test_subprocess ())
    {
      _dbus_init_system_log ("test-syslog",
          DBUS_LOG_FLAGS_SYSTEM_LOG | DBUS_LOG_FLAGS_STDERR);
      _dbus_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "%d", 42);
      _dbus_log (DBUS_SYSTEM_LOG_WARNING, MESSAGE "%d", 45);
      _dbus_log (DBUS_SYSTEM_LOG_SECURITY, MESSAGE "%d", 666);
      _dbus_log (DBUS_SYSTEM_LOG_ERROR, MESSAGE "%d", 23);

      _dbus_init_system_log ("test-syslog-stderr", DBUS_LOG_FLAGS_STDERR);
      _dbus_log (DBUS_SYSTEM_LOG_INFO,
          MESSAGE "this should not appear in the syslog");
      _dbus_init_system_log ("test-syslog-both",
          DBUS_LOG_FLAGS_SYSTEM_LOG | DBUS_LOG_FLAGS_STDERR);
      _dbus_log (DBUS_SYSTEM_LOG_INFO,
          MESSAGE "this should appear in the syslog and on stderr");
      _dbus_init_system_log ("test-syslog-only", DBUS_LOG_FLAGS_SYSTEM_LOG);
      _dbus_log (DBUS_SYSTEM_LOG_INFO,
          MESSAGE "this should appear in the syslog only");

      exit (0);
    }

  g_test_trap_subprocess (NULL, 0, 0);
  g_test_trap_assert_passed ();
  g_test_trap_assert_stderr ("*" MESSAGE "42\n"
                             "*" MESSAGE "45\n"
                             "*" MESSAGE "666\n"
                             "*" MESSAGE "23\n"
                             "*test-syslog-stderr*" MESSAGE
                               "this should not appear in the syslog\n"
                             "*test-syslog-both*" MESSAGE
                               "this should appear in the syslog and "
                               "on stderr\n");
  g_test_trap_assert_stderr_unmatched ("*this should appear in the syslog "
                                       "only*");
  g_test_trap_assert_stderr_unmatched ("*test-syslog-only*");
}
Beispiel #3
0
static void
test_schema (gpointer data)
{
  SchemaTest *test = (SchemaTest *) data;
  gchar *child_name;

  child_name = g_strdup_printf ("/gschema/%s%s/subprocess/do_compile", test->name, test->opt ? "/opt" : "");
  g_test_trap_subprocess (child_name, 0, 0);
  g_free (child_name);

  if (test->err)
    {
      g_test_trap_assert_failed ();
      g_test_trap_assert_stderr_unmatched ("*CRITICAL*");
      g_test_trap_assert_stderr_unmatched ("*WARNING*");
      g_test_trap_assert_stderr (test->err);
    }
  else
    g_test_trap_assert_passed();
}
Beispiel #4
0
static void
test_x11_autolaunch (void)
{
  if (g_test_subprocess ())
    {
      g_unsetenv ("DISPLAY");
      g_unsetenv ("DBUS_SESSION_BUS_ADDRESS");
      g_unsetenv ("XDG_RUNTIME_DIR");
      set_up_mock_dbus_launch ();

      print_address ();

      tear_down_mock_dbus_launch ();
      return;
    }

  g_test_trap_subprocess (NULL, 0, 0);
  g_test_trap_assert_stderr_unmatched ("?*");
  g_test_trap_assert_stdout ("hello:this=address-is-from-the,mock=dbus-launch\n");
  g_test_trap_assert_passed ();
}
Beispiel #5
0
static void
test_xdg_runtime (void)
{
  if (g_test_subprocess ())
    {
      g_unsetenv ("DISPLAY");
      g_unsetenv ("DBUS_SESSION_BUS_ADDRESS");
      set_up_mock_xdg_runtime_dir ();
      set_up_mock_dbus_launch ();

      print_address ();

      tear_down_mock_dbus_launch ();
      tear_down_mock_xdg_runtime_dir ();
      return;
    }

  g_test_trap_subprocess (NULL, 0, 0);
  g_test_trap_assert_stderr_unmatched ("?*");
  g_test_trap_assert_stdout ("unix:path=/tmp/gdbus%2Cunix%2Ctest.*/bus\n");
  g_test_trap_assert_passed ();
}
Beispiel #6
0
static void
test_LSDebugLogIncoming(TestData *fixture, gconstpointer user_data)
{
    const char *expected_stdout = "RX: where token <<0>> sender: com.name.service sender_unique: com.name.service.0\n";
    const char *expected_verbose_stdout = "RX: where token <<0>> sender: com.name.service sender_unique: com.name.service.0 payload: {}\n";

    setenv("G_MESSAGES_DEBUG", "all", 1);

    PmLogSetContextLevel(PmLogGetLibContext(), kPmLogLevel_Debug);

    if (g_test_trap_fork(0, G_TEST_TRAP_SILENCE_STDERR))
    {
        LSDebugLogIncoming("where", GINT_TO_POINTER(1));
        exit(0);
    }
    g_test_trap_assert_stderr_unmatched(expected_stdout);

    // enable DEBUG_TRACING
    _ls_debug_tracing = 1;

    if (g_test_trap_fork(0, G_TEST_TRAP_SILENCE_STDERR))
    {
        LSDebugLogIncoming("where", GINT_TO_POINTER(1));
        exit(0);
    }
    g_test_trap_assert_stderr(expected_stdout);

    // enable DEBUG_VERBOSE
    _ls_debug_tracing = 2;

    if (g_test_trap_fork(0, G_TEST_TRAP_SILENCE_STDERR))
    {
        LSDebugLogIncoming("where", GINT_TO_POINTER(1));
        exit(0);
    }
    g_test_trap_assert_stderr(expected_verbose_stdout);

    _ls_debug_tracing = 0;
}
static void
test_timer_source_set_interval_seconds()
{
    // 2s interval
    GTimerSource *source = g_timer_source_new_seconds(2);

    // 1s interval
    g_timer_source_set_interval_seconds(source, 1, true);

    g_assert_cmpint(g_timer_source_get_interval_ms(source), ==, 1000);

    // no main loop, no main context, cannot wakeup context, expect warning
    if (g_test_trap_fork(0, G_TEST_TRAP_SILENCE_STDERR))
    {
        g_timer_source_set_interval_seconds(source, 2, false);
        exit(0);
    }
    g_test_trap_assert_stderr("*Cannot get context for timer_source*");

    // valid main loop/context, source attached, expect no warning
    if (g_test_trap_fork(0, G_TEST_TRAP_SILENCE_STDERR))
    {
        GMainLoop *main_loop = g_main_loop_new(NULL, false);

        g_source_attach ((GSource*)source, NULL);

        g_timer_source_set_interval_seconds(source, 1, false);

        g_main_loop_unref(main_loop);
        g_source_unref((GSource*)source);

        exit(0);
    }
    g_test_trap_assert_stderr_unmatched("*Cannot get context for timer_source*");

    g_source_unref((GSource*)source);
}