• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (C) 2024 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package {
16    default_applicable_licenses: [
17        "Android-Apache-2.0",
18        "system_sepolicy_license",
19    ],
20}
21
22//////////////////////////////////
23// Tests for Treble compatibility of current platform policy and vendor policy of
24// given release version.
25//////////////////////////////////
26java_genrule {
27    name: "29.0_mapping.combined.cil",
28    srcs: [
29        ":plat_29.0.cil",
30        ":29.0.ignore.cil",
31    ],
32    out: ["29.0_mapping.combined.cil"],
33    cmd: "cat $(location :plat_29.0.cil) $(location :29.0.ignore.cil) > $(out)",
34}
35
36java_genrule {
37    name: "treble_sepolicy_tests_29.0",
38    srcs: [
39        ":29.0_plat_pub_policy.cil",
40        ":29.0_mapping.combined.cil",
41        ":base_plat_pub_policy.cil",
42    ],
43    tools: ["treble_sepolicy_tests"],
44    out: ["treble_sepolicy_tests_29.0"],
45    cmd: "$(location treble_sepolicy_tests) " +
46        "-b $(location :base_plat_pub_policy.cil) " +
47        "-m $(location :29.0_mapping.combined.cil) " +
48        "-o $(location :29.0_plat_pub_policy.cil) && " +
49        "touch $(out)",
50}
51
52java_genrule {
53    name: "30.0_mapping.combined.cil",
54    srcs: [
55        ":plat_30.0.cil",
56        ":30.0.ignore.cil",
57    ] + select(soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"), {
58        true: [
59            ":system_ext_30.0.cil",
60            ":system_ext_30.0.ignore.cil",
61        ],
62        default: [],
63    }) + select(soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"), {
64        true: [
65            ":product_30.0.cil",
66            ":product_30.0.ignore.cil",
67        ],
68        default: [],
69    }),
70    out: ["30.0_mapping.combined.cil"],
71    cmd: "cat $(location :plat_30.0.cil) " +
72        "$(location :30.0.ignore.cil) " +
73        select(soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"), {
74            true: "$(location :system_ext_30.0.cil) " +
75                "$(location :system_ext_30.0.ignore.cil) ",
76            default: "",
77        }) +
78        select(soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"), {
79            true: "$(location :product_30.0.cil) " +
80                "$(location :product_30.0.ignore.cil) ",
81            default: "",
82        }) +
83        "> $(out)",
84}
85
86java_genrule {
87    name: "treble_sepolicy_tests_30.0",
88    srcs: [
89        ":30.0_plat_pub_policy.cil",
90        ":30.0_mapping.combined.cil",
91    ] + select((
92        soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"),
93        soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"),
94    ), {
95        (false, false): [":base_plat_pub_policy.cil"],
96        (default, default): [":base_product_pub_policy.cil"],
97    }),
98    tools: ["treble_sepolicy_tests"],
99    out: ["treble_sepolicy_tests_30.0"],
100    cmd: select((
101        soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"),
102        soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"),
103    ), {
104        (false, false): "$(location treble_sepolicy_tests) " +
105            "-b $(location :base_plat_pub_policy.cil) " +
106            "-m $(location :30.0_mapping.combined.cil) " +
107            "-o $(location :30.0_plat_pub_policy.cil) && " +
108            "touch $(out)",
109        (default, default): "$(location treble_sepolicy_tests) " +
110            "-b $(location :base_product_pub_policy.cil) " +
111            "-m $(location :30.0_mapping.combined.cil) " +
112            "-o $(location :30.0_plat_pub_policy.cil) && " +
113            "touch $(out)",
114    }),
115}
116
117java_genrule {
118    name: "31.0_mapping.combined.cil",
119    srcs: [
120        ":plat_31.0.cil",
121        ":31.0.ignore.cil",
122    ] + select(soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"), {
123        true: [
124            ":system_ext_31.0.cil",
125            ":system_ext_31.0.ignore.cil",
126        ],
127        default: [],
128    }) + select(soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"), {
129        true: [
130            ":product_31.0.cil",
131            ":product_31.0.ignore.cil",
132        ],
133        default: [],
134    }),
135    out: ["31.0_mapping.combined.cil"],
136    cmd: "cat $(location :plat_31.0.cil) " +
137        "$(location :31.0.ignore.cil) " +
138        select(soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"), {
139            true: "$(location :system_ext_31.0.cil) " +
140                "$(location :system_ext_31.0.ignore.cil) ",
141            default: "",
142        }) +
143        select(soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"), {
144            true: "$(location :product_31.0.cil) " +
145                "$(location :product_31.0.ignore.cil) ",
146            default: "",
147        }) +
148        "> $(out)",
149}
150
151java_genrule {
152    name: "treble_sepolicy_tests_31.0",
153    srcs: [
154        ":31.0_plat_pub_policy.cil",
155        ":31.0_mapping.combined.cil",
156    ] + select((
157        soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"),
158        soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"),
159    ), {
160        (false, false): [":base_plat_pub_policy.cil"],
161        (default, default): [":base_product_pub_policy.cil"],
162    }),
163    tools: ["treble_sepolicy_tests"],
164    out: ["treble_sepolicy_tests_31.0"],
165    cmd: select((
166        soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"),
167        soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"),
168    ), {
169        (false, false): "$(location treble_sepolicy_tests) " +
170            "-b $(location :base_plat_pub_policy.cil) " +
171            "-m $(location :31.0_mapping.combined.cil) " +
172            "-o $(location :31.0_plat_pub_policy.cil) && " +
173            "touch $(out)",
174        (default, default): "$(location treble_sepolicy_tests) " +
175            "-b $(location :base_product_pub_policy.cil) " +
176            "-m $(location :31.0_mapping.combined.cil) " +
177            "-o $(location :31.0_plat_pub_policy.cil) && " +
178            "touch $(out)",
179    }),
180}
181
182java_genrule {
183    name: "32.0_mapping.combined.cil",
184    srcs: [
185        ":plat_32.0.cil",
186        ":32.0.ignore.cil",
187    ] + select(soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"), {
188        true: [
189            ":system_ext_32.0.cil",
190            ":system_ext_32.0.ignore.cil",
191        ],
192        default: [],
193    }) + select(soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"), {
194        true: [
195            ":product_32.0.cil",
196            ":product_32.0.ignore.cil",
197        ],
198        default: [],
199    }),
200    out: ["32.0_mapping.combined.cil"],
201    cmd: "cat $(location :plat_32.0.cil) " +
202        "$(location :32.0.ignore.cil) " +
203        select(soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"), {
204            true: "$(location :system_ext_32.0.cil) " +
205                "$(location :system_ext_32.0.ignore.cil) ",
206            default: "",
207        }) +
208        select(soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"), {
209            true: "$(location :product_32.0.cil) " +
210                "$(location :product_32.0.ignore.cil) ",
211            default: "",
212        }) +
213        "> $(out)",
214}
215
216java_genrule {
217    name: "treble_sepolicy_tests_32.0",
218    srcs: [
219        ":32.0_plat_pub_policy.cil",
220        ":32.0_mapping.combined.cil",
221    ] + select((
222        soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"),
223        soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"),
224    ), {
225        (false, false): [":base_plat_pub_policy.cil"],
226        (default, default): [":base_product_pub_policy.cil"],
227    }),
228    tools: ["treble_sepolicy_tests"],
229    out: ["treble_sepolicy_tests_32.0"],
230    cmd: select((
231        soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"),
232        soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"),
233    ), {
234        (false, false): "$(location treble_sepolicy_tests) " +
235            "-b $(location :base_plat_pub_policy.cil) " +
236            "-m $(location :32.0_mapping.combined.cil) " +
237            "-o $(location :32.0_plat_pub_policy.cil) && " +
238            "touch $(out)",
239        (default, default): "$(location treble_sepolicy_tests) " +
240            "-b $(location :base_product_pub_policy.cil) " +
241            "-m $(location :32.0_mapping.combined.cil) " +
242            "-o $(location :32.0_plat_pub_policy.cil) && " +
243            "touch $(out)",
244    }),
245}
246
247java_genrule {
248    name: "33.0_mapping.combined.cil",
249    srcs: [
250        ":plat_33.0.cil",
251        ":33.0.ignore.cil",
252    ] + select(soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"), {
253        true: [
254            ":system_ext_33.0.cil",
255            ":system_ext_33.0.ignore.cil",
256        ],
257        default: [],
258    }) + select(soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"), {
259        true: [
260            ":product_33.0.cil",
261            ":product_33.0.ignore.cil",
262        ],
263        default: [],
264    }),
265    out: ["33.0_mapping.combined.cil"],
266    cmd: "cat $(location :plat_33.0.cil) " +
267        "$(location :33.0.ignore.cil) " +
268        select(soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"), {
269            true: "$(location :system_ext_33.0.cil) " +
270                "$(location :system_ext_33.0.ignore.cil) ",
271            default: "",
272        }) +
273        select(soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"), {
274            true: "$(location :product_33.0.cil) " +
275                "$(location :product_33.0.ignore.cil) ",
276            default: "",
277        }) +
278        "> $(out)",
279}
280
281java_genrule {
282    name: "treble_sepolicy_tests_33.0",
283    srcs: [
284        ":33.0_plat_pub_policy.cil",
285        ":33.0_mapping.combined.cil",
286    ] + select((
287        soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"),
288        soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"),
289    ), {
290        (false, false): [":base_plat_pub_policy.cil"],
291        (default, default): [":base_product_pub_policy.cil"],
292    }),
293    tools: ["treble_sepolicy_tests"],
294    out: ["treble_sepolicy_tests_33.0"],
295    cmd: select((
296        soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"),
297        soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"),
298    ), {
299        (false, false): "$(location treble_sepolicy_tests) " +
300            "-b $(location :base_plat_pub_policy.cil) " +
301            "-m $(location :33.0_mapping.combined.cil) " +
302            "-o $(location :33.0_plat_pub_policy.cil) && " +
303            "touch $(out)",
304        (default, default): "$(location treble_sepolicy_tests) " +
305            "-b $(location :base_product_pub_policy.cil) " +
306            "-m $(location :33.0_mapping.combined.cil) " +
307            "-o $(location :33.0_plat_pub_policy.cil) && " +
308            "touch $(out)",
309    }),
310}
311
312java_genrule {
313    name: "34.0_mapping.combined.cil",
314    srcs: [
315        ":plat_34.0.cil",
316        ":34.0.ignore.cil",
317    ] + select(soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"), {
318        true: [
319            ":system_ext_34.0.cil",
320            ":system_ext_34.0.ignore.cil",
321        ],
322        default: [],
323    }) + select(soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"), {
324        true: [
325            ":product_34.0.cil",
326            ":product_34.0.ignore.cil",
327        ],
328        default: [],
329    }),
330    out: ["34.0_mapping.combined.cil"],
331    cmd: "cat $(location :plat_34.0.cil) " +
332        "$(location :34.0.ignore.cil) " +
333        select(soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"), {
334            true: "$(location :system_ext_34.0.cil) " +
335                "$(location :system_ext_34.0.ignore.cil) ",
336            default: "",
337        }) +
338        select(soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"), {
339            true: "$(location :product_34.0.cil) " +
340                "$(location :product_34.0.ignore.cil) ",
341            default: "",
342        }) +
343        "> $(out)",
344}
345
346java_genrule {
347    name: "treble_sepolicy_tests_34.0",
348    srcs: [
349        ":34.0_plat_pub_policy.cil",
350        ":34.0_mapping.combined.cil",
351    ] + select((
352        soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"),
353        soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"),
354    ), {
355        (false, false): [":base_plat_pub_policy.cil"],
356        (default, default): [":base_product_pub_policy.cil"],
357    }),
358    tools: ["treble_sepolicy_tests"],
359    out: ["treble_sepolicy_tests_34.0"],
360    cmd: select((
361        soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"),
362        soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"),
363    ), {
364        (false, false): "$(location treble_sepolicy_tests) " +
365            "-b $(location :base_plat_pub_policy.cil) " +
366            "-m $(location :34.0_mapping.combined.cil) " +
367            "-o $(location :34.0_plat_pub_policy.cil) && " +
368            "touch $(out)",
369        (default, default): "$(location treble_sepolicy_tests) " +
370            "-b $(location :base_product_pub_policy.cil) " +
371            "-m $(location :34.0_mapping.combined.cil) " +
372            "-o $(location :34.0_plat_pub_policy.cil) && " +
373            "touch $(out)",
374    }),
375}
376
377// TODO(b/391513934): clean up once we can simplify complex select statements.
378java_genrule {
379    name: "202404_mapping.combined.cil",
380    srcs: select(soong_config_variable("ANDROID", "PLATFORM_SEPOLICY_VERSION"), {
381        "202404": [
382        ],
383        default: [
384            ":plat_202404.cil",
385            ":202404.ignore.cil",
386        ],
387    }) + select((
388        soong_config_variable("ANDROID", "PLATFORM_SEPOLICY_VERSION"),
389        soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"),
390    ), {
391        ("202404", true): [],
392        ("202404", default): [],
393        (default, true): [
394            ":system_ext_202404.cil",
395            ":system_ext_202404.ignore.cil",
396        ],
397        (default, default): [],
398    }) + select((
399        soong_config_variable("ANDROID", "PLATFORM_SEPOLICY_VERSION"),
400        soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"),
401    ), {
402        ("202404", true): [],
403        ("202404", default): [],
404        (default, true): [
405            ":product_202404.cil",
406            ":product_202404.ignore.cil",
407        ],
408        (default, default): [],
409    }),
410    out: ["202404_mapping.combined.cil"],
411    cmd: select(soong_config_variable("ANDROID", "PLATFORM_SEPOLICY_VERSION"), {
412        "202404": "touch $(out)",
413        default: "cat $(in) > $(out)",
414    }),
415}
416
417// TODO(b/391513934): clean up once we can simplify complex select statements.
418java_genrule {
419    name: "treble_sepolicy_tests_202404",
420    srcs: [
421        ":202404_plat_pub_policy.cil",
422        ":202404_mapping.combined.cil",
423    ] + select((
424        soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"),
425        soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"),
426    ), {
427        (false, false): [":base_plat_pub_policy.cil"],
428        (default, default): [":base_product_pub_policy.cil"],
429    }),
430    tools: ["treble_sepolicy_tests"],
431    out: ["treble_sepolicy_tests_202404"],
432    cmd: select((
433        soong_config_variable("ANDROID", "PLATFORM_SEPOLICY_VERSION"),
434        soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"),
435        soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"),
436    ), {
437        ("202404", false, false): "touch $(out)",
438        ("202404", default, default): "touch $(out)",
439        (default, false, false): "$(location treble_sepolicy_tests) " +
440            "-b $(location :base_plat_pub_policy.cil) " +
441            "-m $(location :202404_mapping.combined.cil) " +
442            "-o $(location :202404_plat_pub_policy.cil) && " +
443            "touch $(out)",
444        (default, default, default): "$(location treble_sepolicy_tests) " +
445            "-b $(location :base_product_pub_policy.cil) " +
446            "-m $(location :202404_mapping.combined.cil) " +
447            "-o $(location :202404_plat_pub_policy.cil) && " +
448            "touch $(out)",
449    }),
450}
451
452// TODO(b/391513934): clean up once we can simplify complex select statements.
453java_genrule {
454    name: "202504_mapping.combined.cil",
455    srcs: select(soong_config_variable("ANDROID", "PLATFORM_SEPOLICY_VERSION"), {
456        "202404": [],
457        "202504": [],
458        default: [
459            ":plat_202504.cil",
460            ":202504.ignore.cil",
461        ],
462    }) + select((
463        soong_config_variable("ANDROID", "PLATFORM_SEPOLICY_VERSION"),
464        soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"),
465    ), {
466        ("202404", default): [],
467        ("202504", default): [],
468        (default, true): [
469            ":system_ext_202504.cil",
470            ":system_ext_202504.ignore.cil",
471        ],
472        (default, default): [],
473    }) + select((
474        soong_config_variable("ANDROID", "PLATFORM_SEPOLICY_VERSION"),
475        soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"),
476    ), {
477        ("202404", default): [],
478        ("202504", default): [],
479        (default, true): [
480            ":product_202504.cil",
481            ":product_202504.ignore.cil",
482        ],
483        (default, default): [],
484    }),
485    out: ["202504_mapping.combined.cil"],
486    cmd: select(soong_config_variable("ANDROID", "PLATFORM_SEPOLICY_VERSION"), {
487        "202404": "touch $(out)",
488        "202504": "touch $(out)",
489        default: "cat $(in) > $(out)",
490    }),
491}
492
493// TODO(b/391513934): clean up once we can simplify complex select statements.
494java_genrule {
495    name: "treble_sepolicy_tests_202504",
496    srcs: [
497        ":202504_plat_pub_policy.cil",
498        ":202504_mapping.combined.cil",
499    ] + select((
500        soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"),
501        soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"),
502    ), {
503        (false, false): [":base_plat_pub_policy.cil"],
504        (default, default): [":base_product_pub_policy.cil"],
505    }),
506    tools: ["treble_sepolicy_tests"],
507    out: ["treble_sepolicy_tests_202504"],
508    cmd: select((
509        soong_config_variable("ANDROID", "PLATFORM_SEPOLICY_VERSION"),
510        soong_config_variable("ANDROID", "HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR"),
511        soong_config_variable("ANDROID", "HAS_BOARD_PRODUCT_PREBUILT_DIR"),
512    ), {
513        ("202404", default, default): "touch $(out)",
514        ("202504", default, default): "touch $(out)",
515        (default, false, false): "$(location treble_sepolicy_tests) " +
516            "-b $(location :base_plat_pub_policy.cil) " +
517            "-m $(location :202504_mapping.combined.cil) " +
518            "-o $(location :202504_plat_pub_policy.cil) && " +
519            "touch $(out)",
520        (default, default, default): "$(location treble_sepolicy_tests) " +
521            "-b $(location :base_product_pub_policy.cil) " +
522            "-m $(location :202504_mapping.combined.cil) " +
523            "-o $(location :202504_plat_pub_policy.cil) && " +
524            "touch $(out)",
525    }),
526}
527