Remove buildDir from apex package

Bug: 182885307
Test: m nothing
Change-Id: I71cbfd79e2fb4b1cbd2914ffab76570548d57c61
This commit is contained in:
Paul Duffin 2021-03-29 00:21:08 +01:00
parent f53555da2f
commit 37ba344e40

View file

@ -16,7 +16,6 @@ package apex
import ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
@ -38,8 +37,6 @@ import (
"android/soong/sh" "android/soong/sh"
) )
var buildDir string
// names returns name list from white space separated string // names returns name list from white space separated string
func names(s string) (ns []string) { func names(s string) (ns []string) {
for _, n := range strings.Split(s, " ") { for _, n := range strings.Split(s, " ") {
@ -118,7 +115,7 @@ var withUnbundledBuild = android.FixtureModifyProductVariables(
) )
var apexFixtureFactory = android.NewFixtureFactory( var apexFixtureFactory = android.NewFixtureFactory(
&buildDir, nil,
// General preparers in alphabetical order as test infrastructure will enforce correct // General preparers in alphabetical order as test infrastructure will enforce correct
// registration order. // registration order.
android.PrepareForTestWithAndroidBuildComponents, android.PrepareForTestWithAndroidBuildComponents,
@ -208,18 +205,6 @@ var prepareForTestWithMyapex = android.FixtureMergeMockFs(android.MockFS{
"system/sepolicy/apex/myapex-file_contexts": nil, "system/sepolicy/apex/myapex-file_contexts": nil,
}) })
func setUp() {
var err error
buildDir, err = ioutil.TempDir("", "soong_apex_test")
if err != nil {
panic(err)
}
}
func tearDown() {
_ = os.RemoveAll(buildDir)
}
// ensure that 'result' equals 'expected' // ensure that 'result' equals 'expected'
func ensureEquals(t *testing.T, result string, expected string) { func ensureEquals(t *testing.T, result string, expected string) {
t.Helper() t.Helper()
@ -500,7 +485,7 @@ func TestBasicApex(t *testing.T) {
} }
`) `)
apexRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexRule") apexRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexRule").RelativeToTop()
// Make sure that Android.mk is created // Make sure that Android.mk is created
ab := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle) ab := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
@ -515,7 +500,7 @@ func TestBasicApex(t *testing.T) {
optFlags := apexRule.Args["opt_flags"] optFlags := apexRule.Args["opt_flags"]
ensureContains(t, optFlags, "--pubkey vendor/foo/devkeys/testkey.avbpubkey") ensureContains(t, optFlags, "--pubkey vendor/foo/devkeys/testkey.avbpubkey")
// Ensure that the NOTICE output is being packaged as an asset. // Ensure that the NOTICE output is being packaged as an asset.
ensureContains(t, optFlags, "--assets_dir "+buildDir+"/.intermediates/myapex/android_common_myapex_image/NOTICE") ensureContains(t, optFlags, "--assets_dir out/soong/.intermediates/myapex/android_common_myapex_image/NOTICE")
copyCmds := apexRule.Args["copy_commands"] copyCmds := apexRule.Args["copy_commands"]
@ -2468,8 +2453,8 @@ func TestVendorApex(t *testing.T) {
prefix := "TARGET_" prefix := "TARGET_"
var builder strings.Builder var builder strings.Builder
data.Custom(&builder, name, prefix, "", data) data.Custom(&builder, name, prefix, "", data)
androidMk := builder.String() androidMk := android.StringRelativeToTop(ctx.Config(), builder.String())
installPath := path.Join(buildDir, "../target/product/test_device/vendor/apex") installPath := "out/target/product/test_device/vendor/apex"
ensureContains(t, androidMk, "LOCAL_MODULE_PATH := "+installPath) ensureContains(t, androidMk, "LOCAL_MODULE_PATH := "+installPath)
apexManifestRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexManifestRule") apexManifestRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexManifestRule")
@ -2513,13 +2498,13 @@ func TestVendorApex_use_vndk_as_stable(t *testing.T) {
vendorVariant := "android_vendor.VER_arm64_armv8-a" vendorVariant := "android_vendor.VER_arm64_armv8-a"
ldRule := ctx.ModuleForTests("mybin", vendorVariant+"_apex10000").Rule("ld") ldRule := ctx.ModuleForTests("mybin", vendorVariant+"_apex10000").Rule("ld").RelativeToTop()
libs := names(ldRule.Args["libFlags"]) libs := names(ldRule.Args["libFlags"])
// VNDK libs(libvndk/libc++) as they are // VNDK libs(libvndk/libc++) as they are
ensureListContains(t, libs, buildDir+"/.intermediates/libvndk/"+vendorVariant+"_shared/libvndk.so") ensureListContains(t, libs, "out/soong/.intermediates/libvndk/"+vendorVariant+"_shared/libvndk.so")
ensureListContains(t, libs, buildDir+"/.intermediates/"+cc.DefaultCcCommonTestModulesDir+"libc++/"+vendorVariant+"_shared/libc++.so") ensureListContains(t, libs, "out/soong/.intermediates/"+cc.DefaultCcCommonTestModulesDir+"libc++/"+vendorVariant+"_shared/libc++.so")
// non-stable Vendor libs as APEX variants // non-stable Vendor libs as APEX variants
ensureListContains(t, libs, buildDir+"/.intermediates/libvendor/"+vendorVariant+"_shared_apex10000/libvendor.so") ensureListContains(t, libs, "out/soong/.intermediates/libvendor/"+vendorVariant+"_shared_apex10000/libvendor.so")
// VNDK libs are not included when use_vndk_as_stable: true // VNDK libs are not included when use_vndk_as_stable: true
ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{ ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
@ -4092,15 +4077,15 @@ func TestApexInVariousPartition(t *testing.T) {
`) `)
apex := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle) apex := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
expected := buildDir + "/target/product/test_device/" + tc.parition + "/apex" expected := "out/soong/target/product/test_device/" + tc.parition + "/apex"
actual := apex.installDir.String() actual := apex.installDir.RelativeToTop().String()
if actual != expected { if actual != expected {
t.Errorf("wrong install path. expected %q. actual %q", expected, actual) t.Errorf("wrong install path. expected %q. actual %q", expected, actual)
} }
flattened := ctx.ModuleForTests("myapex", "android_common_myapex_flattened").Module().(*apexBundle) flattened := ctx.ModuleForTests("myapex", "android_common_myapex_flattened").Module().(*apexBundle)
expected = buildDir + "/target/product/test_device/" + tc.flattenedPartition + "/apex" expected = "out/soong/target/product/test_device/" + tc.flattenedPartition + "/apex"
actual = flattened.installDir.String() actual = flattened.installDir.RelativeToTop().String()
if actual != expected { if actual != expected {
t.Errorf("wrong install path. expected %q. actual %q", expected, actual) t.Errorf("wrong install path. expected %q. actual %q", expected, actual)
} }
@ -6331,7 +6316,7 @@ func TestAppSetBundlePrebuilt(t *testing.T) {
) )
m := ctx.ModuleForTests("myapex", "android_common") m := ctx.ModuleForTests("myapex", "android_common")
extractedApex := m.Output(buildDir + "/.intermediates/myapex/android_common/foo_v2.apex") extractedApex := m.Output("out/soong/.intermediates/myapex/android_common/foo_v2.apex")
actual := extractedApex.Inputs actual := extractedApex.Inputs
if len(actual) != 1 { if len(actual) != 1 {
@ -6458,7 +6443,7 @@ func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, transformDexpreopt
for k, v := range filesForSdkLibrary { for k, v := range filesForSdkLibrary {
fs[k] = v fs[k] = v
} }
config := android.TestArchConfig(buildDir, nil, bp, fs) config := android.TestArchConfig(t.TempDir(), nil, bp, fs)
ctx := android.NewTestArchContext(config) ctx := android.NewTestArchContext(config)
ctx.RegisterModuleType("apex", BundleFactory) ctx.RegisterModuleType("apex", BundleFactory)
@ -6679,7 +6664,7 @@ func testApexPermittedPackagesRules(t *testing.T, errmsg, bp string, apexBootJar
"system/sepolicy/apex/myapex-file_contexts": nil, "system/sepolicy/apex/myapex-file_contexts": nil,
} }
config := android.TestArchConfig(buildDir, nil, bp, fs) config := android.TestArchConfig(t.TempDir(), nil, bp, fs)
android.SetTestNeverallowRules(config, rules) android.SetTestNeverallowRules(config, rules)
updatableBootJars := make([]string, 0, len(apexBootJars)) updatableBootJars := make([]string, 0, len(apexBootJars))
for _, apexBootJar := range apexBootJars { for _, apexBootJar := range apexBootJars {
@ -6908,7 +6893,7 @@ func TestApexSet(t *testing.T) {
m := ctx.ModuleForTests("myapex", "android_common") m := ctx.ModuleForTests("myapex", "android_common")
// Check extract_apks tool parameters. // Check extract_apks tool parameters.
extractedApex := m.Output(buildDir + "/.intermediates/myapex/android_common/foo_v2.apex") extractedApex := m.Output("out/soong/.intermediates/myapex/android_common/foo_v2.apex")
actual := extractedApex.Args["abis"] actual := extractedApex.Args["abis"]
expected := "ARMEABI_V7A,ARM64_V8A" expected := "ARMEABI_V7A,ARM64_V8A"
if actual != expected { if actual != expected {
@ -7399,12 +7384,5 @@ func TestPrebuiltStubLibDep(t *testing.T) {
} }
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
run := func() int { os.Exit(m.Run())
setUp()
defer tearDown()
return m.Run()
}
os.Exit(run())
} }