Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 1 | // 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 | |
| 15 | package sdk |
| 16 | |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 17 | import ( |
| 18 | "testing" |
| 19 | |
| 20 | "android/soong/android" |
| 21 | ) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 22 | |
| 23 | func TestSnapshotWithBootImage(t *testing.T) { |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 24 | result := android.GroupFixturePreparers( |
| 25 | prepareForSdkTestWithJava, |
| 26 | android.FixtureWithRootAndroidBp(` |
| 27 | sdk { |
| 28 | name: "mysdk", |
| 29 | boot_images: ["mybootimage"], |
| 30 | } |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 31 | |
Paul Duffin | 4a1d451 | 2021-03-18 10:12:26 +0000 | [diff] [blame] | 32 | boot_image { |
| 33 | name: "mybootimage", |
| 34 | image_name: "art", |
| 35 | } |
| 36 | `), |
| 37 | ).RunTest(t) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 38 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 39 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 40 | checkUnversionedAndroidBpContents(` |
| 41 | // This is auto-generated. DO NOT EDIT. |
| 42 | |
| 43 | prebuilt_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 | |
| 54 | prebuilt_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 | |
| 62 | sdk_snapshot { |
| 63 | name: "mysdk@current", |
| 64 | visibility: ["//visibility:public"], |
| 65 | boot_images: ["mysdk_mybootimage@current"], |
| 66 | } |
| 67 | `), |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 68 | checkAllCopyRules("")) |
Paul Duffin | f7f65da | 2021-03-10 15:00:46 +0000 | [diff] [blame] | 69 | } |
Paul Duffin | 04b4a19 | 2021-03-18 11:05:31 +0000 | [diff] [blame^] | 70 | |
| 71 | // Test that boot_image works with sdk. |
| 72 | func 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 | } |