blob: 79f42250b092936cf2a1276daae1849f7128bc69 [file] [log] [blame]
Paul Duffin6d448b72021-10-29 12:35:36 +01001// 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
15package java
16
17import (
18 "sort"
19 "strings"
20 "testing"
21
22 "android/soong/android"
23 "github.com/google/blueprint"
24)
25
26func TestPrebuiltApis_SystemModulesCreation(t *testing.T) {
27 result := android.GroupFixturePreparers(
28 prepareForJavaTest,
29 FixtureWithPrebuiltApis(map[string][]string{
30 "31": {},
Paul Duffin004547f2021-10-29 13:50:24 +010031 "32": {},
Paul Duffin6d448b72021-10-29 12:35:36 +010032 "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 Duffin004547f2021-10-29 13:50:24 +010048 // 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 Duffin6d448b72021-10-29 12:35:36 +010051 "sdk_public_current_system_modules",
Paul Duffin004547f2021-10-29 13:50:24 +010052 "sdk_module-lib_current_system_modules",
Paul Duffin6d448b72021-10-29 12:35:36 +010053 }
54 sort.Strings(expected)
55 android.AssertArrayString(t, "sdk system modules", expected, sdkSystemModules)
56}