From 67fb9db2d81c8b81aab5da6be081d8cc6712ef62 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 27 Dec 2021 18:10:25 +0000 Subject: 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); } -- cgit v1.2.1