From 588e22a6bcb7874c84cfe83bb0b82f4a47cd34cf Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Fri, 21 May 2021 19:28:09 +0100 Subject: Tighten bootclasspath_fragment property validation Previously, due to legacy reasons, the property validation did not require a contents property and allowed the image_name to be either "art" or "boot". Those reasons no longer apply and so this change requires a contents property and only allows the image_name to be set to "art" if specified. Bug: 177892522 Test: m nothing Merged-In: I8855d6e5365ef0b55490e90e7b6c0081cf070ee5 Change-Id: I8855d6e5365ef0b55490e90e7b6c0081cf070ee5 (cherry picked from commit 8018e50ddb141dea7891918c4178a7a394a788d8) --- java/bootclasspath_fragment_test.go | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) (limited to 'java/bootclasspath_fragment_test.go') diff --git a/java/bootclasspath_fragment_test.go b/java/bootclasspath_fragment_test.go index 581625d8c..fba7d1a71 100644 --- a/java/bootclasspath_fragment_test.go +++ b/java/bootclasspath_fragment_test.go @@ -29,38 +29,28 @@ var prepareForTestWithBootclasspathFragment = android.GroupFixturePreparers( dexpreopt.PrepareForTestByEnablingDexpreopt, ) -func TestUnknownBootclasspathFragment(t *testing.T) { +func TestBootclasspathFragment_UnknownImageName(t *testing.T) { prepareForTestWithBootclasspathFragment. ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern( - `\Qimage_name: Unknown image name "unknown", expected one of art, boot\E`)). + `\Qimage_name: unknown image name "unknown", expected "art"\E`)). RunTestWithBp(t, ` bootclasspath_fragment { name: "unknown-bootclasspath-fragment", image_name: "unknown", + contents: ["foo"], } `) } -func TestUnknownBootclasspathFragmentImageName(t *testing.T) { +func TestPrebuiltBootclasspathFragment_UnknownImageName(t *testing.T) { prepareForTestWithBootclasspathFragment. ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern( - `\Qimage_name: Unknown image name "unknown", expected one of art, boot\E`)). - RunTestWithBp(t, ` - bootclasspath_fragment { - name: "unknown-bootclasspath-fragment", - image_name: "unknown", - } - `) -} - -func TestUnknownPrebuiltBootclasspathFragment(t *testing.T) { - prepareForTestWithBootclasspathFragment. - ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern( - `\Qimage_name: Unknown image name "unknown", expected one of art, boot\E`)). + `\Qimage_name: unknown image name "unknown", expected "art"\E`)). RunTestWithBp(t, ` prebuilt_bootclasspath_fragment { name: "unknown-bootclasspath-fragment", image_name: "unknown", + contents: ["foo"], } `) } @@ -76,6 +66,7 @@ func TestBootclasspathFragmentInconsistentArtConfiguration_Platform(t *testing.T bootclasspath_fragment { name: "bootclasspath-fragment", image_name: "art", + contents: ["foo", "bar"], apex_available: [ "apex", ], @@ -94,6 +85,7 @@ func TestBootclasspathFragmentInconsistentArtConfiguration_ApexMixture(t *testin bootclasspath_fragment { name: "bootclasspath-fragment", image_name: "art", + contents: ["foo", "bar"], apex_available: [ "apex1", "apex2", @@ -102,17 +94,6 @@ func TestBootclasspathFragmentInconsistentArtConfiguration_ApexMixture(t *testin `) } -func TestBootclasspathFragmentWithoutImageNameOrContents(t *testing.T) { - prepareForTestWithBootclasspathFragment. - ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern( - `\Qneither of the "image_name" and "contents" properties\E`)). - RunTestWithBp(t, ` - bootclasspath_fragment { - name: "bootclasspath-fragment", - } - `) -} - func TestBootclasspathFragment_Coverage(t *testing.T) { prepareForTestWithFrameworkCoverage := android.FixtureMergeEnv(map[string]string{ "EMMA_INSTRUMENT": "true", -- cgit v1.2.3