Paul Duffin | 6d448b7 | 2021-10-29 12:35:36 +0100 | [diff] [blame] | 1 | // Copyright 2021 Google Inc. All rights reserved. |
| 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 java |
| 16 | |
| 17 | import ( |
| 18 | "sort" |
| 19 | "strings" |
| 20 | "testing" |
| 21 | |
| 22 | "android/soong/android" |
| 23 | "github.com/google/blueprint" |
| 24 | ) |
| 25 | |
| 26 | func TestPrebuiltApis_SystemModulesCreation(t *testing.T) { |
| 27 | result := android.GroupFixturePreparers( |
| 28 | prepareForJavaTest, |
| 29 | FixtureWithPrebuiltApis(map[string][]string{ |
| 30 | "31": {}, |
Paul Duffin | 004547f | 2021-10-29 13:50:24 +0100 | [diff] [blame^] | 31 | "32": {}, |
Paul Duffin | 6d448b7 | 2021-10-29 12:35:36 +0100 | [diff] [blame] | 32 | "current": {}, |
| 33 | }), |
| 34 | ).RunTest(t) |
| 35 | |
| 36 | sdkSystemModules := []string{} |
| 37 | result.VisitAllModules(func(module blueprint.Module) { |
| 38 | name := android.RemoveOptionalPrebuiltPrefix(module.Name()) |
| 39 | if strings.HasPrefix(name, "sdk_") && strings.HasSuffix(name, "_system_modules") { |
| 40 | sdkSystemModules = append(sdkSystemModules, name) |
| 41 | } |
| 42 | }) |
| 43 | sort.Strings(sdkSystemModules) |
| 44 | expected := []string{ |
| 45 | // 31 only has public system modules. |
| 46 | "sdk_public_31_system_modules", |
| 47 | |
Paul Duffin | 004547f | 2021-10-29 13:50:24 +0100 | [diff] [blame^] | 48 | // 32 and current both have public and module-lib system modules. |
| 49 | "sdk_public_32_system_modules", |
| 50 | "sdk_module-lib_32_system_modules", |
Paul Duffin | 6d448b7 | 2021-10-29 12:35:36 +0100 | [diff] [blame] | 51 | "sdk_public_current_system_modules", |
Paul Duffin | 004547f | 2021-10-29 13:50:24 +0100 | [diff] [blame^] | 52 | "sdk_module-lib_current_system_modules", |
Paul Duffin | 6d448b7 | 2021-10-29 12:35:36 +0100 | [diff] [blame] | 53 | } |
| 54 | sort.Strings(expected) |
| 55 | android.AssertArrayString(t, "sdk system modules", expected, sdkSystemModules) |
| 56 | } |