Merge "Disallow non-existent paths in sdk package"
This commit is contained in:
commit
863ecfb7ba
|
@ -19,4 +19,11 @@ import "android/soong/android"
|
||||||
var PrepareForTestWithApexBuildComponents = android.GroupFixturePreparers(
|
var PrepareForTestWithApexBuildComponents = android.GroupFixturePreparers(
|
||||||
android.FixtureRegisterWithContext(registerApexBuildComponents),
|
android.FixtureRegisterWithContext(registerApexBuildComponents),
|
||||||
android.FixtureRegisterWithContext(registerApexKeyBuildComponents),
|
android.FixtureRegisterWithContext(registerApexKeyBuildComponents),
|
||||||
|
// Additional files needed in tests that disallow non-existent source files.
|
||||||
|
// This includes files that are needed by all, or at least most, instances of an apex module type.
|
||||||
|
android.MockFS{
|
||||||
|
// Needed by apex.
|
||||||
|
"system/core/rootdir/etc/public.libraries.android.txt": nil,
|
||||||
|
"build/soong/scripts/gen_ndk_backedby_apex.sh": nil,
|
||||||
|
}.AddToFixture(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -166,6 +166,15 @@ const (
|
||||||
recoveryVariant = "android_recovery_arm64_armv8-a_shared"
|
recoveryVariant = "android_recovery_arm64_armv8-a_shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Test that the PrepareForTestWithCcDefaultModules provides all the files that it uses by
|
||||||
|
// running it in a fixture that requires all source files to exist.
|
||||||
|
func TestPrepareForTestWithCcDefaultModules(t *testing.T) {
|
||||||
|
android.GroupFixturePreparers(
|
||||||
|
PrepareForTestWithCcDefaultModules,
|
||||||
|
android.PrepareForTestDisallowNonExistentPaths,
|
||||||
|
).RunTest(t)
|
||||||
|
}
|
||||||
|
|
||||||
func TestFuchsiaDeps(t *testing.T) {
|
func TestFuchsiaDeps(t *testing.T) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
|
|
|
@ -619,11 +619,26 @@ var PrepareForTestWithCcBuildComponents = android.GroupFixturePreparers(
|
||||||
|
|
||||||
RegisterVndkLibraryTxtTypes(ctx)
|
RegisterVndkLibraryTxtTypes(ctx)
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
// Additional files needed in tests that disallow non-existent source files.
|
||||||
|
// This includes files that are needed by all, or at least most, instances of a cc module type.
|
||||||
|
android.MockFS{
|
||||||
|
// Needed for ndk_prebuilt_(shared|static)_stl.
|
||||||
|
"prebuilts/ndk/current/sources/cxx-stl/llvm-libc++/libs": nil,
|
||||||
|
}.AddToFixture(),
|
||||||
)
|
)
|
||||||
|
|
||||||
// Preparer that will define default cc modules, e.g. standard prebuilt modules.
|
// Preparer that will define default cc modules, e.g. standard prebuilt modules.
|
||||||
var PrepareForTestWithCcDefaultModules = android.GroupFixturePreparers(
|
var PrepareForTestWithCcDefaultModules = android.GroupFixturePreparers(
|
||||||
PrepareForTestWithCcBuildComponents,
|
PrepareForTestWithCcBuildComponents,
|
||||||
|
|
||||||
|
// Additional files needed in tests that disallow non-existent source.
|
||||||
|
android.MockFS{
|
||||||
|
"defaults/cc/common/libc.map.txt": nil,
|
||||||
|
"defaults/cc/common/libdl.map.txt": nil,
|
||||||
|
"defaults/cc/common/libm.map.txt": nil,
|
||||||
|
}.AddToFixture(),
|
||||||
|
|
||||||
// Place the default cc test modules that are common to all platforms in a location that will not
|
// Place the default cc test modules that are common to all platforms in a location that will not
|
||||||
// conflict with default test modules defined by other packages.
|
// conflict with default test modules defined by other packages.
|
||||||
android.FixtureAddTextFile(DefaultCcCommonTestModulesDir+"Android.bp", commonDefaultModules()),
|
android.FixtureAddTextFile(DefaultCcCommonTestModulesDir+"Android.bp", commonDefaultModules()),
|
||||||
|
|
|
@ -486,6 +486,9 @@ func TestSnapshotWithCcExportGeneratedHeaders(t *testing.T) {
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
// TODO(b/183322862): Remove this and fix the issue.
|
||||||
|
errorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module source path "snapshot/include_gen/generated_foo/gen/protos" does not exist`)
|
||||||
|
|
||||||
CheckSnapshot(t, result, "mysdk", "",
|
CheckSnapshot(t, result, "mysdk", "",
|
||||||
checkUnversionedAndroidBpContents(`
|
checkUnversionedAndroidBpContents(`
|
||||||
// This is auto-generated. DO NOT EDIT.
|
// This is auto-generated. DO NOT EDIT.
|
||||||
|
@ -518,6 +521,9 @@ myinclude/Test.h -> include/myinclude/Test.h
|
||||||
.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
|
.intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so
|
||||||
.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
|
.intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so
|
||||||
`),
|
`),
|
||||||
|
snapshotTestErrorHandler(checkSnapshotWithoutSource, errorHandler),
|
||||||
|
snapshotTestErrorHandler(checkSnapshotWithSourcePreferred, errorHandler),
|
||||||
|
snapshotTestErrorHandler(checkSnapshotPreferredWithSource, errorHandler),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,16 @@ import (
|
||||||
var prepareForSdkTestWithJava = android.GroupFixturePreparers(
|
var prepareForSdkTestWithJava = android.GroupFixturePreparers(
|
||||||
java.PrepareForTestWithJavaBuildComponents,
|
java.PrepareForTestWithJavaBuildComponents,
|
||||||
PrepareForTestWithSdkBuildComponents,
|
PrepareForTestWithSdkBuildComponents,
|
||||||
|
|
||||||
|
// Ensure that all source paths are provided. This helps ensure that the snapshot generation is
|
||||||
|
// consistent and all files referenced from the snapshot's Android.bp file have actually been
|
||||||
|
// copied into the snapshot.
|
||||||
|
android.PrepareForTestDisallowNonExistentPaths,
|
||||||
|
|
||||||
|
// Files needs by most of the tests.
|
||||||
|
android.MockFS{
|
||||||
|
"Test.java": nil,
|
||||||
|
}.AddToFixture(),
|
||||||
)
|
)
|
||||||
|
|
||||||
var prepareForSdkTestWithJavaSdkLibrary = android.GroupFixturePreparers(
|
var prepareForSdkTestWithJavaSdkLibrary = android.GroupFixturePreparers(
|
||||||
|
@ -339,6 +349,7 @@ func TestSnapshotWithJavaImplLibrary(t *testing.T) {
|
||||||
result := android.GroupFixturePreparers(
|
result := android.GroupFixturePreparers(
|
||||||
prepareForSdkTestWithJava,
|
prepareForSdkTestWithJava,
|
||||||
android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil),
|
android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil),
|
||||||
|
android.FixtureAddFile("resource.txt", nil),
|
||||||
).RunTestWithBp(t, `
|
).RunTestWithBp(t, `
|
||||||
module_exports {
|
module_exports {
|
||||||
name: "myexports",
|
name: "myexports",
|
||||||
|
@ -394,7 +405,11 @@ aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSnapshotWithJavaBootLibrary(t *testing.T) {
|
func TestSnapshotWithJavaBootLibrary(t *testing.T) {
|
||||||
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
|
result := android.GroupFixturePreparers(
|
||||||
|
prepareForSdkTestWithJava,
|
||||||
|
android.FixtureAddFile("aidl", nil),
|
||||||
|
android.FixtureAddFile("resource.txt", nil),
|
||||||
|
).RunTestWithBp(t, `
|
||||||
module_exports {
|
module_exports {
|
||||||
name: "myexports",
|
name: "myexports",
|
||||||
java_boot_libs: ["myjavalib"],
|
java_boot_libs: ["myjavalib"],
|
||||||
|
@ -1539,7 +1554,10 @@ sdk_snapshot {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSnapshotWithJavaSdkLibrary_DoctagFiles(t *testing.T) {
|
func TestSnapshotWithJavaSdkLibrary_DoctagFiles(t *testing.T) {
|
||||||
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
|
result := android.GroupFixturePreparers(
|
||||||
|
prepareForSdkTestWithJavaSdkLibrary,
|
||||||
|
android.FixtureAddFile("docs/known_doctags", nil),
|
||||||
|
).RunTestWithBp(t, `
|
||||||
sdk {
|
sdk {
|
||||||
name: "mysdk",
|
name: "mysdk",
|
||||||
java_sdk_libs: ["myjavalib"],
|
java_sdk_libs: ["myjavalib"],
|
||||||
|
|
|
@ -48,10 +48,10 @@ var prepareForSdkTestWithApex = android.GroupFixturePreparers(
|
||||||
"system/sepolicy/apex/myapex-file_contexts": nil,
|
"system/sepolicy/apex/myapex-file_contexts": nil,
|
||||||
"system/sepolicy/apex/myapex2-file_contexts": nil,
|
"system/sepolicy/apex/myapex2-file_contexts": nil,
|
||||||
"system/sepolicy/apex/mysdkapex-file_contexts": nil,
|
"system/sepolicy/apex/mysdkapex-file_contexts": nil,
|
||||||
"myapex.avbpubkey": nil,
|
"sdk/tests/myapex.avbpubkey": nil,
|
||||||
"myapex.pem": nil,
|
"sdk/tests/myapex.pem": nil,
|
||||||
"myapex.x509.pem": nil,
|
"sdk/tests/myapex.x509.pem": nil,
|
||||||
"myapex.pk8": nil,
|
"sdk/tests/myapex.pk8": nil,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -80,6 +80,12 @@ var prepareForSdkTest = android.GroupFixturePreparers(
|
||||||
{android.Windows, android.Arch{ArchType: android.X86_64}, android.NativeBridgeDisabled, "", "", true},
|
{android.Windows, android.Arch{ArchType: android.X86_64}, android.NativeBridgeDisabled, "", "", true},
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
// Make sure that every test provides all the source files.
|
||||||
|
android.PrepareForTestDisallowNonExistentPaths,
|
||||||
|
android.MockFS{
|
||||||
|
"Test.java": nil,
|
||||||
|
}.AddToFixture(),
|
||||||
)
|
)
|
||||||
|
|
||||||
var PrepareForTestWithSdkBuildComponents = android.GroupFixturePreparers(
|
var PrepareForTestWithSdkBuildComponents = android.GroupFixturePreparers(
|
||||||
|
|
Loading…
Reference in New Issue