Merge "Disallow non-existent paths in sdk package" am: 863ecfb7ba
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1647171 Change-Id: I03a4fa86c9f85fc8f89dc688573450f65f2fcbba
This commit is contained in:
commit
a48aed59ee
6 changed files with 67 additions and 6 deletions
|
@ -19,4 +19,11 @@ import "android/soong/android"
|
|||
var PrepareForTestWithApexBuildComponents = android.GroupFixturePreparers(
|
||||
android.FixtureRegisterWithContext(registerApexBuildComponents),
|
||||
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"
|
||||
)
|
||||
|
||||
// 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) {
|
||||
t.Helper()
|
||||
|
||||
|
|
|
@ -619,11 +619,26 @@ var PrepareForTestWithCcBuildComponents = android.GroupFixturePreparers(
|
|||
|
||||
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.
|
||||
var PrepareForTestWithCcDefaultModules = android.GroupFixturePreparers(
|
||||
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
|
||||
// conflict with default test modules defined by other packages.
|
||||
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", "",
|
||||
checkUnversionedAndroidBpContents(`
|
||||
// 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_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(
|
||||
java.PrepareForTestWithJavaBuildComponents,
|
||||
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(
|
||||
|
@ -339,6 +349,7 @@ func TestSnapshotWithJavaImplLibrary(t *testing.T) {
|
|||
result := android.GroupFixturePreparers(
|
||||
prepareForSdkTestWithJava,
|
||||
android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil),
|
||||
android.FixtureAddFile("resource.txt", nil),
|
||||
).RunTestWithBp(t, `
|
||||
module_exports {
|
||||
name: "myexports",
|
||||
|
@ -394,7 +405,11 @@ aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
|
|||
}
|
||||
|
||||
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 {
|
||||
name: "myexports",
|
||||
java_boot_libs: ["myjavalib"],
|
||||
|
@ -1539,7 +1554,10 @@ sdk_snapshot {
|
|||
}
|
||||
|
||||
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 {
|
||||
name: "mysdk",
|
||||
java_sdk_libs: ["myjavalib"],
|
||||
|
|
|
@ -48,10 +48,10 @@ var prepareForSdkTestWithApex = android.GroupFixturePreparers(
|
|||
"system/sepolicy/apex/myapex-file_contexts": nil,
|
||||
"system/sepolicy/apex/myapex2-file_contexts": nil,
|
||||
"system/sepolicy/apex/mysdkapex-file_contexts": nil,
|
||||
"myapex.avbpubkey": nil,
|
||||
"myapex.pem": nil,
|
||||
"myapex.x509.pem": nil,
|
||||
"myapex.pk8": nil,
|
||||
"sdk/tests/myapex.avbpubkey": nil,
|
||||
"sdk/tests/myapex.pem": nil,
|
||||
"sdk/tests/myapex.x509.pem": 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},
|
||||
}
|
||||
}),
|
||||
|
||||
// Make sure that every test provides all the source files.
|
||||
android.PrepareForTestDisallowNonExistentPaths,
|
||||
android.MockFS{
|
||||
"Test.java": nil,
|
||||
}.AddToFixture(),
|
||||
)
|
||||
|
||||
var PrepareForTestWithSdkBuildComponents = android.GroupFixturePreparers(
|
||||
|
|
Loading…
Reference in a new issue