[gnome-desktop-testing] runner: If stdout is journal, set up children for journal too



commit 074b6b0991bc4cb5aeef1eb21de409db4809c083
Author: Colin Walters <walters verbum org>
Date:   Wed Jul 24 18:46:03 2013 -0400

    runner: If stdout is journal, set up children for journal too
    
    We really want to split up the stdout of each test into its own
    journal identifier; otherwise we get a terrible mess.
    
    Long term, we should probably autogenerate systemd units for the
    tests, but this is a major win for now.

 src/gnome-desktop-testing-runner.c |   30 ++++++++++++++++++++++++++++++
 src/libgsystem                     |    2 +-
 2 files changed, 31 insertions(+), 1 deletions(-)
---
diff --git a/src/gnome-desktop-testing-runner.c b/src/gnome-desktop-testing-runner.c
index bf363aa..8a396b2 100755
--- a/src/gnome-desktop-testing-runner.c
+++ b/src/gnome-desktop-testing-runner.c
@@ -24,9 +24,14 @@
 #include "gsystem-local-alloc.h"
 
 #include <string.h>
+#include <errno.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 
+#ifdef ENABLE_SYSTEMD_JOURNAL
+#include <systemd/sd-journal.h>
+#endif
+
 #define TEST_SKIP_ECODE 77
 #define TEST_RUNNING_STATUS_MSGID   "ed6199045dd38bb5321e551d9578f3d9"
 #define TESTS_COMPLETE_MSGID   "4d013788dd704743b826436c951e551d"
@@ -314,6 +319,27 @@ on_test_exited (GObject       *obj,
     g_task_return_boolean (task, TRUE);
 }
 
+static void
+setup_test_child (gpointer user_data)
+{
+#ifdef ENABLE_SYSTEMD_JOURNAL
+  Test *test = user_data;
+  int journalfd;
+  
+  journalfd = sd_journal_stream_fd (test->name, LOG_INFO, 0);
+  if (journalfd >= 0)
+    {
+      int ret;
+      do
+        ret = dup2 (journalfd, 1);
+      while (ret == -1 && errno == EINTR);
+      do
+        ret = dup2 (journalfd, 2);
+      while (ret == -1 && errno == EINTR);
+    }
+#endif
+}
+
 static gboolean
 run_test_async (Test                *test,
                 GCancellable        *cancellable,
@@ -376,6 +402,10 @@ run_test_async (Test                *test,
 
   proc_context = gs_subprocess_context_new (test->argv);
   gs_subprocess_context_set_cwd (proc_context, test_tmpdir);
+#ifdef ENABLE_SYSTEMD_JOURNAL
+  if (gs_stdout_is_journal ())
+    gs_subprocess_context_set_child_setup (proc_context, setup_test_child, test);
+#endif
 
   proc = gs_subprocess_new (proc_context, cancellable, error);
   if (!proc)
diff --git a/src/libgsystem b/src/libgsystem
index 52f38c8..c541759 160000
--- a/src/libgsystem
+++ b/src/libgsystem
@@ -1 +1 @@
-Subproject commit 52f38c8d9bf9f4ba1ac3dea4fd1a5c89a7362191
+Subproject commit c541759c92667fdf50975e4919b590b9091d2c65


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]