Beispiel #1
0
def _do_work(qTasks, qResults, qWatch, prefix, run_skipped, timeout, show_cmd):
    while True:
        test = qTasks.get(block=True, timeout=sys.maxint)
        if test is EndMarker:
            qWatch.put(EndMarker)
            qResults.put(EndMarker)
            return

        if not test.enable and not run_skipped:
            qResults.put(NullTestOutput(test))
            continue

        # Spawn the test task.
        cmd = test.get_command(prefix)
        if show_cmd:
            print(escape_cmdline(cmd))
        tStart = datetime.utcnow()
        proc = subprocess.Popen(cmd,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)

        # Push the task to the watchdog -- it will kill the task
        # if it goes over the timeout while we keep its stdout
        # buffer clear on the "main" worker thread.
        qWatch.put(proc)
        out, err = proc.communicate()
        qWatch.put(TaskFinishedMarker)

        # Create a result record and forward to result processing.
        dt = datetime.utcnow() - tStart
        result = TestOutput(test, cmd, out, err, proc.returncode,
                            dt.total_seconds(),
                            dt > timedelta(seconds=timeout))
        qResults.put(result)
Beispiel #2
0
def spawn_test(test, prefix, passthrough, run_skipped, show_cmd):
    """Spawn one child, return a task struct."""
    if not test.enable and not run_skipped:
        return None

    cmd = test.get_command(prefix)
    if show_cmd:
        print(escape_cmdline(cmd))

    if not passthrough:
        (rout, wout) = os.pipe()
        (rerr, werr) = os.pipe()

        rv = os.fork()

        # Parent.
        if rv:
            os.close(wout)
            os.close(werr)
            return Task(test, prefix, rv, rout, rerr)

        # Child.
        os.close(rout)
        os.close(rerr)

        os.dup2(wout, 1)
        os.dup2(werr, 2)

    os.execvp(cmd[0], cmd)
Beispiel #3
0
def spawn_test(test, prefix, passthrough, run_skipped, show_cmd):
    """Spawn one child, return a task struct."""
    if not test.enable and not run_skipped:
        return None

    cmd = test.get_command(prefix)
    if show_cmd:
        print(escape_cmdline(cmd))

    if not passthrough:
        (rout, wout) = os.pipe()
        (rerr, werr) = os.pipe()

        rv = os.fork()

        # Parent.
        if rv:
            os.close(wout)
            os.close(werr)
            return Task(test, prefix, rv, rout, rerr)

        # Child.
        os.close(rout)
        os.close(rerr)

        os.dup2(wout, 1)
        os.dup2(werr, 2)

    os.execvp(cmd[0], cmd)
Beispiel #4
0
def _do_work(qTasks, qResults, qWatch, prefix, run_skipped, timeout, show_cmd):
    while True:
        test = qTasks.get(block=True, timeout=sys.maxint)
        if test is EndMarker:
            qWatch.put(EndMarker)
            qResults.put(EndMarker)
            return

        if not test.enable and not run_skipped:
            qResults.put(NullTestOutput(test))
            continue

        # Spawn the test task.
        cmd = test.get_command(prefix)
        if show_cmd:
            print(escape_cmdline(cmd))
        tStart = datetime.now()
        proc = subprocess.Popen(cmd,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)

        # Push the task to the watchdog -- it will kill the task
        # if it goes over the timeout while we keep its stdout
        # buffer clear on the "main" worker thread.
        qWatch.put(proc)
        out, err = proc.communicate()
        qWatch.put(TaskFinishedMarker)

        # Create a result record and forward to result processing.
        dt = datetime.now() - tStart
        result = TestOutput(test, cmd, out, err, proc.returncode, dt.total_seconds(),
                            dt > timedelta(seconds=timeout))
        qResults.put(result)
Beispiel #5
0
def run_test_remote(test, device, prefix, options):
    from mozdevice import ADBDevice, ADBProcessError

    if options.test_reflect_stringify:
        raise ValueError("can't run Reflect.stringify tests remotely")
    cmd = test.command(prefix, posixpath.join(options.remote_test_root,
                                              'lib/'),
                       posixpath.join(options.remote_test_root, 'modules/'),
                       posixpath.join(options.remote_test_root, 'tests'))
    if options.show_cmd:
        print(escape_cmdline(cmd))

    env = {}
    if test.tz_pacific:
        env['TZ'] = 'PST8PDT'

    env['LD_LIBRARY_PATH'] = options.remote_test_root

    cmd = ADBDevice._escape_command_line(cmd)
    start = datetime.now()
    try:
        # Allow ADBError or ADBTimeoutError to terminate the test run,
        # but handle ADBProcessError in order to support the use of
        # non-zero exit codes in the JavaScript shell tests.
        out = device.shell_output(cmd,
                                  env=env,
                                  cwd=options.remote_test_root,
                                  timeout=int(options.timeout))
        returncode = 0
    except ADBProcessError as e:
        # Treat ignorable intermittent adb communication errors as
        # skipped tests.
        out = str(e.adb_process.stdout)
        returncode = e.adb_process.exitcode
        re_ignore = re.compile(r'error: (closed|device .* not found)')
        if returncode == 1 and re_ignore.search(out):
            print("Skipping {} due to ignorable adb error {}".format(
                test.path, out))
            test.skip_if_cond = "true"
            returncode = test.SKIPPED_EXIT_STATUS

    elapsed = (datetime.now() - start).total_seconds()

    # We can't distinguish between stdout and stderr so we pass
    # the same buffer to both.
    return TestOutput(test, cmd, out, out, returncode, elapsed, False)
Beispiel #6
0
def run_test_remote(test, device, prefix, options):
    from mozdevice import ADBDevice, ADBProcessError, ADBTimeoutError

    if options.test_reflect_stringify:
        raise ValueError("can't run Reflect.stringify tests remotely")
    cmd = test.command(prefix, posixpath.join(options.remote_test_root,
                                              'lib/'),
                       posixpath.join(options.remote_test_root, 'modules/'),
                       posixpath.join(options.remote_test_root, 'tests'))
    if options.show_cmd:
        print(escape_cmdline(cmd))

    env = {}
    if test.tz_pacific:
        env['TZ'] = 'PST8PDT'

    env['LD_LIBRARY_PATH'] = options.remote_test_root

    cmd = ADBDevice._escape_command_line(cmd)
    start = datetime.now()
    try:
        out = device.shell_output(cmd,
                                  env=env,
                                  cwd=options.remote_test_root,
                                  timeout=int(options.timeout))
        returncode = 0
    except ADBTimeoutError:
        raise
    except ADBProcessError as e:
        out = e.adb_process.stdout
        print("exception output: %s" % str(out))
        returncode = e.adb_process.exitcode

    elapsed = (datetime.now() - start).total_seconds()

    # We can't distinguish between stdout and stderr so we pass
    # the same buffer to both.
    return TestOutput(test, cmd, out, out, returncode, elapsed, False)
Beispiel #7
0
def run_test_remote(test, device, prefix, options):
    from mozdevice import ADBDevice, ADBProcessError, ADBTimeoutError

    if options.test_reflect_stringify:
        raise ValueError("can't run Reflect.stringify tests remotely")
    cmd = test.command(prefix,
                       posixpath.join(options.remote_test_root, 'lib/'),
                       posixpath.join(options.remote_test_root, 'modules/'),
                       posixpath.join(options.remote_test_root, 'tests'))
    if options.show_cmd:
        print(escape_cmdline(cmd))

    env = {}
    if test.tz_pacific:
        env['TZ'] = 'PST8PDT'

    env['LD_LIBRARY_PATH'] = options.remote_test_root

    cmd = ADBDevice._escape_command_line(cmd)
    start = datetime.now()
    try:
        out = device.shell_output(cmd, env=env,
                                  cwd=options.remote_test_root,
                                  timeout=int(options.timeout))
        returncode = 0
    except ADBTimeoutError:
        raise
    except ADBProcessError as e:
        out = e.adb_process.stdout
        print("exception output: %s" % str(out))
        returncode = e.adb_process.exitcode

    elapsed = (datetime.now() - start).total_seconds()

    # We can't distinguish between stdout and stderr so we pass
    # the same buffer to both.
    return TestOutput(test, cmd, out, out, returncode, elapsed, False)
Beispiel #8
0
 def show_test(res):
     if options.show_failed:
         print('    ' + escape_cmdline(res.cmd))
     else:
         print('    ' + ' '.join(res.test.jitflags + [res.test.relpath_tests]))
Beispiel #9
0
 def show_test(res):
     if options.show_failed:
         print('    ' + escape_cmdline(res.cmd))
     else:
         print('    ' + ' '.join(res.test.jitflags + [res.test.relpath_tests]))