diff options
author | 2021-03-08 09:47:16 +0000 | |
---|---|---|
committer | 2021-03-11 17:25:29 +0000 | |
commit | 37aad605075130a6c682a8a60eee31bd9c3d428d (patch) | |
tree | 30d8d8451a075c8cf2ef38f10f6a6f2682f9cc50 | |
parent | db4888966aaa0f0be8b019b0a653175a9a1a00c3 (diff) |
Add apexFixtureFactory to apex package
Unlike the similar changes in other packages this change separates the
addition of the fixture factory and the conversion of the test...
methods to use them as there are a few tests that need converting to
use test fixtures first.
Bug: 181070625
Test: m nothing
Change-Id: Ic76523ba89fc1967631aeb682935935b5af116df
-rw-r--r-- | apex/Android.bp | 1 | ||||
-rw-r--r-- | apex/apex_test.go | 88 | ||||
-rw-r--r-- | apex/testing.go | 22 |
3 files changed, 111 insertions, 0 deletions
diff --git a/apex/Android.bp b/apex/Android.bp index 8a2edebdb..1890b89c3 100644 --- a/apex/Android.bp +++ b/apex/Android.bp @@ -25,6 +25,7 @@ bootstrap_go_package { "deapexer.go", "key.go", "prebuilt.go", + "testing.go", "vndk.go", ], testSrcs: [ diff --git a/apex/apex_test.go b/apex/apex_test.go index 08f54f724..3fde14458 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -127,6 +127,94 @@ func withUnbundledBuild(_ map[string][]byte, config android.Config) { config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true) } +var apexFixtureFactory = android.NewFixtureFactory( + &buildDir, + // General preparers in alphabetical order as test infrastructure will enforce correct + // registration order. + android.PrepareForTestWithAndroidBuildComponents, + bpf.PrepareForTestWithBpf, + cc.PrepareForTestWithCcBuildComponents, + java.PrepareForTestWithJavaDefaultModules, + prebuilt_etc.PrepareForTestWithPrebuiltEtc, + rust.PrepareForTestWithRustDefaultModules, + sh.PrepareForTestWithShBuildComponents, + + PrepareForTestWithApexBuildComponents, + + // Additional apex test specific preparers. + android.FixtureAddTextFile("system/sepolicy/Android.bp", ` + filegroup { + name: "myapex-file_contexts", + srcs: [ + "apex/myapex-file_contexts", + ], + } + `), + android.FixtureMergeMockFs(android.MockFS{ + "a.java": nil, + "PrebuiltAppFoo.apk": nil, + "PrebuiltAppFooPriv.apk": nil, + "build/make/target/product/security": nil, + "apex_manifest.json": nil, + "AndroidManifest.xml": nil, + "system/sepolicy/apex/myapex-file_contexts": nil, + "system/sepolicy/apex/myapex.updatable-file_contexts": nil, + "system/sepolicy/apex/myapex2-file_contexts": nil, + "system/sepolicy/apex/otherapex-file_contexts": nil, + "system/sepolicy/apex/com.android.vndk-file_contexts": nil, + "system/sepolicy/apex/com.android.vndk.current-file_contexts": nil, + "mylib.cpp": nil, + "mytest.cpp": nil, + "mytest1.cpp": nil, + "mytest2.cpp": nil, + "mytest3.cpp": nil, + "myprebuilt": nil, + "my_include": nil, + "foo/bar/MyClass.java": nil, + "prebuilt.jar": nil, + "prebuilt.so": nil, + "vendor/foo/devkeys/test.x509.pem": nil, + "vendor/foo/devkeys/test.pk8": nil, + "testkey.x509.pem": nil, + "testkey.pk8": nil, + "testkey.override.x509.pem": nil, + "testkey.override.pk8": nil, + "vendor/foo/devkeys/testkey.avbpubkey": nil, + "vendor/foo/devkeys/testkey.pem": nil, + "NOTICE": nil, + "custom_notice": nil, + "custom_notice_for_static_lib": nil, + "testkey2.avbpubkey": nil, + "testkey2.pem": nil, + "myapex-arm64.apex": nil, + "myapex-arm.apex": nil, + "myapex.apks": nil, + "frameworks/base/api/current.txt": nil, + "framework/aidl/a.aidl": nil, + "build/make/core/proguard.flags": nil, + "build/make/core/proguard_basic_keeps.flags": nil, + "dummy.txt": nil, + "baz": nil, + "bar/baz": nil, + "testdata/baz": nil, + "AppSet.apks": nil, + "foo.rs": nil, + "libfoo.jar": nil, + "libbar.jar": nil, + }, + ), + + android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.DeviceVndkVersion = proptools.StringPtr("current") + variables.DefaultAppCertificate = proptools.StringPtr("vendor/foo/devkeys/test") + variables.CertificateOverrides = []string{"myapex_keytest:myapex.certificate.override"} + variables.Platform_sdk_codename = proptools.StringPtr("Q") + variables.Platform_sdk_final = proptools.BoolPtr(false) + variables.Platform_version_active_codenames = []string{"Q"} + variables.Platform_vndk_version = proptools.StringPtr("VER") + }), +) + func testApexContext(_ *testing.T, bp string, handlers ...testCustomizer) (*android.TestContext, android.Config) { bp = bp + ` filegroup { diff --git a/apex/testing.go b/apex/testing.go new file mode 100644 index 000000000..e662cade3 --- /dev/null +++ b/apex/testing.go @@ -0,0 +1,22 @@ +// Copyright 2021 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package apex + +import "android/soong/android" + +var PrepareForTestWithApexBuildComponents = android.GroupFixturePreparers( + android.FixtureRegisterWithContext(registerApexBuildComponents), + android.FixtureRegisterWithContext(registerApexKeyBuildComponents), +) |