Best Python code snippet using autotest_python
harness_standalone.py
Source:harness_standalone.py
...29 dest = os.path.join(tests_dir, 'control')30 if os.path.abspath(src) != os.path.abspath(dest):31 shutil.copyfile(src, dest)32 job.control_set(dest)33 def yield_default_initlevel():34 """35 If we really can't figure out something better, default to '2',36 which is the case with some debian systems37 """38 init_default = '2'39 logging.error('Could not determine initlevel, assuming %s' %40 init_default)41 return init_default42 rc = os.path.join(self.autodir, 'tools/autotest')43 # see if system supports event.d versus systemd versus inittab44 supports_eventd = os.path.exists('/etc/event.d')45 supports_systemd = os.path.exists('/etc/systemd')46 supports_inittab = os.path.exists('/etc/inittab')47 # This is the best heuristics I can think of for identifying48 # an embedded system running busybox49 busybox_system = (os.readlink('/bin/sh') == 'busybox')50 # Small busybox systems usually use /etc/rc.d/ straight51 if busybox_system:52 initdefault = ''53 elif supports_eventd or supports_systemd:54 try:55 # NB: assuming current runlevel is default56 cmd_result = utils.run('/sbin/runlevel', verbose=False)57 initdefault = cmd_result.stdout.split()[1]58 except (error.CmdError, IndexError):59 initdefault = yield_default_initlevel()60 elif supports_inittab:61 try:62 cmd_result = utils.run('grep :initdefault: /etc/inittab',63 verbose=False)64 initdefault = cmd_result.stdout.split(':')[1]65 except (error.CmdError, IndexError):66 initdefault = yield_default_initlevel()67 else:68 initdefault = yield_default_initlevel()69 vendor = distro.detect().name70 service = '/etc/init.d/autotest'71 if vendor == 'SUSE':72 service_link = '/etc/init.d/rc%s.d/S99autotest' % initdefault73 else:74 service_link = '/etc/rc%s.d/S99autotest' % initdefault75 try:76 if os.path.islink(service):77 os.remove(service)78 if os.path.islink(service_link):79 os.remove(service_link)80 os.symlink(rc, service)81 os.symlink(rc, service_link)82 except (OSError, IOError):...
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!!