Prebuilt replacing source should not change partition

This reveals unintended mistake (setting a wrong target partition) at
build-time instead of runtime, which is much harder to debug.

Bug: 280368661
Test: m nothing (soong test)
Change-Id: Ic5e5e97ba918e24f7a59aceb405c2b105e28cccc
This commit is contained in:
Jooyung Han
2023-05-02 11:43:14 +09:00
parent acb7f7a7ce
commit ebaa573317
3 changed files with 72 additions and 8 deletions

View File

@@ -497,6 +497,52 @@ func TestPrebuilts(t *testing.T) {
}
}
func testPrebuiltError(t *testing.T, expectedError, bp string) {
t.Helper()
fs := MockFS{
"prebuilt_file": nil,
}
GroupFixturePreparers(
PrepareForTestWithArchMutator,
PrepareForTestWithPrebuilts,
PrepareForTestWithOverrides,
fs.AddToFixture(),
FixtureRegisterWithContext(registerTestPrebuiltModules),
).
ExtendWithErrorHandler(FixtureExpectsAtLeastOneErrorMatchingPattern(expectedError)).
RunTestWithBp(t, bp)
}
func TestPrebuiltShouldNotChangePartition(t *testing.T) {
testPrebuiltError(t, `partition is different`, `
source {
name: "foo",
vendor: true,
}
prebuilt {
name: "foo",
prefer: true,
srcs: ["prebuilt_file"],
}`)
}
func TestPrebuiltShouldNotChangePartition_WithOverride(t *testing.T) {
testPrebuiltError(t, `partition is different`, `
source {
name: "foo",
vendor: true,
}
override_source {
name: "bar",
base: "foo",
}
prebuilt {
name: "bar",
prefer: true,
srcs: ["prebuilt_file"],
}`)
}
func registerTestPrebuiltBuildComponents(ctx RegistrationContext) {
registerTestPrebuiltModules(ctx)