import os
import KernelCollection
def check(kernel_cache):
kernel_cache.buildKernelCollection("arm64", "/strip-all-kexts/main.kc", "/strip-all-kexts/main.kernel", "/strip-all-kexts/extensions", ["com.apple.foo", "com.apple.bar"], ["-strip-all-kexts"])
kernel_cache.analyze("/strip-all-kexts/main.kc", ["-layout", "-arch", "arm64"])
kernel_cache.analyze("/strip-all-kexts/main.kc", ["-symbols", "-arch", "arm64"])
assert len(kernel_cache.dictionary()["dylibs"]) == 3
assert kernel_cache.dictionary()["dylibs"][0]["name"] == "com.apple.kernel"
assert len(kernel_cache.dictionary()["dylibs"][0]["global-symbols"]) == 2
assert kernel_cache.dictionary()["dylibs"][0]["global-symbols"][0]["name"] == "__mh_execute_header"
assert kernel_cache.dictionary()["dylibs"][0]["global-symbols"][1]["name"] == "__start"
assert kernel_cache.dictionary()["dylibs"][0]["local-symbols"] == "none"
assert kernel_cache.dictionary()["dylibs"][1]["name"] == "com.apple.bar"
assert kernel_cache.dictionary()["dylibs"][1]["global-symbols"] == "none"
assert kernel_cache.dictionary()["dylibs"][1]["local-symbols"] == "none"
assert kernel_cache.dictionary()["dylibs"][2]["name"] == "com.apple.foo"
assert kernel_cache.dictionary()["dylibs"][2]["global-symbols"] == "none"
assert kernel_cache.dictionary()["dylibs"][2]["local-symbols"] == "none"