xref: /aosp_15_r20/build/bazel/rules/partitions/diff/partition_diff.bzl (revision 7594170e27e0732bc44b93d1440d87a54b6ffe7c)
1*7594170eSAndroid Build Coastguard Worker# Copyright (C) 2023 The Android Open Source Project
2*7594170eSAndroid Build Coastguard Worker#
3*7594170eSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
4*7594170eSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
5*7594170eSAndroid Build Coastguard Worker# You may obtain a copy of the License at
6*7594170eSAndroid Build Coastguard Worker#
7*7594170eSAndroid Build Coastguard Worker#     http://www.apache.org/licenses/LICENSE-2.0
8*7594170eSAndroid Build Coastguard Worker#
9*7594170eSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
10*7594170eSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
11*7594170eSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*7594170eSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
13*7594170eSAndroid Build Coastguard Worker# limitations under the License.
14*7594170eSAndroid Build Coastguard Worker
15*7594170eSAndroid Build Coastguard Workerload("@bazel_skylib//rules:diff_test.bzl", "diff_test")
16*7594170eSAndroid Build Coastguard Worker
17*7594170eSAndroid Build Coastguard Workerdef partition_diff_test(
18*7594170eSAndroid Build Coastguard Worker        *,
19*7594170eSAndroid Build Coastguard Worker        name,
20*7594170eSAndroid Build Coastguard Worker        partition1,
21*7594170eSAndroid Build Coastguard Worker        partition2):
22*7594170eSAndroid Build Coastguard Worker    """A test that compares the contents of two paritions."""
23*7594170eSAndroid Build Coastguard Worker
24*7594170eSAndroid Build Coastguard Worker    native.genrule(
25*7594170eSAndroid Build Coastguard Worker        name = name + "_1_genrule",
26*7594170eSAndroid Build Coastguard Worker        tools = [
27*7594170eSAndroid Build Coastguard Worker            "//build/bazel/rules/partitions/diff:partition_inspector",
28*7594170eSAndroid Build Coastguard Worker            "//external/e2fsprogs/debugfs:debugfs",
29*7594170eSAndroid Build Coastguard Worker        ],
30*7594170eSAndroid Build Coastguard Worker        srcs = [partition1],
31*7594170eSAndroid Build Coastguard Worker        outs = [name + "_1.txt"],
32*7594170eSAndroid Build Coastguard Worker        cmd = "$(location //build/bazel/rules/partitions/diff:partition_inspector) --debugfs-path=$(location //external/e2fsprogs/debugfs:debugfs) $< > $@",
33*7594170eSAndroid Build Coastguard Worker    )
34*7594170eSAndroid Build Coastguard Worker
35*7594170eSAndroid Build Coastguard Worker    native.genrule(
36*7594170eSAndroid Build Coastguard Worker        name = name + "_2_genrule",
37*7594170eSAndroid Build Coastguard Worker        tools = [
38*7594170eSAndroid Build Coastguard Worker            "//build/bazel/rules/partitions/diff:partition_inspector",
39*7594170eSAndroid Build Coastguard Worker            "//external/e2fsprogs/debugfs:debugfs",
40*7594170eSAndroid Build Coastguard Worker        ],
41*7594170eSAndroid Build Coastguard Worker        srcs = [partition2],
42*7594170eSAndroid Build Coastguard Worker        outs = [name + "_2.txt"],
43*7594170eSAndroid Build Coastguard Worker        cmd = "$(location //build/bazel/rules/partitions/diff:partition_inspector) --debugfs-path=$(location //external/e2fsprogs/debugfs:debugfs) $< > $@",
44*7594170eSAndroid Build Coastguard Worker    )
45*7594170eSAndroid Build Coastguard Worker
46*7594170eSAndroid Build Coastguard Worker    diff_test(
47*7594170eSAndroid Build Coastguard Worker        name = name,
48*7594170eSAndroid Build Coastguard Worker        file1 = name + "_1.txt",
49*7594170eSAndroid Build Coastguard Worker        file2 = name + "_2.txt",
50*7594170eSAndroid Build Coastguard Worker    )
51