Beispiel #1
0
    def serial_test_process_crashing(self):
        # Give -u switch to force stdout to be unbuffered for Windows
        cmd = [
            sys.executable, '-uc',
            'import sys; print("stdout 1"); print("stdout 2"); print("stdout 3"); sys.stdin.readline(); sys.exit(1);'
        ]
        host = SystemHost()
        factory = PortFactory(host)
        port = factory.get()
        now = time.time()
        proc = server_process.ServerProcess(port, 'python', cmd)
        proc.write(b'')

        line = proc.read_stdout_line(now + 1.0)
        self.assertEqual(line.strip(), b'stdout 1')

        proc.write(b'End\n')
        time.sleep(0.1)  # Give process a moment to close.

        line = proc.read_stdout_line(now + 1.0)
        self.assertEqual(line.strip(), b'stdout 2')

        self.assertEqual(True, proc.has_crashed())

        line = proc.read_stdout_line(now + 1.0)
        self.assertEqual(line, None)

        proc.stop(0)
    def test_basic(self):
        cmd = [sys.executable, '-c', 'import sys; import time; time.sleep(0.02); print "stdout"; sys.stdout.flush(); print >>sys.stderr, "stderr"']
        host = SystemHost()
        factory = PortFactory(host)
        port = factory.get()
        now = time.time()
        proc = server_process.ServerProcess(port, 'python', cmd)
        proc.write('')

        if sys.platform.startswith('win'):
            self.assertEqual(proc.poll(), 0)
        else:
            self.assertEqual(proc.poll(), None)
        self.assertFalse(proc.has_crashed())

        # check that doing a read after an expired deadline returns
        # nothing immediately.
        line = proc.read_stdout_line(now - 1)
        self.assertEqual(line, None)

        # FIXME: This part appears to be flaky. line should always be non-None.
        # FIXME: https://bugs.webkit.org/show_bug.cgi?id=88280
        line = proc.read_stdout_line(now + 1.0)
        if line:
            self.assertEqual(line.strip(), "stdout")

        line = proc.read_stderr_line(now + 1.0)
        if line:
            self.assertEqual(line.strip(), "stderr")

        proc.stop(0)
Beispiel #3
0
    def test_basic(self):
        cmd = [sys.executable, '-c', 'import sys; import time; time.sleep(0.02); print "stdout"; sys.stdout.flush(); print >>sys.stderr, "stderr"']
        host = SystemHost()
        factory = PortFactory(host)
        port = factory.get()
        now = time.time()
        proc = server_process.ServerProcess(port, 'python', cmd)
        proc.write('')

        self.assertEqual(proc.poll(), None)
        self.assertFalse(proc.has_crashed())

        # check that doing a read after an expired deadline returns
        # nothing immediately.
        line = proc.read_stdout_line(now - 1)
        self.assertEqual(line, None)

        # FIXME: This part appears to be flaky. line should always be non-None.
        # FIXME: https://bugs.webkit.org/show_bug.cgi?id=88280
        line = proc.read_stdout_line(now + 1.0)
        if line:
            self.assertEqual(line.strip(), "stdout")

        line = proc.read_stderr_line(now + 1.0)
        if line:
            self.assertEqual(line.strip(), "stderr")

        proc.stop(0)
Beispiel #4
0
    def test_process_crashing(self):
        cmd = [
            sys.executable, '-c',
            'import sys; print "stdout 1"; print "stdout 2"; print "stdout 3"; sys.stdout.flush(); sys.stdin.readline(); sys.exit(1);'
        ]
        host = SystemHost()
        factory = PortFactory(host)
        port = factory.get()
        now = time.time()
        proc = server_process.ServerProcess(port, 'python', cmd)
        proc.write('')

        line = proc.read_stdout_line(now + 1.0)
        self.assertEqual(line.strip(), 'stdout 1')

        proc.write('End\n')
        time.sleep(0.1)  # Give process a moment to close.

        line = proc.read_stdout_line(now + 1.0)
        self.assertEqual(line.strip(), 'stdout 2')

        self.assertEqual(True, proc.has_crashed())

        line = proc.read_stdout_line(now + 1.0)
        self.assertEqual(line, None)

        proc.stop(0)
Beispiel #5
0
    def serial_test_basic(self):
        # Give -u switch to force stdout and stderr to be unbuffered for Windows
        cmd = [
            sys.executable, '-uc',
            'import sys; print "stdout"; print >>sys.stderr, "stderr"; sys.stdin.readline();'
        ]
        host = SystemHost()
        factory = PortFactory(host)
        port = factory.get()
        now = time.time()
        proc = server_process.ServerProcess(port, 'python', cmd)
        proc.write('')

        self.assertEqual(proc.poll(), None)
        self.assertFalse(proc.has_crashed())

        # check that doing a read after an expired deadline returns
        # nothing immediately.
        line = proc.read_stdout_line(now - 1)
        self.assertEqual(line, None)

        line = proc.read_stdout_line(now + 1.0)
        self.assertEqual(line.strip(), "stdout")

        line = proc.read_stderr_line(now + 1.0)
        self.assertEqual(line.strip(), "stderr")

        proc.write('End\n')
        time.sleep(0.1)  # Give process a moment to close.
        self.assertEqual(proc.poll(), 0)

        proc.stop(0)
Beispiel #6
0
    def test_basic(self):
        cmd = [
            sys.executable, '-c',
            'import sys; print "stdout"; sys.stdout.flush(); print >>sys.stderr, "stderr"; sys.stdin.readline();'
        ]
        host = SystemHost()
        factory = PortFactory(host)
        port = factory.get()
        now = time.time()
        proc = server_process.ServerProcess(port, 'python', cmd)
        proc.write('')

        if sys.platform.startswith('win'):
            self.assertEqual(proc.poll(), 0)
        else:
            self.assertEqual(proc.poll(), None)
        self.assertFalse(proc.has_crashed())

        # check that doing a read after an expired deadline returns
        # nothing immediately.
        line = proc.read_stdout_line(now - 1)
        self.assertEqual(line, None)

        line = proc.read_stdout_line(now + 1.0)
        self.assertEqual(line.strip(), "stdout")

        line = proc.read_stderr_line(now + 1.0)
        self.assertEqual(line.strip(), "stderr")

        proc.write('End\n')
        proc.stop(0)
Beispiel #7
0
    def clean_args(self):
        if self.user_repo:
            os.environ["FLATPAK_USER_DIR"] = FLATPAK_USER_DIR_PATH + ".Local"
        else:
            os.environ["FLATPAK_USER_DIR"] = os.environ.get(
                "WEBKIT_FLATPAK_USER_DIR", FLATPAK_USER_DIR_PATH)
        self.flatpak_build_path = os.environ["FLATPAK_USER_DIR"]
        try:
            os.makedirs(self.flatpak_build_path)
        except OSError as e:
            pass

        configure_logging(logging.DEBUG if self.verbose else logging.INFO)
        _log.debug("Using flatpak user dir: %s" % self.flatpak_build_path)

        if not self.debug and not self.release:
            factory = PortFactory(SystemHost())
            port = factory.get(self.platform)
            self.debug = port.default_configuration() == "Debug"

        self.build_type = "Debug" if self.debug else "Release"
        self.platform = self.platform.upper()

        if self.gdb is None and '--gdb' in sys.argv:
            self.gdb = True

        self.build_root = os.path.join(self.source_root, 'WebKitBuild')
        self.build_path = os.path.join(self.build_root, self.platform,
                                       self.build_type)
        self.config_file = os.path.join(self.flatpak_build_path,
                                        'webkit_flatpak_config.json')

        Console.quiet = self.quiet
        if not check_flatpak():
            return False

        self._reset_repository()

        try:
            with open(self.config_file) as config:
                json_config = json.load(config)
                self.icc_version = json_config['icecc_version']
        except IOError as e:
            pass

        return True
Beispiel #8
0
    def serial_test_read_after_process_exits(self):
        cmd = [sys.executable, '-uc', 'import sys; print("stdout"); {};'.format(self.stderr_print)]
        host = SystemHost()
        factory = PortFactory(host)
        port = factory.get()
        now = time.time()
        proc = server_process.ServerProcess(port, 'python', cmd)
        proc.write(b'')
        time.sleep(0.1)  # Give process a moment to close.

        line = proc.read_stdout_line(now + 1.0)
        self.assertEqual(line.strip(), b"stdout")

        line = proc.read_stderr_line(now + 1.0)
        self.assertEqual(line.strip(), b"stderr")

        proc.stop(0)
Beispiel #9
0
    def serial_test_process_crashing_no_data(self):
        cmd = [sys.executable, '-uc', 'import sys; sys.stdin.readline(); sys.exit(1);']
        host = SystemHost()
        factory = PortFactory(host)
        port = factory.get()
        now = time.time()
        proc = server_process.ServerProcess(port, 'python', cmd)
        proc.write(b'')

        self.assertEqual(False, proc.has_crashed())

        proc.write(b'End\n')
        time.sleep(0.1)  # Give process a moment to close.

        line = proc.read_stdout_line(now + 1.0)
        self.assertEqual(line, None)

        self.assertEqual(True, proc.has_crashed())

        proc.stop(0)
Beispiel #10
0
    def clean_args(self):
        configure_logging(logging.DEBUG if self.verbose else logging.INFO)
        if not self.debug and not self.release:
            factory = PortFactory(SystemHost())
            port = factory.get(self.platform)
            self.debug = port.default_configuration() == "Debug"
        self.build_type = "Debug" if self.debug else "Release"

        self.platform = self.platform.upper()

        if self.gdb is None and '--gdb' in sys.argv:
            self.gdb = ""

        self.command = "%s %s %s" % (os.path.join(
            self.sandbox_source_root, "Tools/Scripts/run-minibrowser"),
                                     "--" + self.platform.lower(), " --debug"
                                     if self.debug else " --release")

        self.name = "org.webkit.%s" % self.platform
        self.manifest_path = os.path.abspath(
            os.path.join(scriptdir, '../flatpak/org.webkit.WebKit.yaml'))
        self.build_name = self.name + "-generated"

        build_root = os.path.join(self.source_root, 'WebKitBuild')
        self.flatpak_build_path = os.path.join(build_root, self.platform,
                                               "FlatpakTree" + self.build_type)
        self.cache_path = os.path.join(build_root, "FlatpakCache")
        self.build_path = os.path.join(build_root, self.platform,
                                       self.build_type)
        try:
            os.makedirs(self.build_path)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise e

        Console.quiet = self.quiet
        if not check_flatpak():
            return False

        repos = FlatpakRepos()
        self.sdk_repo = repos.add(
            FlatpakRepo(
                "flathub",
                url="https://dl.flathub.org/repo/",
                repo_file="https://dl.flathub.org/repo/flathub.flatpakrepo"))

        manifest = load_manifest(self.manifest_path)
        if not manifest:
            return False

        self.sdk_branch = manifest["runtime-version"]
        self.finish_args = manifest.get("finish-args", [])
        self.finish_args = remove_extension_points(self.finish_args)
        self.runtime = FlatpakPackage("org.gnome.Platform",
                                      self.sdk_branch,
                                      self.sdk_repo,
                                      "x86_64",
                                      hash=manifest.get("runtime-hash"),
                                      assumeyes=self.assumeyes)
        self.locale = FlatpakPackage("org.gnome.Platform.Locale",
                                     self.sdk_branch,
                                     self.sdk_repo,
                                     "x86_64",
                                     assumeyes=self.assumeyes)
        self.sdk = FlatpakPackage("org.gnome.Sdk",
                                  self.sdk_branch,
                                  self.sdk_repo,
                                  "x86_64",
                                  hash=manifest.get("sdk-hash"),
                                  assumeyes=self.assumeyes)
        self.packs = [self.runtime, self.locale, self.sdk]

        if self.debug:
            self.sdk_debug = FlatpakPackage("org.gnome.Sdk.Debug",
                                            self.sdk_branch,
                                            self.sdk_repo,
                                            "x86_64",
                                            assumeyes=self.assumeyes)
            self.packs.append(self.sdk_debug)
        self.manifest_generated_path = os.path.join(self.cache_path,
                                                    self.build_name + ".json")

        return True
Beispiel #11
0
    def clean_args(self):
        os.environ["FLATPAK_USER_DIR"] = os.environ.get("WEBKIT_FLATPAK_USER_DIR", os.path.realpath(os.path.join(scriptdir, "../../WebKitBuild", "UserFlatpak")))
        try:
            os.makedirs(os.environ["FLATPAK_USER_DIR"])
        except OSError as e:
            pass

        configure_logging(logging.DEBUG if self.verbose else logging.INFO)
        _log.debug("Using flatpak user dir: %s" % os.environ["FLATPAK_USER_DIR"])

        if not self.debug and not self.release:
            factory = PortFactory(SystemHost())
            port = factory.get(self.platform)
            self.debug = port.default_configuration() == "Debug"
        self.build_type = "Debug" if self.debug else "Release"

        self.platform = self.platform.upper()

        if self.gdb is None and '--gdb' in sys.argv:
            self.gdb = ""

        self.command = "%s %s %s" % (os.path.join(self.sandbox_source_root,
            "Tools/Scripts/run-minibrowser"),
            "--" + self.platform.lower(),
            " --debug" if self.debug else " --release")

        self.name = "org.webkit.%s" % self.platform

        if self.wpe_extension:
            manifest_filename = WPE_MANIFEST_MAP[self.wpe_extension]
        else:
            manifest_filename = "org.webkit.WebKit.yaml"
        self.manifest_path = os.path.abspath(os.path.join(scriptdir, '../flatpak/') + manifest_filename)

        self.build_name = self.name + "-generated"

        build_root = os.path.join(self.source_root, 'WebKitBuild')
        self.flatpak_build_path = os.path.join(build_root, self.platform, "FlatpakTree" + self.build_type)
        self.cache_path = os.path.join(build_root, "FlatpakCache")
        self.build_path = os.path.join(build_root, self.platform, self.build_type)
        try:
            os.makedirs(self.build_path)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise e
        self.config_file = os.path.join(self.build_path, 'webkit_flatpak_config.json')

        Console.quiet = self.quiet
        if not check_flatpak():
            return False

        repos = FlatpakRepos()
        self.sdk_repo = repos.add(
            FlatpakRepo("flathub",
                        url="https://dl.flathub.org/repo/",
                        repo_file="https://dl.flathub.org/repo/flathub.flatpakrepo"))

        manifest = load_manifest(self.manifest_path, port_name=self.name)
        if not manifest:
            return False

        self.app = manifest['app-id']

        self.sdk_branch = manifest["runtime-version"]
        self.finish_args = manifest.get("finish-args", [])
        self.finish_args = remove_extension_points(self.finish_args)
        self.runtime = FlatpakPackage(manifest['runtime'], self.sdk_branch,
                                      self.sdk_repo, "x86_64",
                                      hash=manifest.get("runtime-hash"))
        self.locale = FlatpakPackage(manifest['runtime'] + '.Locale',
                                     self.sdk_branch, self.sdk_repo, "x86_64")
        self.sdk = FlatpakPackage(manifest['sdk'], self.sdk_branch,
                                  self.sdk_repo, "x86_64",
                                  hash=manifest.get("sdk-hash"))
        self.packs = [self.runtime, self.locale, self.sdk]

        if self.debug:
            self.sdk_debug = FlatpakPackage(manifest['sdk'] + '.Debug', self.sdk_branch,
                                      self.sdk_repo, "x86_64")
            self.packs.append(self.sdk_debug)
        self.manifest_generated_path = os.path.join(self.cache_path,
                                                    self.build_name + ".json")
        try:
            with open(self.config_file) as config:
                json_config = json.load(config)
                self.icc_version = json_config['icecc_version']
        except IOError as e:
            pass

        return True
Beispiel #12
0
    def clean_args(self):
        os.environ["FLATPAK_USER_DIR"] = os.environ.get(
            "WEBKIT_FLATPAK_USER_DIR", FLATPAK_USER_DIR_PATH)
        try:
            os.makedirs(os.environ["FLATPAK_USER_DIR"])
        except OSError as e:
            pass

        configure_logging(logging.DEBUG if self.verbose else logging.INFO)
        _log.debug("Using flatpak user dir: %s" %
                   os.environ["FLATPAK_USER_DIR"])

        if not self.debug and not self.release:
            factory = PortFactory(SystemHost())
            port = factory.get(self.platform)
            self.debug = port.default_configuration() == "Debug"

        self.build_type = "Debug" if self.debug else "Release"

        self.platform = self.platform.upper()

        if self.gdb is None and '--gdb' in sys.argv:
            self.gdb = True

        self.command = "%s %s %s" % (os.path.join(
            self.sandbox_source_root, "Tools/Scripts/run-minibrowser"),
                                     "--" + self.platform.lower(), " --debug"
                                     if self.debug else " --release")

        self.flatpak_build_path = os.environ["FLATPAK_USER_DIR"]

        build_root = os.path.join(self.source_root, 'WebKitBuild')
        self.build_path = os.path.join(build_root, self.platform,
                                       self.build_type)
        try:
            os.makedirs(self.build_path)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise e
        self.config_file = os.path.join(self.flatpak_build_path,
                                        'webkit_flatpak_config.json')

        Console.quiet = self.quiet
        if not check_flatpak():
            return False

        self.finish_args = []
        self.repos = FlatpakRepos()
        self.sdk_repo = self.repos.add(
            FlatpakRepo(
                "webkit-sdk",
                url="https://software.igalia.com/webkit-sdk-repo/",
                repo_file=
                "https://software.igalia.com/flatpak-refs/webkit-sdk.flatpakrepo"
            ))

        try:
            with open(self.config_file) as config:
                json_config = json.load(config)
                self.icc_version = json_config['icecc_version']
        except IOError as e:
            pass

        return True