Example #1
0
def main(argv):
    for ix in range(100):
        print argv[1], "starting pass ", ix
        with open("log%s_%s.txt" % (argv[1], ix), "wb") as f:
            try:
                subprocess.check_call(
                    "ulimit -c unlimited; " + " ".join(["python"] + argv[2:]) + " 2> log%s_%s.txt > out%s_%s.txt" % (argv[1], ix, argv[1], ix), 
                    stderr=subprocess.STDOUT,
                    shell=True
                    )
            except subprocess.CalledProcessError as e:
                print "ERRORS in log%s_%s.txt" % (argv[1],ix)
                print >> f, e.output
Example #2
0
    def runScript_(self, script):
        print
        print "Running %s" % script
        print "with a timeout of %s sec" % self.getTimeout(script)

        if sys.platform == 'linux2':
            directory, filename = os.path.split(script)
            args = [
                sys.executable, "-u", '-c',
                "print 'started'; execfile('%s')" % filename
            ]

            with DirectoryScope(directory):
                tries = 0
                runner = None

                while tries < 5 and runner is None:
                    startedEvent = threading.Event()

                    def printOutput(line):
                        if line == 'started':
                            startedEvent.set()
                            print "Script %s started" % filename
                        else:
                            print "OUT> %s\n" % line,

                    def printErr(line):
                        print "ERR> %s\n" % line,

                    runner = SubprocessRunner.SubprocessRunner(
                        args, printOutput, printErr, self.envVars)
                    runner.start()

                    startedEvent.wait(5)
                    if not startedEvent.isSet():
                        runner.terminate()
                        runner = None
                        tries = tries + 1
                        print "Retrying script ", filename, " as python failed to start."

                if runner is None:
                    print "Test %s failed to start a python process in 5 tries" % filename
                    return False
                else:
                    result = runner.wait(self.getTimeout(script))

                    if result is None:
                        try:
                            runner.terminate()
                        except:
                            print "Failed to terminate test runner: ", traceback.format_exc(
                            )
                        print "Test %s timed out" % filename,
                        return False
                    runner.stop()

                    if result != 0:
                        print "Test %s failed" % filename,
                        return False

                return True
        else:
            subprocess.check_call('cd "%s" & c:\python27\python.exe %s ' %
                                  os.path.split(script),
                                  shell=True)

        return True
Example #3
0
    def runScript_(self, script):
        print
        print "Running %s" % script
        print "with a timeout of ", self.getTimeout(script)

        if sys.platform == 'linux2':
            directory, filename = os.path.split(script)
            genCore = os.path.abspath('generateCore.gdb')
            args = [sys.executable, "-u", '-c', "print 'started'; execfile('%s')" % filename]

            with DirectoryScope(directory):
                tries = 0
                runner = None

                while tries < 5 and runner is None:
                    startedEvent = threading.Event()

                    def printOutput(line):
                        if line == 'started':
                            startedEvent.set()
                            print "Script %s started" % filename
                        else:
                            print "OUT> %s\n" % line,

                    def printErr(line):
                        print "ERR> %s\n" % line,

                    runner = SubprocessRunner.SubprocessRunner(
                        args,
                        printOutput,
                        printErr,
                        self.envVars
                        )
                    runner.start()

                    startedEvent.wait(5)
                    if not startedEvent.isSet():
                        runner.terminate()
                        runner = None
                        tries = tries + 1
                        print "Retrying script ", filename, " as python failed to start."

                if runner is None:
                    print "Test %s failed to start a python process in 5 tries" % filename
                    return False
                else:
                    result = runner.wait(self.getTimeout(script))

                    if result is None:
                        try:
                            runner.terminate()
                        except:
                            print "Failed to terminate test runner: ", traceback.format_exc()
                        print "Test %s timed out" % filename,
                        return False
                    runner.stop()


                    if result != 0:
                        print "Test %s failed" % filename,
                        return False

                return True
        else:
            subprocess.check_call('cd "%s" & c:\python27\python.exe %s '
                % os.path.split(script),
                shell = True
                )

        return True