This is a catch-all mode for turning off daemon features which
interfere with our testing of the daemon.
---
daemon/daemon.h | 2 ++
daemon/guestfsd.c | 17 ++++++++++++++---
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 136e9a9..e977095 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -47,6 +47,8 @@ extern int enable_network;
extern int autosync_umount;
+extern int test_mode;
+
extern const char *sysroot;
extern size_t sysroot_len;
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index eef24d5..8285d27 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -120,6 +120,9 @@ size_t sysroot_len = 8;
/* If set (the default), do 'umount-all' when performing autosync. */
int autosync_umount = 1;
+/* If set, we are testing the daemon as part of the libguestfs tests. */
+int test_mode = 0;
+
/* Not used explicitly, but required by the gnulib 'error' module. */
const char *program_name = "guestfsd";
@@ -136,9 +139,10 @@ usage (void)
int
main (int argc, char *argv[])
{
- static const char *options = "rv?";
+ static const char *options = "rtv?";
static const struct option long_options[] = {
{ "help", 0, 0, '?' },
+ { "test", 0, 0, 't' },
{ "verbose", 0, 0, 'v' },
{ 0, 0, 0, 0 }
};
@@ -191,6 +195,11 @@ main (int argc, char *argv[])
autosync_umount = 0;
break;
+ /* Undocumented --test option used for testing guestfsd. */
+ case 't':
+ test_mode = 1;
+ break;
+
case 'v':
verbose = 1;
break;
@@ -244,7 +253,8 @@ main (int argc, char *argv[])
* environment is essentially empty.
*
https://bugzilla.redhat.com/show_bug.cgi?id=502074#c5
*/
- setenv ("PATH", "/sbin:/usr/sbin:/bin:/usr/bin", 1);
+ if (!test_mode)
+ setenv ("PATH", "/sbin:/usr/sbin:/bin:/usr/bin", 1);
setenv ("SHELL", "/bin/sh", 1);
setenv ("LC_ALL", "C", 1);
setenv ("TERM", "dumb", 1);
@@ -263,7 +273,8 @@ main (int argc, char *argv[])
/* Make a private copy of /etc/lvm so we can change the config (see
* daemon/lvm-filter.c).
*/
- copy_lvm ();
+ if (!test_mode)
+ copy_lvm ();
/* Connect to virtio-serial channel. */
char *channel, *p;
--
2.3.1