diff --git a/tests/qemu/boot-analysis-utils.c b/tests/qemu/boot-analysis-utils.c index e885f3b11..bcd470e44 100644 --- a/tests/qemu/boot-analysis-utils.c +++ b/tests/qemu/boot-analysis-utils.c @@ -24,6 +24,8 @@ #include #include +#include "ignore-value.h" + #include "guestfs.h" #include "guestfs-internal-frontend.h" @@ -45,3 +47,38 @@ timespec_diff (const struct timespec *x, const struct timespec *y) nsec += y->tv_nsec - x->tv_nsec; return nsec; } + +void +test_info (guestfs_h *g, int nr_test_passes) +{ + const char *qemu = guestfs_get_hv (g); + CLEANUP_FREE char *cmd = NULL; + + /* Related to the test program. */ + printf ("test version: %s %s\n", PACKAGE_NAME, PACKAGE_VERSION_FULL); + printf (" test passes: %d\n", nr_test_passes); + + /* Related to the host. */ + printf ("host version: "); + fflush (stdout); + ignore_value (system ("uname -a")); + printf (" host CPU: "); + fflush (stdout); + ignore_value (system ("perl -n -e 'if (/^model name.*: (.*)/) { print \"$1\\n\"; exit }' /proc/cpuinfo")); + + /* Related to qemu. */ + printf (" backend: %s\n", guestfs_get_backend (g)); + printf (" qemu: %s\n", qemu); + printf ("qemu version: "); + fflush (stdout); + if (asprintf (&cmd, "%s -version", qemu) == -1) + error (EXIT_FAILURE, errno, "asprintf"); + ignore_value (system (cmd)); + printf (" smp: %d\n", guestfs_get_smp (g)); + printf (" memsize: %d\n", guestfs_get_memsize (g)); + + /* Related to the guest kernel. Be nice to get the guest + * kernel version here somehow (XXX). + */ + printf (" append: %s\n", guestfs_get_append (g) ? : ""); +} diff --git a/tests/qemu/boot-analysis-utils.h b/tests/qemu/boot-analysis-utils.h index 83fc49415..95e4f06bd 100644 --- a/tests/qemu/boot-analysis-utils.h +++ b/tests/qemu/boot-analysis-utils.h @@ -27,4 +27,10 @@ extern void get_time (struct timespec *ts); /* Computes Y - X, returning nanoseconds. */ extern int64_t timespec_diff (const struct timespec *x, const struct timespec *y); +/* Display host machine and test parameters (to stdout). 'g' should + * be an open libguestfs handle. It is used for reading hv, memsize + * etc. and is not modified. + */ +extern void test_info (guestfs_h *g, int nr_test_passes); + #endif /* GUESTFS_BOOT_ANALYSIS_UTILS_H_ */ diff --git a/tests/qemu/boot-analysis.c b/tests/qemu/boot-analysis.c index 9ab228a65..f4c1d6c4d 100644 --- a/tests/qemu/boot-analysis.c +++ b/tests/qemu/boot-analysis.c @@ -73,8 +73,6 @@ #include #include -#include "ignore-value.h" - #include "guestfs.h" #include "guestfs-internal-frontend.h" @@ -105,7 +103,6 @@ static void check_pass_data (void); static void dump_pass_data (void); static void analyze_timeline (void); static void dump_timeline (void); -static void print_info (void); static void print_analysis (void); static void print_longest_to_shortest (void); static void free_pass_data (void); @@ -254,7 +251,9 @@ run_test (void) dump_timeline (); printf ("\n"); - print_info (); + g = create_handle (); + test_info (g, NR_TEST_PASSES); + guestfs_close (g); printf ("\n"); print_analysis (); printf ("\n"); @@ -823,37 +822,6 @@ dump_timeline (void) } } -/* Print some information that will allow us to determine the test - * system when reviewing the results in future. - */ -static void -print_info (void) -{ - size_t i; - - printf ("%s %s\n", PACKAGE_NAME, PACKAGE_VERSION_FULL); - - printf ("Host:\n"); - ignore_value (system ("uname -a")); - ignore_value (system ("grep '^model name' /proc/cpuinfo | head -1")); - - /* We can dig some information about qemu and the appliance out of - * the events. - */ - printf ("Appliance:\n"); - assert (NR_TEST_PASSES > 0); - for (i = 0; i < pass_data[0].nr_events; ++i) { - const char *message = pass_data[0].events[i].message; - if (strstr (message, "qemu version") || - (strstr (message, "SeaBIOS") && strstr (message, "version")) || - strstr (message, "Linux version") || - (strstr (message, "supermin") && strstr (message, "starting up"))) { - print_escaped_string (message); - putchar ('\n'); - } - } -} - static void print_activity (struct activity *activity) { diff --git a/tests/qemu/boot-benchmark.c b/tests/qemu/boot-benchmark.c index 2a6a03869..0508ee92a 100644 --- a/tests/qemu/boot-benchmark.c +++ b/tests/qemu/boot-benchmark.c @@ -179,13 +179,8 @@ run_test (void) /* Print the test parameters. */ printf ("\n"); - printf (" passes %d\n", NR_TEST_PASSES); g = create_handle (); - printf (" append %s\n", guestfs_get_append (g) ? : ""); - printf ("backend %s\n", guestfs_get_backend (g)); - printf (" hv %s\n", guestfs_get_hv (g)); - printf ("memsize %d\n", guestfs_get_memsize (g)); - printf (" smp %d\n", guestfs_get_smp (g)); + test_info (g, NR_TEST_PASSES); guestfs_close (g); /* Print the result. */