How to use unmount_force method in autotest

Best Python code snippet using autotest_python

mtab.py

Source:mtab.py Github

copy

Full Screen

...24 @abc.abstractmethod25 def unmount_lazy(self, mount_point: bytes) -> bool:26 "Corresponds to `umount -l` on Linux."27 @abc.abstractmethod28 def unmount_force(self, mount_point: bytes) -> bool:29 "Corresponds to `umount -f` on Linux."30 def lstat(self, path: Union[bytes, str]) -> MTStat:31 "Returns a subset of the results of os.lstat."32 st = os.lstat(path)33 return MTStat(st_uid=st.st_uid, st_dev=st.st_dev, st_mode=st.st_mode)34 def check_path_access(self, path: bytes) -> None:35 """\36 Attempts to stat the given directory, bypassing the kernel's caches.37 Raises OSError upon failure.38 """39 # Even if the FUSE process is shut down, the lstat call will succeed if40 # the stat result is cached. Append a random string to avoid that. In a41 # better world, this code would bypass the cache by opening a handle42 # with O_DIRECT, but Eden does not support O_DIRECT.43 try:44 os.lstat(os.path.join(path, hex(random.getrandbits(32))[2:].encode()))45 except OSError as e:46 if e.errno == errno.ENOENT:47 return48 raise49 @abc.abstractmethod50 def create_bind_mount(self, source_path, dest_path) -> bool:51 "Creates a bind mount from source_path to dest_path."52def parse_mtab(contents: bytes) -> List[MountInfo]:53 mounts = []54 for line in contents.splitlines():55 # columns split by space or tab per man page56 entries = line.split()57 if len(entries) != 6:58 log.warning(f"mount table line has {len(entries)} entries instead of 6")59 continue60 device, mount_point, vfstype, opts, freq, passno = entries61 mounts.append(62 MountInfo(device=device, mount_point=mount_point, vfstype=vfstype)63 )64 return mounts65class LinuxMountTable(MountTable):66 def read(self) -> List[MountInfo]:67 # What's the most portable mtab path? I've seen both /etc/mtab and68 # /proc/self/mounts. CentOS 6 in particular does not symlink /etc/mtab69 # to /proc/self/mounts so go directly to /proc/self/mounts.70 # This code could eventually fall back to /proc/mounts and /etc/mtab.71 with open("/proc/self/mounts", "rb") as f:72 return parse_mtab(f.read())73 def unmount_lazy(self, mount_point: bytes) -> bool:74 # MNT_DETACH75 return 0 == subprocess.call(["sudo", "umount", "-l", mount_point])76 def unmount_force(self, mount_point: bytes) -> bool:77 # MNT_FORCE78 return 0 == subprocess.call(["sudo", "umount", "-f", mount_point])79 def create_bind_mount(self, source_path, dest_path) -> bool:80 return 0 == subprocess.check_call(81 ["sudo", "mount", "-o", "bind", source_path, dest_path]82 )83def parse_macos_mount_output(contents: bytes) -> List[MountInfo]:84 mounts = []85 for line in contents.splitlines():86 m = re.match(b"^(\\S+) on (.+) \\(([^,]+),.*\\)$", line)87 if m:88 mounts.append(89 MountInfo(device=m.group(1), mount_point=m.group(2), vfstype=m.group(3))90 )91 return mounts92class MacOSMountTable(MountTable):93 def read(self) -> List[MountInfo]:94 # Specifying the path is important, as sudo may have munged the path95 # such that /sbin is not part of it any longer96 contents = subprocess.check_output(["/sbin/mount"])97 return parse_macos_mount_output(contents)98 def unmount_lazy(self, mount_point: bytes) -> bool:99 return False100 def unmount_force(self, mount_point: bytes) -> bool:101 return False102 def create_bind_mount(self, source_path, dest_path) -> bool:103 return False104class NopMountTable(MountTable):105 def read(self) -> List[MountInfo]:106 return []107 def unmount_lazy(self, mount_point: bytes) -> bool:108 return False109 def unmount_force(self, mount_point: bytes) -> bool:110 return False111 def create_bind_mount(self, source_path, dest_path) -> bool:112 return False113def new() -> MountTable:114 if "linux" in sys.platform:115 return LinuxMountTable()116 if sys.platform == "darwin":117 return MacOSMountTable()...

Full Screen

Full Screen

add_file_endp.py

Source:add_file_endp.py Github

copy

Full Screen

1from enum import Enum2from collections import namedtuple3# This is a surprising technique that is not an obvious extension to the language4class fe_fstype(namedtuple("fe_fstype", "id name"), Enum):5 EP_FE_GENERIC = 8, "generic"6 EP_FE_NFS = 9, "fe_nfs"7 EP_FE_ISCSI = 10, "fe_iscsi"8 EP_FE_CIFS = 24, "fe_cifs"9 EP_FE_NFS4 = 25, "fe_nfs4"10 EP_FE_CIFSipv6 = 26, "fe_cifs/ip6"11 EP_FE_NFSipv6 = 27, "fe_nfs/ip6"12 EP_FE_NFS4ipv6 = 28, "fe_nfs4/ip6"13 EP_FE_SMB2 = 29, "fe_smb2"14 EP_FE_SMB2ipv6 = 30, "fe_smb2/ip6"15 EP_FE_SMB21 = 35, "fe_smb21"16 EP_FE_SMB21ipv6 = 36, "fe_smb21/ip6"17 EP_FE_SMB30 = 37, "fe_smb30"18 EP_FE_SMB30ipv6 = 38, "fe_smb30/ip6"19 20class fe_payload_list(Enum):21 increasing = 1 # bytes start at 00 and increase, wrapping if needed.22 decreasing = 2 # bytes start at FF and decrease, wrapping if needed.23 random = 3 # generate a new random payload each time sent.24 25 random_fixed = 4 # Means generate one random payload, and send it over26 # and over again.27 28 zeros = 5 # Payload is all zeros (00).29 ones = 6 # Payload is all ones (FF).30 31 PRBS_4_0_3 = 7 # Use linear feedback shift register to generate pseudo random sequence.32 # First number is bit-length of register, second two are TAPS (zero-based indexs)33 # Seed value is always 1.34 35 PRBS_7_0_6 = 8 # PRBS (see above)36 PRBS_11_8_10 = 9 # PRBS (see above)37 PRBS_15_0_14 = 10 # PRBS (see above)38 custom = 11 # Enter your own payload with the set_endp_payload cmd.39 40class fe_fio_flags(Enum):41 CHECK_MOUNT = 0x1, # (1) Attempt to verify NFS and SMB mounts match the configured values.42 AUTO_MOUNT = 0x2, # (2) Attempt to mount with the provided information if not already mounted.43 AUTO_UNMOUNT = 0x4, # (4) Attempt to un-mount when stopping test.44 O_DIRECT = 0x8, # (8) Open file with O_DIRECT flag, disables caching. Must use block-size read/write calls.45 UNLINK_BW = 0x10, # (16) Unlink file before writing. This works around issues with CIFS for some file-servers.46 O_LARGEFILE = 0x20, # (32) Open files with O_LARGEFILE. This allows greater than 2GB files on 32-bit systems.47 UNMOUNT_FORCE = 0x40, # (64) Use -f flag when calling umount48 UNMOUNT_LAZY = 0x80, # (128) Use -l flag when calling umount49 USE_FSTATFS = 0x100, # (256) Use fstatfs system call to verify file-system type when opening files.50 # This can take a bit of time on some file systems, but it can be used51 # to detect un-expected file-system unmounts and such.52 53 O_APPEND = 0x200 # (512) Open files for writing with O_APPEND instead54 # of O_TRUNC. This will cause files to grow ever larger.55 56 # base_endpoint_types cribbed from BaseEndpoint.java57 # we are unlikely to need this dictionary58class fe_base_endpoint_types(Enum):59 EP_FE_GENERIC = 860 EP_FE_NFS = 961 EP_FE_ISCSI = 1062 EP_FE_CIFS = 2463 EP_FE_NFS4 = 2564 EP_FE_CIFS6 = 2665 EP_FE_NFS6 = 2766 EP_FE_NFS46 = 2867 EP_FE_SMB2 = 2968 EP_FE_SMB26 = 3069 EP_FE_SMB21 = 3570 EP_FE_SMB216 = 3671 EP_FE_SMB30 = 37...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful