Ejemplo n.º 1
0
 def test_copy_debug_universal(self):
     """
     Test that dumping symbols for multiple architectures only copies debug symbols once
     per file.
     """
     copied = []
     def mock_copy_debug(filename, debug_file, guid, code_file, code_id):
         copied.append(filename[len(self.symbol_dir):] if filename.startswith(self.symbol_dir) else filename)
     self.add_test_files(add_extension(["foo"]))
     # Windows doesn't call file(1) to figure out if the file should be processed.
     if target_platform() != 'WINNT':
         self.stdouts.append(file_output)
     self.stdouts.append(mock_dump_syms("X" * 33, add_extension(["foo"])[0]))
     self.stdouts.append(mock_dump_syms("Y" * 33, add_extension(["foo"])[0]))
     def mock_dsymutil(args, **kwargs):
         filename = args[-1]
         os.makedirs(filename + ".dSYM")
         return 0
     self.mock_call.side_effect = mock_dsymutil
     d = symbolstore.GetPlatformSpecificDumper(dump_syms="dump_syms",
                                               symbol_path=self.symbol_dir,
                                               copy_debug=True,
                                               archs="abc xyz")
     d.CopyDebug = mock_copy_debug
     d.Process(os.path.join(self.test_dir, add_extension(["foo"])[0]))
     self.assertEqual(1, len(copied))
Ejemplo n.º 2
0
    def test_size_order(self):
        """
        Test that files are processed ordered by size on disk.
        """
        processed = []

        def mock_process_file(filenames):
            for filename in filenames:
                processed.append(
                    (filename[len(self.test_dir):] if filename.startswith(
                        self.test_dir) else filename).replace('\\', '/'))
            return True

        for f, size in (('a/one', 10), ('b/c/two', 30), ('c/three', 20)):
            f = os.path.join(self.test_dir, f)
            d = os.path.dirname(f)
            if d and not os.path.exists(d):
                os.makedirs(d)
            open(f, 'wb').write('x' * size)
        d = symbolstore.GetPlatformSpecificDumper(dump_syms="dump_syms",
                                                  symbol_path="symbol_path")
        d.ShouldProcess = lambda f: True
        d.ProcessFiles = mock_process_file
        d.Process(self.test_dir)
        d.Finish(stop_pool=False)
        self.assertEqual(processed, ['b/c/two', 'c/three', 'a/one'])
Ejemplo n.º 3
0
    def test_exclude_filenames(self):
        """
        Test that excluding a filename without a wildcard works.
        """
        processed = []

        def mock_process_file(filenames):
            for filename in filenames:
                processed.append(
                    (filename[len(self.test_dir):] if filename.startswith(
                        self.test_dir) else filename).replace('\\', '/'))
            return True

        self.add_test_files(
            add_extension(
                ["foo", "bar", "abc/foo", "abc/bar", "def/foo", "def/bar"]))
        d = symbolstore.GetPlatformSpecificDumper(dump_syms="dump_syms",
                                                  symbol_path="symbol_path",
                                                  exclude=add_extension(
                                                      ["foo"]))
        d.ProcessFiles = mock_process_file
        d.Process(self.test_dir)
        d.Finish(stop_pool=False)
        processed.sort()
        expected = add_extension(["bar", "abc/bar", "def/bar"])
        expected.sort()
        self.assertEqual(processed, expected)
Ejemplo n.º 4
0
    def test_exclude_wildcard(self):
        """
        Test that using an exclude list with a wildcard pattern works.
        """
        processed = []

        def mock_process_file(filename):
            processed.append(
                (filename[len(self.test_dir):] if filename.startswith(
                    self.test_dir) else filename).replace('\\', '/'))
            return True

        self.add_test_files(
            add_extension([
                "foo", "bar", "abc/xyz", "abc/fooxyz", "def/asdf", "def/xyzfoo"
            ]))
        d = symbolstore.GetPlatformSpecificDumper(dump_syms="dump_syms",
                                                  symbol_path="symbol_path",
                                                  exclude=["*foo*"])
        d.ProcessFile = mock_process_file
        self.assertTrue(d.Process(self.test_dir))
        processed.sort()
        expected = add_extension(["bar", "abc/xyz", "def/asdf"])
        expected.sort()
        self.assertEqual(processed, expected)
Ejemplo n.º 5
0
        def test_HGSERVER(self, mock_Popen, mock_call):
            """
            Test that HGSERVER gets set correctly in the source server index.
            """
            symbolpath = os.path.join(self.test_dir, "symbols")
            os.makedirs(symbolpath)
            srcdir = os.path.join(self.test_dir, "srcdir")
            os.makedirs(os.path.join(srcdir, ".hg"))
            sourcefile = os.path.join(srcdir, "foo.c")
            test_files = add_extension(["foo"])
            self.add_test_files(test_files)
            # mock calls to `dump_syms`, `hg parent` and
            # `hg showconfig paths.default`
            mock_Popen.return_value.stdout = iter(
                [
                    "MODULE os x86 %s %s" % ("X" * 33, test_files[0]),
                    "FILE 0 %s" % sourcefile,
                    "PUBLIC xyz 123",
                ]
            )
            mock_Popen.return_value.wait.return_value = 0
            mock_communicate = mock_Popen.return_value.communicate
            mock_communicate.side_effect = [
                ("abcd1234", ""),
                ("http://example.com/repo", ""),
            ]
            # And mock the call to pdbstr to capture the srcsrv stream data.
            global srcsrv_stream
            srcsrv_stream = None

            def mock_pdbstr(args, cwd="", **kwargs):
                for arg in args:
                    if arg.startswith("-i:"):
                        global srcsrv_stream
                        srcsrv_stream = open(os.path.join(cwd, arg[3:]), "r").read()
                return 0

            mock_call.side_effect = mock_pdbstr
            d = symbolstore.GetPlatformSpecificDumper(
                dump_syms="dump_syms",
                symbol_path=symbolpath,
                srcdirs=[srcdir],
                vcsinfo=True,
                srcsrv=True,
                copy_debug=True,
            )
            # stub out CopyDebug
            d.CopyDebug = lambda *args: True
            d.Process(os.path.join(self.test_dir, test_files[0]))
            self.assertNotEqual(srcsrv_stream, None)
            hgserver = [
                x.rstrip()
                for x in srcsrv_stream.splitlines()
                if x.startswith("HGSERVER=")
            ]
            self.assertEqual(len(hgserver), 1)
            self.assertEqual(hgserver[0].split("=")[1], "http://example.com/repo")
Ejemplo n.º 6
0
 def test_copy_debug_universal(self):
     """
     Test that dumping symbols for multiple architectures only copies debug symbols once
     per file.
     """
     copied = []
     def mock_copy_debug(filename, debug_file, guid):
         copied.append(filename[len(self.symbol_dir):] if filename.startswith(self.symbol_dir) else filename)
     self.add_test_files(add_extension(["foo"]))
     self.stdouts.append(mock_dump_syms("X" * 33, add_extension(["foo"])[0]))
     self.stdouts.append(mock_dump_syms("Y" * 33, add_extension(["foo"])[0]))
     d = symbolstore.GetPlatformSpecificDumper(dump_syms="dump_syms",
                                               symbol_path=self.symbol_dir,
                                               copy_debug=True,
                                               archs="abc xyz")
     d.CopyDebug = mock_copy_debug
     d.Process(self.test_dir)
     d.Finish(stop_pool=False)
     self.assertEqual(1, len(copied))