def run(self, test_name, option=None, timeout=-1, repeat_count=0): # Make sure in test image now self.check_lava_android_test_installed() with self.client.android_tester_session() as session: bundle_name = generate_bundle_file_name(test_name) cmds = [ "lava-android-test", 'run', test_name, '-s', session.dev_name, '-o', '%s/%s.bundle' % (self.context.host_result_dir, bundle_name) ] if option is not None: cmds.extend(['-O', option]) if timeout != -1: cmds.insert(0, 'timeout') cmds.insert(1, '%ss' % timeout) t = DrainConsoleOutput(proc=session._connection, timeout=timeout) t.start() logging.info("Execute command on host: %s" % (' '.join(cmds))) rc = self.context.run_command(cmds) t.join() if rc == 124: raise TimeoutError( "The test case(%s) on device(%s) timed out" % (test_name, session.dev_name)) elif rc != 0: raise OperationFailed( "Failed to run test case(%s) on device(%s) with return " "value: %s" % (test_name, session.dev_name, rc))
def run(self, test_name, option=None, timeout=-1, repeat_count=0): # Make sure in test image now self.check_lava_android_test_installed() with self.client.android_tester_session() as session: bundle_name = generate_bundle_file_name(test_name) cmds = ["lava-android-test", 'run', test_name, '-s', session.dev_name, '-o', '%s/%s.bundle' % (self.context.host_result_dir, bundle_name)] if option is not None: cmds.extend(['-O', option]) if timeout != -1: cmds.insert(0, 'timeout') cmds.insert(1, '%ss' % timeout) t = DrainConsoleOutput(proc=session._connection, timeout=timeout) t.start() logging.info("Execute command on host: %s" % (' '.join(cmds))) rc = self.context.run_command(cmds) t.join() if rc == 124: raise TimeoutError( "The test case(%s) on device(%s) timed out" % (test_name, session.dev_name)) elif rc != 0: raise OperationFailed( "Failed to run test case(%s) on device(%s) with return " "value: %s" % (test_name, session.dev_name, rc))
def run(self, commands=None, command_file=None, parser=None, timeout=-1, repeat_count=0): """ :param commands: a list of commands :param command_file: a file containing commands :param parser: The parser to use for the test :param timeout: The timeout to apply. """ # Make sure in test image now self.check_lava_android_test_installed() if commands or command_file: with self.client.android_tester_session() as session: bundle_name = generate_bundle_file_name('custom') cmds = ["lava-android-test", 'run-custom'] if commands: for command in commands: cmds.extend(['-c', command]) elif command_file: cmds.extend(['-f', command_file]) else: raise OperationFailed( "Only one of the -c and -f option can be specified" " for lava_android_test_run_custom action") cmds.extend([ '-s', session.dev_name, '-o', '%s/%s.bundle' % (self.context.host_result_dir, bundle_name) ]) if parser is not None: cmds.extend(['-p', parser]) if timeout != -1: cmds.insert(0, 'timeout') cmds.insert(1, '%ss' % timeout) logging.info("Execute command on host: %s" % (' '.join(cmds))) rc = self.context.run_command(cmds) if rc == 124: raise TimeoutError( "The test (%s) on device(%s) timed out." % (' '.join(cmds), session.dev_name)) elif rc != 0: raise OperationFailed( "Failed to run test custom case[%s] on device(%s)" " with return value: %s" % (' '.join(cmds), session.dev_name, rc))
def run(self, commands=None, command_file=None, parser=None, timeout=-1, repeat_count=0): """ :param commands: a list of commands :param command_file: a file containing commands :param parser: The parser to use for the test :param timeout: The timeout to apply. """ # Make sure in test image now self.check_lava_android_test_installed() if commands or command_file: with self.client.android_tester_session() as session: bundle_name = generate_bundle_file_name('custom') cmds = ["lava-android-test", 'run-custom'] if commands: for command in commands: cmds.extend(['-c', command]) elif command_file: cmds.extend(['-f', command_file]) else: raise OperationFailed( "Only one of the -c and -f option can be specified" " for lava_android_test_run_custom action") cmds.extend(['-s', session.dev_name, '-o', '%s/%s.bundle' % (self.context.host_result_dir, bundle_name)]) if parser is not None: cmds.extend(['-p', parser]) if timeout != -1: cmds.insert(0, 'timeout') cmds.insert(1, '%ss' % timeout) logging.info("Execute command on host: %s" % (' '.join(cmds))) rc = self.context.run_command(cmds) if rc == 124: raise TimeoutError( "The test (%s) on device(%s) timed out." % (' '.join(cmds), session.dev_name)) elif rc != 0: raise OperationFailed( "Failed to run test custom case[%s] on device(%s)" " with return value: %s" % (' '.join(cmds), session.dev_name, rc))
def run(self, url=None, timeout=-1, repeat_count=0): # Make sure in test image now self.check_lava_android_test_installed() with self.client.android_tester_session() as session: bundle_name = generate_bundle_file_name('monkeyrunner') cmds = ["lava-android-test", 'run-monkeyrunner', url] cmds.extend(['-s', session.dev_name, '-o', '%s/%s.bundle' % (self.context.host_result_dir, bundle_name)]) if timeout != -1: cmds.insert(0, 'timeout') cmds.insert(1, '%ss' % timeout) logging.info("Execute command on host: %s" % (' '.join(cmds))) rc = self.context.run_command(cmds) if rc == 124: raise TimeoutError("Failed to run monkeyrunner test url[%s] on device(%s)" % (url, session.dev_name)) elif rc != 0: raise OperationFailed( "Failed to run monkeyrunner test url[%s] on device(%s)" " with return value: %s" % (url, session.dev_name, rc))
def run(self, test_name, test_options="", timeout=-1): self.context.any_device_bundles = True logging.info("Executing lava_test_run %s command" % test_name) with self.client.tester_session() as session: session.run('mkdir -p %s' % self.context.config.lava_result_dir) session.export_display() bundle_name = generate_bundle_file_name(test_name) if test_options != "": test_options = "-t '%s'" % test_options cmd = ('lava-test run %s %s -o %s/%s.bundle' % (test_name, test_options, self.context.config.lava_result_dir, bundle_name)) try: rc = session.run(cmd, timeout=timeout) except KeyboardInterrupt: raise KeyboardInterrupt except: logging.exception("session.run failed") self.client.proc.sendcontrol('c') try: session.run('true', timeout=20) except KeyboardInterrupt: raise KeyboardInterrupt except: logging.exception("killing test failed, rebooting") self.client.boot_linaro_image() raise finally: # try to make sure the test bundle is safely written to disk session.run('sync', timeout=60) if rc is None: raise OperationFailed("test case getting return value failed") elif rc != 0: raise OperationFailed( "test case failed with return value: %s" % rc)
def run(self, url=None, timeout=-1, repeat_count=0): # Make sure in test image now self.check_lava_android_test_installed() with self.client.android_tester_session() as session: bundle_name = generate_bundle_file_name('monkeyrunner') cmds = ["lava-android-test", 'run-monkeyrunner', url] cmds.extend([ '-s', session.dev_name, '-o', '%s/%s.bundle' % (self.context.host_result_dir, bundle_name) ]) if timeout != -1: cmds.insert(0, 'timeout') cmds.insert(1, '%ss' % timeout) logging.info("Execute command on host: %s" % (' '.join(cmds))) rc = self.context.run_command(cmds) if rc == 124: raise TimeoutError( "Failed to run monkeyrunner test url[%s] on device(%s)" % (url, session.dev_name)) elif rc != 0: raise OperationFailed( "Failed to run monkeyrunner test url[%s] on device(%s)" " with return value: %s" % (url, session.dev_name, rc))