Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1ef3e2c authored by Paul Duffin's avatar Paul Duffin Committed by Automerger Merge Worker
Browse files

Merge changes Ifc96992e,Ic76523ba am: c10ee77e

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1628691

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I62a6d450597de5d28f09c58cc30475774ec8a795
parents 83eb3ba3 c10ee77e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ bootstrap_go_package {
        "deapexer.go",
        "key.go",
        "prebuilt.go",
        "testing.go",
        "vndk.go",
    ],
    testSrcs: [
+88 −0
Original line number Diff line number Diff line
@@ -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 {

apex/testing.go

0 → 100644
+22 −0
Original line number Diff line number Diff line
// 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),
)
+12 −6
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import (
	"android/soong/cc"
)

var ccTestFs = map[string][]byte{
var ccTestFs = android.MockFS{
	"Test.cpp":                        nil,
	"myinclude/Test.h":                nil,
	"myinclude-android/AndroidTest.h": nil,
@@ -32,7 +32,7 @@ var ccTestFs = map[string][]byte{
	"some/where/stubslib.map.txt":     nil,
}

func testSdkWithCc(t *testing.T, bp string) *testSdkResult {
func testSdkWithCc(t *testing.T, bp string) *android.TestResult {
	t.Helper()
	return testSdkWithFs(t, bp, ccTestFs)
}
@@ -808,7 +808,15 @@ module_exports_snapshot {
}

func TestSnapshotWithSingleHostOsType(t *testing.T) {
	ctx, config := testSdkContext(`
	result := sdkFixtureFactory.Extend(
		ccTestFs.AddToFixture(),
		cc.PrepareForTestOnLinuxBionic,
		android.FixtureModifyConfig(func(config android.Config) {
			config.Targets[android.LinuxBionic] = []android.Target{
				{android.LinuxBionic, android.Arch{ArchType: android.X86_64}, android.NativeBridgeDisabled, "", "", false},
			}
		}),
	).RunTestWithBp(t, `
		cc_defaults {
			name: "mydefaults",
			device_supported: false,
@@ -849,9 +857,7 @@ func TestSnapshotWithSingleHostOsType(t *testing.T) {
			],
			stl: "none",
		}
	`, ccTestFs, []android.OsType{android.LinuxBionic})

	result := runTests(t, ctx, config)
	`)

	CheckSnapshot(result, "myexports", "",
		checkUnversionedAndroidBpContents(`
+2 −1
Original line number Diff line number Diff line
@@ -17,10 +17,11 @@ package sdk
import (
	"testing"

	"android/soong/android"
	"android/soong/java"
)

func testSdkWithJava(t *testing.T, bp string) *testSdkResult {
func testSdkWithJava(t *testing.T, bp string) *android.TestResult {
	t.Helper()

	fs := map[string][]byte{
Loading