Show the result of the mlabel when logging the mlabel failure

It's helpful to see what mlabel gave when it failed to get the label
for a drive.

Change-Id: I531c1a75debaa88aff3185fdaa03417559eec7cc
This commit is contained in:
Claudiu Popa 2015-03-26 02:01:18 +02:00
parent 54b18ca6e9
commit 4e7e8ac867
2 changed files with 7 additions and 3 deletions

View File

@ -52,11 +52,14 @@ class TestVfat(unittest.TestCase):
self.assertEqual(expected_response, response)
def test_is_vfat_drive_fails(self):
test_stderr = b"test stderr"
expected_logging = [
"Could not retrieve label for VFAT drive path %r"
% mock.sentinel.drive,
% (mock.sentinel.drive),
"mlabel failed with error %r" % test_stderr,
]
execute_process_value = (None, None, 1)
execute_process_value = (None, test_stderr, 1)
expected_response = False
self._test_is_vfat_drive(execute_process_value=execute_process_value,

View File

@ -47,10 +47,11 @@ def is_vfat_drive(osutils, drive_path):
mlabel = os.path.join(CONF.mtools_path, "mlabel.exe")
args = [mlabel, "-i", drive_path, "-s"]
out, _, exit_code = osutils.execute_process(args, shell=False)
out, err, exit_code = osutils.execute_process(args, shell=False)
if exit_code:
LOG.warning("Could not retrieve label for VFAT drive path %r",
drive_path)
LOG.warning("mlabel failed with error %r", err)
return False
out = out.decode().strip()