aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sos/sosreport.py19
-rw-r--r--tests/utilities_tests.py4
2 files changed, 22 insertions, 1 deletions
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 580b5bd7..d9abcb8d 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -540,6 +540,21 @@ class SoSOptions(object):
self._sysroot = value
@property
+ def chroot(self):
+ if self._options is not None:
+ return self._options.chroot
+ return self._chroot
+
+ @chroot.setter
+ def chroot(self, value):
+ self._check_options_initialized()
+ if value not in ["auto", "always", "never"]:
+ msg = "SoSOptions.chroot '%s' is not a valid chroot mode: "
+ msg += "('auto', 'always', 'never')"
+ raise ValueError(msg % value)
+ self._chroot = value
+
+ @property
def compression_type(self):
if self._options is not None:
return self._options.compression_type
@@ -630,6 +645,10 @@ class SoSOptions(object):
parser.add_option("-s", "--sysroot", action="store", dest="sysroot",
help="system root directory path (default='/')",
default="/")
+ parser.add_option("-c", "--chroot", action="store", dest="chroot",
+ help="chroot executed commands to SYSROOT "
+ "[auto, always, never] (default=auto)",
+ default="auto")
parser.add_option("-z", "--compression-type", dest="compression_type",
help="compression technology to use [auto, "
"gzip, bzip2, xz] (default=auto)",
diff --git a/tests/utilities_tests.py b/tests/utilities_tests.py
index 9327b1f9..c4646926 100644
--- a/tests/utilities_tests.py
+++ b/tests/utilities_tests.py
@@ -69,7 +69,9 @@ class ExecutableTest(unittest.TestCase):
self.assertEquals(result['output'], "")
def test_output_chdir(self):
- result = sos_get_command_output("/usr/bin/pwd", chdir=TEST_DIR)
+ cmd = "/bin/bash -c 'echo $PWD'"
+ result = sos_get_command_output(cmd, chdir=TEST_DIR)
+ print(result)
self.assertEquals(result['status'], 0)
self.assertEquals(result['output'].strip(), TEST_DIR)