blob: 5a03e346eab2b6c97b1883e4c07fed0fefa5e01b [file] [log] [blame]
Paul Duffinf7f65da2021-03-10 15:00:46 +00001// Copyright (C) 2021 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 sdk
16
Paul Duffin4a1d4512021-03-18 10:12:26 +000017import (
18 "testing"
19
20 "android/soong/android"
21)
Paul Duffinf7f65da2021-03-10 15:00:46 +000022
23func TestSnapshotWithBootImage(t *testing.T) {
Paul Duffin4a1d4512021-03-18 10:12:26 +000024 result := android.GroupFixturePreparers(
25 prepareForSdkTestWithJava,
26 android.FixtureWithRootAndroidBp(`
27 sdk {
28 name: "mysdk",
29 boot_images: ["mybootimage"],
30 }
Paul Duffinf7f65da2021-03-10 15:00:46 +000031
Paul Duffin4a1d4512021-03-18 10:12:26 +000032 boot_image {
33 name: "mybootimage",
34 image_name: "art",
35 }
36 `),
37 ).RunTest(t)
Paul Duffinf7f65da2021-03-10 15:00:46 +000038
Paul Duffin36474d32021-03-12 12:19:43 +000039 CheckSnapshot(t, result, "mysdk", "",
Paul Duffinf7f65da2021-03-10 15:00:46 +000040 checkUnversionedAndroidBpContents(`
41// This is auto-generated. DO NOT EDIT.
42
43prebuilt_boot_image {
44 name: "mybootimage",
45 prefer: false,
46 visibility: ["//visibility:public"],
47 apex_available: ["//apex_available:platform"],
48 image_name: "art",
49}
50`),
51 checkVersionedAndroidBpContents(`
52// This is auto-generated. DO NOT EDIT.
53
54prebuilt_boot_image {
55 name: "mysdk_mybootimage@current",
56 sdk_member_name: "mybootimage",
57 visibility: ["//visibility:public"],
58 apex_available: ["//apex_available:platform"],
59 image_name: "art",
60}
61
62sdk_snapshot {
63 name: "mysdk@current",
64 visibility: ["//visibility:public"],
65 boot_images: ["mysdk_mybootimage@current"],
66}
67`),
Paul Duffin36474d32021-03-12 12:19:43 +000068 checkAllCopyRules(""))
Paul Duffinf7f65da2021-03-10 15:00:46 +000069}
Paul Duffin04b4a192021-03-18 11:05:31 +000070
71// Test that boot_image works with sdk.
72func TestBasicSdkWithBootImage(t *testing.T) {
73 android.GroupFixturePreparers(
74 prepareForSdkTestWithApex,
75 prepareForSdkTestWithJava,
76 android.FixtureWithRootAndroidBp(`
77 sdk {
78 name: "mysdk",
79 boot_images: ["mybootimage"],
80 }
81
82 boot_image {
83 name: "mybootimage",
84 image_name: "art",
85 apex_available: ["myapex"],
86 }
87
88 sdk_snapshot {
89 name: "mysdk@1",
90 boot_images: ["mybootimage_mysdk_1"],
91 }
92
93 prebuilt_boot_image {
94 name: "mybootimage_mysdk_1",
95 sdk_member_name: "mybootimage",
96 prefer: false,
97 visibility: ["//visibility:public"],
98 apex_available: [
99 "myapex",
100 ],
101 image_name: "art",
102 }
103 `),
104 ).RunTest(t)
105}