def runVMCommand(self, command, expectedErrors=[], silent=False): """ runs a command in the VM using the vmrun.exe helper """ commandString = "" for part in command: commandString += str(part) + " " if not silent: self.automation.log.info( "INFO | runtests.py | Running command: %s" % commandString) commonErrors = [ "Error: Invalid user name or password for the guest OS", "Unable to connect to host." ] expectedErrors.extend(commonErrors) # VMware can't run commands until the VM has fully loaded so keep running # this command in a loop until it succeeds or we try 100 times. errorString = "" for i in range(100): process = Automation.Process(command, stdout=PIPE) result = process.wait() if result == 0: break for line in process.stdout.readlines(): line = line.strip() if not line: continue errorString = line break expected = False for error in expectedErrors: if errorString.startswith(error): expected = True if not expected: self.automation.log.warning( "WARNING | runtests.py | Command \"%s\" " "failed with result %d, : %s" % (commandString, result, errorString)) break if not silent: self.automation.log.info( "INFO | runtests.py | Running command again.") return (result, process.stdout.readlines())
if options.extraArg != "": args.append(options.extraArg) # Different binary implies no default args if 'bin' in cmd: binary = cmd['bin'] args = cmd['args'] print >> sys.stderr, 'INFO | runtest.py | Running ' + cmd['name'] + ' in ' + CWD + ' : ' print >> sys.stderr, 'INFO | runtest.py | ', binary, args envkeys = mailnewsEnv.keys() envkeys.sort() for envkey in envkeys: print >> sys.stderr, "%s=%s"%(envkey, mailnewsEnv[envkey]) proc = automation.Process([binary] + args, env = mailnewsEnv) status = proc.wait() if status != 0: print >> sys.stderr, "TEST-UNEXPECTED-FAIL | runtest.py | Exited with code %d during test run"%(status) if checkForCrashes(os.path.join(PROFILE, "minidumps"), options.symbols, cmd['name']): print >> sys.stderr, 'TinderboxPrint: ' + cmd['name'] + '<br/><em class="testfail">CRASH</em>' status = 1 if status != 0: sys.exit(status) print >> sys.stderr, 'INFO | runtest.py | ' + cmd['name'] + ' executed successfully.' print >> sys.stderr, 'INFO | runtest.py | All tests executed successfully.'