mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
tests/qemu: Standardize test info printed by boot-* tests.
It now looks like: test version: libguestfs 1.33.16 test passes: 5 host version: Linux moo 4.4.4-301.fc23.x86_64 #1 SMP Fri Mar 4 17:42:42 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux host CPU: Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz backend: direct qemu: /home/rjones/d/qemu/x86_64-softmmu/qemu-system-x86_64 qemu version: QEMU emulator version 2.5.90, Copyright (c) 2003-2008 Fabrice Bellard smp: 1 memsize: 500 append: guestfs_boot_analysis=1 ignore_loglevel initcall_debug
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
#include <error.h>
|
||||
#include <errno.h>
|
||||
|
||||
#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) ? : "");
|
||||
}
|
||||
|
||||
@@ -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_ */
|
||||
|
||||
@@ -73,8 +73,6 @@
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
#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)
|
||||
{
|
||||
|
||||
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user