1717import tempfile
1818from functools import cmp_to_key
1919
20+ import aexpect
2021from avocado .core import exceptions
2122from avocado .utils import process , wait
2223from 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