summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Paul Duffin <paulduffin@google.com> 2021-10-29 12:35:36 +0100
committer Paul Duffin <paulduffin@google.com> 2021-11-01 16:36:02 +0000
commit6d448b7a0a2a05125e3f118051db4f8db5f72ca8 (patch)
tree21e3326ba22d771a0f18bbc114ae0f72d36964b0
parentbce9f08d027cee0554bedc28e3fbef6313aa8b98 (diff)
Add test for prebuilt_apis creation of system modules
Previously, there were no tests for this (outside uses in other tests). This change adds a test that uses the fixture preparers that create a prebuilt_api in order to make prebuilt APIs available. That ensures that both the prebuilt_api is working as expected and the preparer creates a realistic test environment. Bug: 204189791 Test: m nothing Change-Id: I57352aa00f7b268e5286be92f177764dd63ba7e8
-rw-r--r--java/Android.bp1
-rw-r--r--java/prebuilt_apis_test.go52
2 files changed, 53 insertions, 0 deletions
diff --git a/java/Android.bp b/java/Android.bp
index 78d0cc1a9..8835b4456 100644
--- a/java/Android.bp
+++ b/java/Android.bp
@@ -93,6 +93,7 @@ bootstrap_go_package {
"platform_bootclasspath_test.go",
"platform_compat_config_test.go",
"plugin_test.go",
+ "prebuilt_apis_test.go",
"rro_test.go",
"sdk_test.go",
"sdk_library_test.go",
diff --git a/java/prebuilt_apis_test.go b/java/prebuilt_apis_test.go
new file mode 100644
index 000000000..7c2e52600
--- /dev/null
+++ b/java/prebuilt_apis_test.go
@@ -0,0 +1,52 @@
+// Copyright 2021 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package java
+
+import (
+ "sort"
+ "strings"
+ "testing"
+
+ "android/soong/android"
+ "github.com/google/blueprint"
+)
+
+func TestPrebuiltApis_SystemModulesCreation(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ FixtureWithPrebuiltApis(map[string][]string{
+ "31": {},
+ "current": {},
+ }),
+ ).RunTest(t)
+
+ sdkSystemModules := []string{}
+ result.VisitAllModules(func(module blueprint.Module) {
+ name := android.RemoveOptionalPrebuiltPrefix(module.Name())
+ if strings.HasPrefix(name, "sdk_") && strings.HasSuffix(name, "_system_modules") {
+ sdkSystemModules = append(sdkSystemModules, name)
+ }
+ })
+ sort.Strings(sdkSystemModules)
+ expected := []string{
+ // 31 only has public system modules.
+ "sdk_public_31_system_modules",
+
+ // current only has public system modules.
+ "sdk_public_current_system_modules",
+ }
+ sort.Strings(expected)
+ android.AssertArrayString(t, "sdk system modules", expected, sdkSystemModules)
+}