diff options
author | 2023-05-02 11:43:14 +0900 | |
---|---|---|
committer | 2023-05-04 10:36:27 +0900 | |
commit | ebaa5733173f687ed14c0b7aedfa72bcc990138d (patch) | |
tree | db0897a7975a9a2c8e98d03eff1591f993257eb4 /android/prebuilt_test.go | |
parent | acb7f7a7ce75c9b9ee82f715468f7ad90cdba23c (diff) |
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
Diffstat (limited to 'android/prebuilt_test.go')
-rw-r--r-- | android/prebuilt_test.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/android/prebuilt_test.go b/android/prebuilt_test.go index fa40d1fb3..fc47cfd97 100644 --- a/android/prebuilt_test.go +++ b/android/prebuilt_test.go @@ -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) |