From 281b155800f2e62b994e59bef418ca200da8e93a Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 14 Sep 2012 11:34:26 +0100 Subject: [PATCH] test-tool: Print more environment variables. This prints LIBVIRT_*, LIBVIRTD_*, LD_* and PATH, since these are all useful for debugging and could affect libguestfs in some way. --- test-tool/test-tool.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/test-tool/test-tool.c b/test-tool/test-tool.c index ca31c09f0..ba574ecf8 100644 --- a/test-tool/test-tool.c +++ b/test-tool/test-tool.c @@ -42,11 +42,11 @@ //#define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0) //#define STRNEQ(a,b) (strcmp((a),(b)) != 0) //#define STRCASENEQ(a,b) (strcasecmp((a),(b)) != 0) -#define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0) +//#define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0) //#define STRCASEEQLEN(a,b,n) (strncasecmp((a),(b),(n)) == 0) //#define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0) //#define STRCASENEQLEN(a,b,n) (strncasecmp((a),(b),(n)) != 0) -//#define STRPREFIX(a,b) (strncmp((a),(b),strlen((b))) == 0) +#define STRPREFIX(a,b) (strncmp((a),(b),strlen((b))) == 0) #ifndef P_tmpdir #define P_tmpdir "/tmp" @@ -169,13 +169,24 @@ main (int argc, char *argv[]) printf ("===== Test starts here =====\n"); /* Print out any environment variables which may relate to this test. */ - for (i = 0; environ[i] != NULL; ++i) - if (STREQLEN (environ[i], "LIBGUESTFS_", 11)) + for (i = 0; environ[i] != NULL; ++i) { + if (STRPREFIX (environ[i], "LIBGUESTFS_")) printf ("%s\n", environ[i]); - for (i = 0; environ[i] != NULL; ++i) - if (STREQLEN (environ[i], "FEBOOTSTRAP_", 12)) + if (STRPREFIX (environ[i], "FEBOOTSTRAP_")) printf ("%s\n", environ[i]); - printf ("TMPDIR=%s\n", getenv ("TMPDIR") ? : "(not set)"); + if (STRPREFIX (environ[i], "LIBVIRT_")) + printf ("%s\n", environ[i]); + if (STRPREFIX (environ[i], "LIBVIRTD_")) + printf ("%s\n", environ[i]); + if (STRPREFIX (environ[i], "LD_")) + printf ("%s\n", environ[i]); + } + p = getenv ("TMPDIR"); + if (p) + printf ("TMPDIR=%s\n", p); + p = getenv ("PATH"); + if (p) + printf ("PATH=%s\n", p); /* Configure the handle. */ if (guestfs_add_drive_opts (g, tmpf,