Move TestPlatformBootclasspath_Fragments to apex package
This test checks that fragments which are referenced from a platform_bootclasspath module contribute their hidden API flags to those used by platform_bootclasspath module. Previously, it was unrealistic because the bootclasspath_fragment does not belong in an APEX. This change moves the test from the java package to the apex package to allow it to be modified to make the bootclasspath_fragment part of an apex. Bug: 179354495 Test: m nothing Change-Id: Icb57f2e1eaea4b14aab5f47f3af7d05ea0555816
This commit is contained in:
@@ -15,6 +15,8 @@
|
|||||||
package apex
|
package apex
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
@@ -31,6 +33,116 @@ var prepareForTestWithPlatformBootclasspath = android.GroupFixturePreparers(
|
|||||||
PrepareForTestWithApexBuildComponents,
|
PrepareForTestWithApexBuildComponents,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestPlatformBootclasspath_Fragments(t *testing.T) {
|
||||||
|
result := android.GroupFixturePreparers(
|
||||||
|
prepareForTestWithPlatformBootclasspath,
|
||||||
|
java.PrepareForTestWithJavaSdkLibraryFiles,
|
||||||
|
java.FixtureWithLastReleaseApis("foo"),
|
||||||
|
android.FixtureWithRootAndroidBp(`
|
||||||
|
platform_bootclasspath {
|
||||||
|
name: "platform-bootclasspath",
|
||||||
|
fragments: [
|
||||||
|
{module:"bar-fragment"},
|
||||||
|
],
|
||||||
|
hidden_api: {
|
||||||
|
unsupported: [
|
||||||
|
"unsupported.txt",
|
||||||
|
],
|
||||||
|
removed: [
|
||||||
|
"removed.txt",
|
||||||
|
],
|
||||||
|
max_target_r_low_priority: [
|
||||||
|
"max-target-r-low-priority.txt",
|
||||||
|
],
|
||||||
|
max_target_q: [
|
||||||
|
"max-target-q.txt",
|
||||||
|
],
|
||||||
|
max_target_p: [
|
||||||
|
"max-target-p.txt",
|
||||||
|
],
|
||||||
|
max_target_o_low_priority: [
|
||||||
|
"max-target-o-low-priority.txt",
|
||||||
|
],
|
||||||
|
blocked: [
|
||||||
|
"blocked.txt",
|
||||||
|
],
|
||||||
|
unsupported_packages: [
|
||||||
|
"unsupported-packages.txt",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
bootclasspath_fragment {
|
||||||
|
name: "bar-fragment",
|
||||||
|
contents: ["bar"],
|
||||||
|
api: {
|
||||||
|
stub_libs: ["foo"],
|
||||||
|
},
|
||||||
|
hidden_api: {
|
||||||
|
unsupported: [
|
||||||
|
"bar-unsupported.txt",
|
||||||
|
],
|
||||||
|
removed: [
|
||||||
|
"bar-removed.txt",
|
||||||
|
],
|
||||||
|
max_target_r_low_priority: [
|
||||||
|
"bar-max-target-r-low-priority.txt",
|
||||||
|
],
|
||||||
|
max_target_q: [
|
||||||
|
"bar-max-target-q.txt",
|
||||||
|
],
|
||||||
|
max_target_p: [
|
||||||
|
"bar-max-target-p.txt",
|
||||||
|
],
|
||||||
|
max_target_o_low_priority: [
|
||||||
|
"bar-max-target-o-low-priority.txt",
|
||||||
|
],
|
||||||
|
blocked: [
|
||||||
|
"bar-blocked.txt",
|
||||||
|
],
|
||||||
|
unsupported_packages: [
|
||||||
|
"bar-unsupported-packages.txt",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
java_library {
|
||||||
|
name: "bar",
|
||||||
|
srcs: ["a.java"],
|
||||||
|
system_modules: "none",
|
||||||
|
sdk_version: "none",
|
||||||
|
compile_dex: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
java_sdk_library {
|
||||||
|
name: "foo",
|
||||||
|
srcs: ["a.java"],
|
||||||
|
public: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
compile_dex: true,
|
||||||
|
}
|
||||||
|
`),
|
||||||
|
).RunTest(t)
|
||||||
|
|
||||||
|
pbcp := result.Module("platform-bootclasspath", "android_common")
|
||||||
|
info := result.ModuleProvider(pbcp, java.MonolithicHiddenAPIInfoProvider).(java.MonolithicHiddenAPIInfo)
|
||||||
|
|
||||||
|
for _, category := range java.HiddenAPIFlagFileCategories {
|
||||||
|
name := category.PropertyName
|
||||||
|
message := fmt.Sprintf("category %s", name)
|
||||||
|
filename := strings.ReplaceAll(name, "_", "-")
|
||||||
|
expected := []string{fmt.Sprintf("%s.txt", filename), fmt.Sprintf("bar-%s.txt", filename)}
|
||||||
|
android.AssertPathsRelativeToTopEquals(t, message, expected, info.FlagsFilesByCategory[category])
|
||||||
|
}
|
||||||
|
|
||||||
|
android.AssertPathsRelativeToTopEquals(t, "stub flags", []string{"out/soong/.intermediates/bar-fragment/android_common/modular-hiddenapi/stub-flags.csv"}, info.StubFlagsPaths)
|
||||||
|
android.AssertPathsRelativeToTopEquals(t, "annotation flags", []string{"out/soong/.intermediates/bar-fragment/android_common/modular-hiddenapi/annotation-flags.csv"}, info.AnnotationFlagsPaths)
|
||||||
|
android.AssertPathsRelativeToTopEquals(t, "metadata flags", []string{"out/soong/.intermediates/bar-fragment/android_common/modular-hiddenapi/metadata.csv"}, info.MetadataPaths)
|
||||||
|
android.AssertPathsRelativeToTopEquals(t, "index flags", []string{"out/soong/.intermediates/bar-fragment/android_common/modular-hiddenapi/index.csv"}, info.IndexPaths)
|
||||||
|
android.AssertPathsRelativeToTopEquals(t, "all flags", []string{"out/soong/.intermediates/bar-fragment/android_common/modular-hiddenapi/all-flags.csv"}, info.AllFlagsPaths)
|
||||||
|
}
|
||||||
|
|
||||||
func TestPlatformBootclasspathDependencies(t *testing.T) {
|
func TestPlatformBootclasspathDependencies(t *testing.T) {
|
||||||
result := android.GroupFixturePreparers(
|
result := android.GroupFixturePreparers(
|
||||||
prepareForTestWithPlatformBootclasspath,
|
prepareForTestWithPlatformBootclasspath,
|
||||||
|
@@ -15,8 +15,6 @@
|
|||||||
package java
|
package java
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
@@ -152,116 +150,6 @@ func TestPlatformBootclasspath(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPlatformBootclasspath_Fragments(t *testing.T) {
|
|
||||||
result := android.GroupFixturePreparers(
|
|
||||||
prepareForTestWithPlatformBootclasspath,
|
|
||||||
PrepareForTestWithJavaSdkLibraryFiles,
|
|
||||||
FixtureWithLastReleaseApis("foo"),
|
|
||||||
android.FixtureWithRootAndroidBp(`
|
|
||||||
platform_bootclasspath {
|
|
||||||
name: "platform-bootclasspath",
|
|
||||||
fragments: [
|
|
||||||
{module:"bar-fragment"},
|
|
||||||
],
|
|
||||||
hidden_api: {
|
|
||||||
unsupported: [
|
|
||||||
"unsupported.txt",
|
|
||||||
],
|
|
||||||
removed: [
|
|
||||||
"removed.txt",
|
|
||||||
],
|
|
||||||
max_target_r_low_priority: [
|
|
||||||
"max-target-r-low-priority.txt",
|
|
||||||
],
|
|
||||||
max_target_q: [
|
|
||||||
"max-target-q.txt",
|
|
||||||
],
|
|
||||||
max_target_p: [
|
|
||||||
"max-target-p.txt",
|
|
||||||
],
|
|
||||||
max_target_o_low_priority: [
|
|
||||||
"max-target-o-low-priority.txt",
|
|
||||||
],
|
|
||||||
blocked: [
|
|
||||||
"blocked.txt",
|
|
||||||
],
|
|
||||||
unsupported_packages: [
|
|
||||||
"unsupported-packages.txt",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
bootclasspath_fragment {
|
|
||||||
name: "bar-fragment",
|
|
||||||
contents: ["bar"],
|
|
||||||
api: {
|
|
||||||
stub_libs: ["foo"],
|
|
||||||
},
|
|
||||||
hidden_api: {
|
|
||||||
unsupported: [
|
|
||||||
"bar-unsupported.txt",
|
|
||||||
],
|
|
||||||
removed: [
|
|
||||||
"bar-removed.txt",
|
|
||||||
],
|
|
||||||
max_target_r_low_priority: [
|
|
||||||
"bar-max-target-r-low-priority.txt",
|
|
||||||
],
|
|
||||||
max_target_q: [
|
|
||||||
"bar-max-target-q.txt",
|
|
||||||
],
|
|
||||||
max_target_p: [
|
|
||||||
"bar-max-target-p.txt",
|
|
||||||
],
|
|
||||||
max_target_o_low_priority: [
|
|
||||||
"bar-max-target-o-low-priority.txt",
|
|
||||||
],
|
|
||||||
blocked: [
|
|
||||||
"bar-blocked.txt",
|
|
||||||
],
|
|
||||||
unsupported_packages: [
|
|
||||||
"bar-unsupported-packages.txt",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
java_library {
|
|
||||||
name: "bar",
|
|
||||||
srcs: ["a.java"],
|
|
||||||
system_modules: "none",
|
|
||||||
sdk_version: "none",
|
|
||||||
compile_dex: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
java_sdk_library {
|
|
||||||
name: "foo",
|
|
||||||
srcs: ["a.java"],
|
|
||||||
public: {
|
|
||||||
enabled: true,
|
|
||||||
},
|
|
||||||
compile_dex: true,
|
|
||||||
}
|
|
||||||
`),
|
|
||||||
).RunTest(t)
|
|
||||||
|
|
||||||
pbcp := result.Module("platform-bootclasspath", "android_common")
|
|
||||||
info := result.ModuleProvider(pbcp, MonolithicHiddenAPIInfoProvider).(MonolithicHiddenAPIInfo)
|
|
||||||
|
|
||||||
for _, category := range HiddenAPIFlagFileCategories {
|
|
||||||
name := category.PropertyName
|
|
||||||
message := fmt.Sprintf("category %s", name)
|
|
||||||
filename := strings.ReplaceAll(name, "_", "-")
|
|
||||||
expected := []string{fmt.Sprintf("%s.txt", filename), fmt.Sprintf("bar-%s.txt", filename)}
|
|
||||||
android.AssertPathsRelativeToTopEquals(t, message, expected, info.FlagsFilesByCategory[category])
|
|
||||||
}
|
|
||||||
|
|
||||||
android.AssertPathsRelativeToTopEquals(t, "stub flags", []string{"out/soong/.intermediates/bar-fragment/android_common/modular-hiddenapi/stub-flags.csv"}, info.StubFlagsPaths)
|
|
||||||
android.AssertPathsRelativeToTopEquals(t, "annotation flags", []string{"out/soong/.intermediates/bar-fragment/android_common/modular-hiddenapi/annotation-flags.csv"}, info.AnnotationFlagsPaths)
|
|
||||||
android.AssertPathsRelativeToTopEquals(t, "metadata flags", []string{"out/soong/.intermediates/bar-fragment/android_common/modular-hiddenapi/metadata.csv"}, info.MetadataPaths)
|
|
||||||
android.AssertPathsRelativeToTopEquals(t, "index flags", []string{"out/soong/.intermediates/bar-fragment/android_common/modular-hiddenapi/index.csv"}, info.IndexPaths)
|
|
||||||
android.AssertPathsRelativeToTopEquals(t, "all flags", []string{"out/soong/.intermediates/bar-fragment/android_common/modular-hiddenapi/all-flags.csv"}, info.AllFlagsPaths)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPlatformBootclasspathVariant(t *testing.T) {
|
func TestPlatformBootclasspathVariant(t *testing.T) {
|
||||||
result := android.GroupFixturePreparers(
|
result := android.GroupFixturePreparers(
|
||||||
prepareForTestWithPlatformBootclasspath,
|
prepareForTestWithPlatformBootclasspath,
|
||||||
|
Reference in New Issue
Block a user