import os
import KernelCollection
def check(kernel_cache):
kernel_cache.buildKernelCollection("x86_64", "/kmod-info-errors/main.kc", "/kmod-info-errors/main.kernel", "/kmod-info-errors/extensions", ["com.apple.foo", "com.apple.bar"], ["-json-errors"])
assert len(kernel_cache.dictionary()) == 2
assert kernel_cache.dictionary()[0]["id"] == "com.apple.bar"
assert len(kernel_cache.dictionary()[0]["errors"]) == 1
assert kernel_cache.dictionary()[0]["errors"][0] == "unsupported kmod_info version of 2"
assert kernel_cache.dictionary()[1]["id"] == "com.apple.foo"
assert len(kernel_cache.dictionary()[1]["errors"]) == 1
assert kernel_cache.dictionary()[1]["errors"][0] == "unsupported kmod_info version of 2"