blob: 90f3971b0927e9614790416e9c843859774960f7 [file] [log] [blame]
Alice Wangf3d96b12022-12-15 13:10:47 +00001package {
2 default_applicable_licenses: ["Android-Apache-2.0"],
3}
4
5rust_defaults {
6 name: "libpvmfw_avb_nostd_defaults",
7 crate_name: "pvmfw_avb",
8 srcs: ["src/lib.rs"],
9 prefer_rlib: true,
Alan Stokesa0e42962023-04-14 17:59:50 +010010 // Require unsafe blocks for inside unsafe functions.
11 flags: ["-Dunsafe_op_in_unsafe_fn"],
Alice Wangf3d96b12022-12-15 13:10:47 +000012 rustlibs: [
Pierre-Clément Tosi69467e02023-02-01 13:35:15 +000013 "libavb_bindgen_nostd",
Alice Wangf2752862023-01-18 11:51:25 +000014 "libtinyvec_nostd",
Alice Wangf3d96b12022-12-15 13:10:47 +000015 ],
Alice Wanga78279c2022-12-16 12:41:19 +000016 whole_static_libs: [
Pierre-Clément Tosi69467e02023-02-01 13:35:15 +000017 "libavb_baremetal",
Alice Wanga78279c2022-12-16 12:41:19 +000018 ],
Alice Wangf3d96b12022-12-15 13:10:47 +000019}
20
21rust_library_rlib {
22 name: "libpvmfw_avb_nostd",
23 defaults: ["libpvmfw_avb_nostd_defaults"],
24 no_stdlibs: true,
25 stdlibs: [
26 "libcore.rust_sysroot",
27 ],
28}
29
30rust_test {
Alice Wangbf7fadd2023-01-13 12:18:24 +000031 name: "libpvmfw_avb.integration_test",
32 crate_name: "pvmfw_avb_test",
Alice Wang2925b0a2023-01-19 10:44:24 +000033 srcs: ["tests/*.rs"],
Alice Wangf3d96b12022-12-15 13:10:47 +000034 test_suites: ["general-tests"],
Alice Wanga78279c2022-12-16 12:41:19 +000035 data: [
36 ":avb_testkey_rsa2048_pub_bin",
37 ":avb_testkey_rsa4096_pub_bin",
38 ":microdroid_kernel_signed",
Alice Wang6b486f12023-01-06 13:12:16 +000039 ":microdroid_initrd_normal",
Alice Wang4e55dd92023-01-11 10:17:01 +000040 ":microdroid_initrd_debuggable",
Alice Wang6b486f12023-01-06 13:12:16 +000041 ":test_image_with_one_hashdesc",
Alice Wang86383df2023-01-11 10:03:56 +000042 ":test_image_with_non_initrd_hashdesc",
Alice Wangf2752862023-01-18 11:51:25 +000043 ":test_image_with_initrd_and_non_initrd_desc",
Alice Wang86383df2023-01-11 10:03:56 +000044 ":test_image_with_prop_desc",
Alice Wanga78279c2022-12-16 12:41:19 +000045 ":unsigned_test_image",
46 ],
Alice Wangbf7fadd2023-01-13 12:18:24 +000047 prefer_rlib: true,
Alice Wanga78279c2022-12-16 12:41:19 +000048 rustlibs: [
49 "libanyhow",
Alice Wangbf7fadd2023-01-13 12:18:24 +000050 "libavb_bindgen",
Alice Wang1f0add02023-01-23 16:22:53 +000051 "libhex",
Alice Wangbf7fadd2023-01-13 12:18:24 +000052 "libpvmfw_avb_nostd",
Alice Wang1f0add02023-01-23 16:22:53 +000053 "libopenssl",
Alice Wanga78279c2022-12-16 12:41:19 +000054 ],
55 enabled: false,
56 arch: {
57 // Microdroid kernel is only available in these architectures.
58 arm64: {
59 enabled: true,
60 },
61 x86_64: {
62 enabled: true,
63 },
64 },
65}
66
67// Generates a 16KB unsigned image for testing.
68genrule {
69 name: "unsigned_test_image",
70 tools: ["avbtool"],
71 out: ["unsigned_test.img"],
72 cmd: "$(location avbtool) generate_test_image --image_size 16384 --output $(out)",
Alice Wangf3d96b12022-12-15 13:10:47 +000073}
Alice Wang6b486f12023-01-06 13:12:16 +000074
Alice Wang86383df2023-01-11 10:03:56 +000075avb_gen_vbmeta_image {
76 name: "test_non_initrd_hashdesc",
77 src: ":unsigned_test_image",
78 partition_name: "non_initrd11",
79 salt: "2222",
80}
81
82avb_add_hash_footer {
83 name: "test_image_with_non_initrd_hashdesc",
84 src: ":unsigned_test_image",
85 partition_name: "boot",
86 private_key: ":pvmfw_sign_key",
Alice Wangf2752862023-01-18 11:51:25 +000087 salt: "3322",
Alice Wang86383df2023-01-11 10:03:56 +000088 include_descriptors_from_images: [
89 ":test_non_initrd_hashdesc",
90 ],
91}
92
93avb_add_hash_footer {
Alice Wangf2752862023-01-18 11:51:25 +000094 name: "test_image_with_initrd_and_non_initrd_desc",
95 src: ":unsigned_test_image",
96 partition_name: "boot",
97 private_key: ":pvmfw_sign_key",
98 salt: "3241",
99 include_descriptors_from_images: [
100 ":microdroid_initrd_normal_hashdesc",
101 ":test_non_initrd_hashdesc",
102 ],
103 enabled: false,
104 arch: {
105 // microdroid_initrd_normal_hashdesc is only available in these architectures.
106 arm64: {
107 enabled: true,
108 },
109 x86_64: {
110 enabled: true,
111 },
112 },
113}
114
115avb_add_hash_footer {
Alice Wang86383df2023-01-11 10:03:56 +0000116 name: "test_image_with_prop_desc",
117 src: ":unsigned_test_image",
118 partition_name: "boot",
119 private_key: ":pvmfw_sign_key",
Alice Wangf2752862023-01-18 11:51:25 +0000120 salt: "2134",
Alice Wang86383df2023-01-11 10:03:56 +0000121 props: [
122 {
123 name: "mock_prop",
124 value: "3333",
125 },
126 ],
127}
128
Alice Wang6b486f12023-01-06 13:12:16 +0000129avb_add_hash_footer {
130 name: "test_image_with_one_hashdesc",
131 src: ":unsigned_test_image",
Alice Wang8aa3cb12023-01-11 09:04:04 +0000132 partition_name: "boot",
Alice Wang6b486f12023-01-06 13:12:16 +0000133 private_key: ":pvmfw_sign_key",
134 salt: "1111",
135}