Best Python code snippet using autotest_python
fsdev_disks.py
Source:fsdev_disks.py
...269FSDEV_RESTORE = None270FSDEV_PREP_CNT = 0271FSDEV_DISK1_ONLY = None272FSDEV_DISKLIST = None273def use_fsdev_lib(fs_desc, disk1_only, reinit_disks):274 """275 Called from the control file to indicate that fsdev is to be used.276 """277 global FSDEV_FS_DESC278 global FSDEV_RESTORE279 global FSDEV_DISK1_ONLY280 global FSDEV_PREP_CNT281 # This is a bit tacky - we simply save the arguments in global variables282 FSDEV_FS_DESC = fs_desc283 FSDEV_DISK1_ONLY = disk1_only284 FSDEV_RESTORE = reinit_disks285 # We need to keep track how many times 'prepare' is called286 FSDEV_PREP_CNT = 0287def prepare_fsdev(job):288 """289 Called from the test file to get the necessary drive(s) ready; return290 a pair of values: the absolute path to the first drive's mount point291 plus the complete disk list (which is useful for tests that need to292 use more than one drive).293 """294 global FSDEV_JOB295 global FSDEV_DISKLIST296 global FSDEV_PREP_CNT297 if not FSDEV_FS_DESC:298 return (None, None)299 # Avoid preparing the same thing more than once300 FSDEV_PREP_CNT += 1301 if FSDEV_PREP_CNT > 1:302 return (FSDEV_DISKLIST[0]['mountpt'], FSDEV_DISKLIST)303 FSDEV_JOB = job304 (path, toss, disks) = prepare_disks(job, fs_desc=FSDEV_FS_DESC,305 disk1_only=FSDEV_DISK1_ONLY,306 disk_list=None)307 FSDEV_DISKLIST = disks308 return (path, disks)309def finish_fsdev(force_cleanup=False):310 """311 This method can be called from the test file to optionally restore312 all the drives used by the test to a standard ext2 format. Note that313 if use_fsdev_lib() was invoked with 'reinit_disks' not set to True,314 this method does nothing. Note also that only fsdev "server-side"315 dynamic control files should ever set force_cleanup to True.316 """317 if FSDEV_PREP_CNT == 1 or force_cleanup:318 restore_disks(job=FSDEV_JOB,319 restore=FSDEV_RESTORE,320 disk_list=FSDEV_DISKLIST)321#322class fsdev_disks:323 """324 Disk drive handling class used for file system development325 """326 def __init__(self, job):327 self.job = job...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!