1load("@bazel_skylib//rules:diff_test.bzl", "diff_test") 2 3def image_contents_test( 4 name, 5 image, 6 path, 7 expected, 8 target_compatible_with = None, 9 tags = []): 10 """A test that extracts a file from a disk image file, and then asserts that it's identical to some other file.""" 11 12 extracted_path = name + path.replace("/", "_") + "_extracted.bin" 13 14 native.genrule( 15 name = name + "_extracted", 16 tools = [ 17 "//external/e2fsprogs/debugfs:debugfs", 18 ], 19 srcs = [image], 20 outs = [extracted_path], 21 cmd = "$(location //external/e2fsprogs/debugfs:debugfs) -R 'dump " + path + " $@' $<", 22 tags = ["manual"], 23 ) 24 25 diff_test( 26 name = name, 27 file1 = extracted_path, 28 file2 = expected, 29 target_compatible_with = target_compatible_with, 30 tags = tags, 31 ) 32