예제 #1
0
 def launchProcess(self, cmd, stdout, stderr, env, cwd, timeout=None):
     self.timedout = False
     cmd.insert(1, self.remoteHere)
     cmd = ADBDevice._escape_command_line(cmd)
     try:
         # env is ignored here since the environment has already been
         # set for the command via the pushWrapper method.
         adb_process = self.device.shell(cmd, timeout=timeout+10, root=True)
         output_file = adb_process.stdout_file
         self.shellReturnCode = adb_process.exitcode
     except ADBTimeoutError:
         raise
     except Exception as e:
         if self.timedout:
             # If the test timed out, there is a good chance the shell
             # call also timed out and raised this Exception.
             # Ignore this exception to simplify the error report.
             self.shellReturnCode = None
         else:
             raise e
     # The device manager may have timed out waiting for xpcshell.
     # Guard against an accumulation of hung processes by killing
     # them here. Note also that IPC tests may spawn new instances
     # of xpcshell.
     self.device.pkill("xpcshell")
     return output_file
예제 #2
0
def run_test_remote(test, device, prefix, tempdir, 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/"),
        tempdir,
        posixpath.join(options.remote_test_root, "tests"),
    )
    if options.show_cmd:
        print(escape_cmdline(cmd))

    env = {"LD_LIBRARY_PATH": os.path.dirname(prefix[0])}

    if test.tz_pacific:
        env["TZ"] = "PST8PDT"

    # replace with shlex.join when move to Python 3.8+
    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)
예제 #3
0
def setup_script(device, prefix, tempdir, options, uniq_tag, tests):
    timeout = int(options.timeout)
    script_timeout = 0
    try:
        print("tasks_adb_remote.py : Create batch script")
        tmpf = tempfile.NamedTemporaryFile(mode="w", delete=False)
        tmpf.write(script_preamble(uniq_tag, prefix, options))
        for i, test in enumerate(tests):
            # This test is common to all tasks_*.py files, however, jit-test do
            # not provide the `run_skipped` option, and all tests are always
            # enabled.
            assert test.enable  # and not options.run_skipped
            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/"),
                tempdir,
                posixpath.join(options.remote_test_root, "tests"),
            )

            # replace with shlex.join when move to Python 3.8+
            cmd = ADBDevice._escape_command_line(cmd)

            env = {}
            if test.tz_pacific:
                env["TZ"] = "PST8PDT"
            envStr = "".join(key + "='" + val + "' "
                             for key, val in env.items())

            tmpf.write("{}do_test {} 0 {};\n".format(envStr, i, cmd))
            script_timeout += timeout
        tmpf.write("do_end;\n")
        tmpf.close()
        script = posixpath.join(options.remote_test_root, "test_manifest.sh")
        device.push(tmpf.name, script)
        device.chmod(script)
        print("tasks_adb_remote.py : Batch script created")
    except Exception as e:
        print("tasks_adb_remote.py : Batch script failed")
        raise e
    finally:
        if tmpf:
            os.unlink(tmpf.name)
    return script, script_timeout
예제 #4
0
    def _test_remote(self, cond, options=[]):
        from mozdevice import ADBDevice, ADBProcessError

        ans = self.cache.get(cond, None)
        if ans is not None:
            return ans

        env = {
            'LD_LIBRARY_PATH':
            posixpath.join(self.options.remote_test_root, 'bin'),
        }

        cmd = [self.js_bin] + self.js_args + options + [
            # run in safe configuration, since it is hard to debug
            # crashes when running code here. In particular, msan will
            # error out if the jit is active.
            '--no-baseline',
            '--no-blinterp',
            '-e',
            self.js_prologue,
            '-e',
            'print(!!({}))'.format(cond)
        ]
        cmd = ADBDevice._escape_command_line(cmd)
        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 = self.device.shell_output(cmd,
                                           env=env,
                                           cwd=self.options.remote_test_root,
                                           timeout=None)
            err = ''
        except ADBProcessError as e:
            out = ''
            err = str(e.adb_process.stdout)

        if out == 'true':
            ans = True
        elif out == 'false':
            ans = False
        else:
            raise Exception("Failed to test XUL condition {!r};"
                            " output was {!r}, stderr was {!r}".format(
                                cond, out, err))
        self.cache[cond] = ans
        return ans
예제 #5
0
def run_test_remote(test, device, prefix, options):
    from mozdevice import ADBDevice, ADBProcessError

    cmd = test.get_command(prefix)
    test_root_parent = os.path.dirname(test.root)
    jtd_tests = posixpath.join(options.remote_test_root, 'tests')
    cmd = [_.replace(test_root_parent, jtd_tests) for _ in cmd]

    env = {'TZ': 'PST8PDT', 'LD_LIBRARY_PATH': os.path.dirname(prefix[0])}

    adb_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(adb_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)
예제 #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)
예제 #7
0
파일: jittests.py 프로젝트: servo/mozjs
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)