Skip to content

Commit 7f04953

Browse files
authored
Merge pull request avocado-framework#4199 from leidwang/issue4169
2 parents 44d6b14 + 5fe8174 commit 7f04953

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

virttest/utils_disk.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import tempfile
1818
from functools import cmp_to_key
1919

20+
import aexpect
2021
from avocado.core import exceptions
2122
from avocado.utils import process, wait
2223
from avocado.utils.service import SpecificServiceManager
@@ -64,7 +65,9 @@ def copytree(src, dst, overwrite=True, ignore=""):
6465
shutil.copy(src_file, dst_dir)
6566

6667

67-
def is_mount(src, dst=None, fstype=None, options=None, verbose=False, session=None):
68+
def is_mount(
69+
src=None, dst=None, fstype=None, options=None, verbose=False, session=None
70+
):
6871
"""
6972
Check is src or dst mounted.
7073
@@ -77,23 +80,22 @@ def is_mount(src, dst=None, fstype=None, options=None, verbose=False, session=No
7780
:return: True if mounted, else return False
7881
"""
7982
mount_options = [("-S", src), ("-M", dst), ("-t", fstype), ("-O", options)]
80-
mount_opts = " ".join(
81-
f"{opt} {val}" for opt, val in mount_options if val is not None
82-
)
83+
mount_opts = " ".join(f"{opt} {val}" for opt, val in mount_options if val)
8384
if mount_opts == "":
8485
raise exceptions.TestError("Mount options is empty, it is meaningless")
8586
mount_check_cmd = f"findmnt -J {mount_opts}"
8687

8788
mount_result = None
8889
try:
8990
if session:
90-
mount_result = session.cmd_output_safe(mount_check_cmd)
91+
mount_result = session.cmd(mount_check_cmd)
9192
else:
9293
mount_result = process.run(mount_check_cmd, shell=True).stdout_text
9394
if verbose:
9495
LOG.info("Output of findmnt: %s", mount_result)
95-
except process.CmdError:
96-
pass
96+
except (process.CmdError, aexpect.exceptions.ShellCmdError) as e:
97+
LOG.error("Exception info: %s", e)
98+
return False
9799

98100
if mount_result:
99101
if verbose:

0 commit comments

Comments
 (0)