[libsoup/wip/smcv/error-log] Record Apache error log for unit tests and show it during teardown




commit 67fb9db2d81c8b81aab5da6be081d8cc6712ef62
Author: Simon McVittie <smcv debian org>
Date:   Mon Dec 27 18:10:25 2021 +0000

    Record Apache error log for unit tests and show it during teardown
    
    This helps to diagnose problems with the Apache-based tests.

 tests/test-utils.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/tests/test-utils.c b/tests/test-utils.c
index c2a59dab..04423d1a 100644
--- a/tests/test-utils.c
+++ b/tests/test-utils.c
@@ -165,7 +165,7 @@ static gboolean
 apache_cmd (const char *cmd)
 {
        GPtrArray *argv;
-       char *cwd, *pid_file;
+       char *cwd, *pid_file, *error_log;
 #ifdef HAVE_APACHE_2_4
        char *default_runtime_dir;
 #endif
@@ -184,6 +184,7 @@ apache_cmd (const char *cmd)
        default_runtime_dir = g_strdup_printf ("DefaultRuntimeDir %s", cwd);
 #endif
        pid_file = g_strdup_printf ("PidFile %s/httpd.pid", cwd);
+       error_log = g_strdup_printf ("ErrorLog %s/error.log", cwd);
 
        argv = g_ptr_array_new ();
        g_ptr_array_add (argv, APACHE_HTTPD);
@@ -196,6 +197,8 @@ apache_cmd (const char *cmd)
        g_ptr_array_add (argv, "-c");
        g_ptr_array_add (argv, default_runtime_dir);
 #endif
+       g_ptr_array_add (argv, "-c");
+       g_ptr_array_add (argv, error_log);
        g_ptr_array_add (argv, "-c");
        g_ptr_array_add (argv, pid_file);
 
@@ -222,6 +225,7 @@ apache_cmd (const char *cmd)
 
        g_free (cwd);
        g_free (pid_file);
+       g_free (error_log);
 #ifdef HAVE_APACHE_2_4
        g_free (default_runtime_dir);
 #endif
@@ -269,6 +273,11 @@ apache_cleanup (void)
                        g_usleep (100);
        }
 
+       if (g_file_get_contents ("error.log", &contents, NULL, NULL)) {
+               g_test_message ("error.log contents:\n%s", contents);
+               g_free (contents);
+       }
+
        g_clear_pointer (&server_root, g_free);
 }
 


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