Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions native/packaging/BundleMachOTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ def setUp(self):
self.tool = self.prefix / "bin/kalandra-check"
self.original = digest(checker)
shutil.copy2(checker, self.tool)
self.load = next(load for load in inspect(checker)[0] if "libLLVM" in load)
self.llvm_loads = [
load for load in inspect(checker)[0]
if not load.startswith(("/usr/lib/", "/System/Library/"))
and Path(load).is_file() and Path(load).resolve().is_relative_to(llvm)
]
self.load = next(load for load in self.llvm_loads if "libLLVM" in load)

def tearDown(self):
self.assertEqual(digest(checker), self.original, "modified the original build binary")
Expand Down Expand Up @@ -56,9 +61,13 @@ def test_basename_collision(self):
library = fake / folder / "collision.dylib"
library.parent.mkdir()
shutil.copy2(checker, library)
for load in self.llvm_loads:
run("/usr/bin/install_name_tool", "-change", load, "/usr/lib/libSystem.B.dylib", library)
libraries.append(library)
run("/usr/bin/install_name_tool", "-change", self.load, libraries[0],
"-change", "/usr/lib/libc++.1.dylib", libraries[1], self.tool)
for load in self.llvm_loads:
target = libraries[0] if load == self.load else "/usr/lib/libSystem.B.dylib"
run("/usr/bin/install_name_tool", "-change", load, target, self.tool)
run("/usr/bin/install_name_tool", "-change", "/usr/lib/libc++.1.dylib", libraries[1], self.tool)
with self.assertRaisesRegex(RuntimeError, "basename collision"):
bundle(self.prefix, fake)

Expand Down
Loading