#!/usr/bin/env python # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. import os, tempfile, unittest, shutil, struct, platform, subprocess import mock from mock import patch import symbolstore # Some simple functions to mock out files that the platform-specific dumpers will accept. # dump_syms itself will not be run (we mock that call out), but we can't override # the ShouldProcessFile method since we actually want to test that. def write_elf(filename): open(filename, "wb").write(struct.pack("<7B45x", 0x7f, ord("E"), ord("L"), ord("F"), 1, 1, 1)) def write_macho(filename): open(filename, "wb").write(struct.pack(" """) # Use a source file from each of the three projects file1 = os.path.join(self.test_dir, "projects", "one", "src1.c") file2 = os.path.join(self.test_dir, "projects", "another", "src2.c") file3 = os.path.join(self.test_dir, "something_else", "src3.c") d = symbolstore.Dumper("dump_syms", "symbol_path", repo_manifest=manifest) self.assertEqual("git:example.com/bar/projects/one:src1.c:abcd1234", symbolstore.GetVCSFilename(file1, d.srcdirs)[0]) self.assertEqual("git:example.com/foo/projects/two:src2.c:ffffffff", symbolstore.GetVCSFilename(file2, d.srcdirs)[0]) self.assertEqual("git:example.com/bar/something_else:src3.c:00000000", symbolstore.GetVCSFilename(file3, d.srcdirs)[0]) if __name__ == '__main__': unittest.main()