From 1db4a74a590e38f60f573fe23fa8ea137f6e2390 Mon Sep 17 00:00:00 2001 From: Kiyoung Kim Date: Mon, 1 Apr 2024 15:50:01 +0900 Subject: [PATCH] Remove VNDK information from Rust, etc, and sysprop tests VNDK is deprecated in 24Q2, so soong should be tested with no device and platform vndk versions. This change removes all VNDK related tests and VNDK versions from soong-etc, soong-rust and soong-sysprop tests. Bug: 330100430 Test: m nothing --no-skip-soong-tests passed Change-Id: Ie34d23f0facab31078de54682f7cc78d37fcd4be --- aconfig/codegen/rust_aconfig_library_test.go | 6 +- etc/prebuilt_etc_test.go | 121 ------------------- rust/image_test.go | 16 +-- rust/rust_test.go | 78 ++---------- rust/testing.go | 4 - sysprop/sysprop_test.go | 30 +++-- 6 files changed, 32 insertions(+), 223 deletions(-) diff --git a/aconfig/codegen/rust_aconfig_library_test.go b/aconfig/codegen/rust_aconfig_library_test.go index 330cecd73..e6b03bb7a 100644 --- a/aconfig/codegen/rust_aconfig_library_test.go +++ b/aconfig/codegen/rust_aconfig_library_test.go @@ -11,7 +11,7 @@ import ( func TestRustAconfigLibrary(t *testing.T) { result := android.GroupFixturePreparers( PrepareForTestWithAconfigBuildComponents, - rust.PrepareForTestWithRustIncludeVndk, + rust.PrepareForIntegrationTestWithRust, android.PrepareForTestWithArchMutator, android.PrepareForTestWithDefaults, android.PrepareForTestWithPrebuilts, @@ -90,7 +90,7 @@ func testRustCodegenModeHelper(t *testing.T, bpMode string, ruleMode string) { t.Helper() result := android.GroupFixturePreparers( PrepareForTestWithAconfigBuildComponents, - rust.PrepareForTestWithRustIncludeVndk). + rust.PrepareForIntegrationTestWithRust). ExtendWithErrorHandler(android.FixtureExpectsNoErrors). RunTestWithBp(t, fmt.Sprintf(` rust_library { @@ -142,7 +142,7 @@ func testIncorrectRustCodegenModeHelper(t *testing.T, bpMode string, err string) t.Helper() android.GroupFixturePreparers( PrepareForTestWithAconfigBuildComponents, - rust.PrepareForTestWithRustIncludeVndk). + rust.PrepareForIntegrationTestWithRust). ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern(err)). RunTestWithBp(t, fmt.Sprintf(` rust_library { diff --git a/etc/prebuilt_etc_test.go b/etc/prebuilt_etc_test.go index e346bd79f..dd9958caf 100644 --- a/etc/prebuilt_etc_test.go +++ b/etc/prebuilt_etc_test.go @@ -15,7 +15,6 @@ package etc import ( - "fmt" "os" "path/filepath" "testing" @@ -23,7 +22,6 @@ import ( "github.com/google/blueprint/proptools" "android/soong/android" - "android/soong/snapshot" ) func TestMain(m *testing.M) { @@ -40,18 +38,6 @@ var prepareForPrebuiltEtcTest = android.GroupFixturePreparers( }), ) -var prepareForPrebuiltEtcSnapshotTest = android.GroupFixturePreparers( - prepareForPrebuiltEtcTest, - android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) { - snapshot.VendorSnapshotImageSingleton.Init(ctx) - snapshot.RecoverySnapshotImageSingleton.Init(ctx) - }), - android.FixtureModifyConfig(func(config android.Config) { - config.TestProductVariables.DeviceVndkVersion = proptools.StringPtr("current") - config.TestProductVariables.RecoverySnapshotVersion = proptools.StringPtr("current") - }), -) - func TestPrebuiltEtcVariants(t *testing.T) { result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` prebuilt_etc { @@ -415,110 +401,3 @@ func TestPrebuiltRFSADirPath(t *testing.T) { }) } } - -func checkIfSnapshotTaken(t *testing.T, result *android.TestResult, image string, moduleName string) { - checkIfSnapshotExistAsExpected(t, result, image, moduleName, true) -} - -func checkIfSnapshotNotTaken(t *testing.T, result *android.TestResult, image string, moduleName string) { - checkIfSnapshotExistAsExpected(t, result, image, moduleName, false) -} - -func checkIfSnapshotExistAsExpected(t *testing.T, result *android.TestResult, image string, moduleName string, expectToExist bool) { - snapshotSingleton := result.SingletonForTests(image + "-snapshot") - archType := "arm64" - archVariant := "armv8-a" - archDir := fmt.Sprintf("arch-%s", archType) - - snapshotDir := fmt.Sprintf("%s-snapshot", image) - snapshotVariantPath := filepath.Join(snapshotDir, archType) - outputDir := filepath.Join(snapshotVariantPath, archDir, "etc") - imageVariant := "" - if image == "recovery" { - imageVariant = "recovery_" - } - mod := result.ModuleForTests(moduleName, fmt.Sprintf("android_%s%s_%s", imageVariant, archType, archVariant)) - outputFiles := mod.OutputFiles(t, "") - if len(outputFiles) != 1 { - t.Errorf("%q must have single output\n", moduleName) - return - } - snapshotPath := filepath.Join(outputDir, moduleName) - - if expectToExist { - out := snapshotSingleton.Output(snapshotPath) - - if out.Input.String() != outputFiles[0].String() { - t.Errorf("The input of snapshot %q must be %q, but %q", "prebuilt_vendor", out.Input.String(), outputFiles[0]) - } - - snapshotJsonPath := snapshotPath + ".json" - - if snapshotSingleton.MaybeOutput(snapshotJsonPath).Rule == nil { - t.Errorf("%q expected but not found", snapshotJsonPath) - } - } else { - out := snapshotSingleton.MaybeOutput(snapshotPath) - if out.Rule != nil { - t.Errorf("There must be no rule for module %q output file %q", moduleName, outputFiles[0]) - } - } -} - -func TestPrebuiltTakeSnapshot(t *testing.T) { - var testBp = ` - prebuilt_etc { - name: "prebuilt_vendor", - src: "foo.conf", - vendor: true, - } - - prebuilt_etc { - name: "prebuilt_vendor_indirect", - src: "foo.conf", - vendor: true, - } - - prebuilt_etc { - name: "prebuilt_recovery", - src: "bar.conf", - recovery: true, - } - - prebuilt_etc { - name: "prebuilt_recovery_indirect", - src: "bar.conf", - recovery: true, - } - ` - - t.Run("prebuilt: vendor and recovery snapshot", func(t *testing.T) { - result := prepareForPrebuiltEtcSnapshotTest.RunTestWithBp(t, testBp) - - checkIfSnapshotTaken(t, result, "vendor", "prebuilt_vendor") - checkIfSnapshotTaken(t, result, "vendor", "prebuilt_vendor_indirect") - checkIfSnapshotTaken(t, result, "recovery", "prebuilt_recovery") - checkIfSnapshotTaken(t, result, "recovery", "prebuilt_recovery_indirect") - }) - - t.Run("prebuilt: directed snapshot", func(t *testing.T) { - prepareForPrebuiltEtcDirectedSnapshotTest := android.GroupFixturePreparers( - prepareForPrebuiltEtcSnapshotTest, - android.FixtureModifyConfig(func(config android.Config) { - config.TestProductVariables.DirectedVendorSnapshot = true - config.TestProductVariables.VendorSnapshotModules = make(map[string]bool) - config.TestProductVariables.VendorSnapshotModules["prebuilt_vendor"] = true - config.TestProductVariables.DirectedRecoverySnapshot = true - config.TestProductVariables.RecoverySnapshotModules = make(map[string]bool) - config.TestProductVariables.RecoverySnapshotModules["prebuilt_recovery"] = true - }), - ) - - result := prepareForPrebuiltEtcDirectedSnapshotTest.RunTestWithBp(t, testBp) - - checkIfSnapshotTaken(t, result, "vendor", "prebuilt_vendor") - checkIfSnapshotNotTaken(t, result, "vendor", "prebuilt_vendor_indirect") - checkIfSnapshotTaken(t, result, "recovery", "prebuilt_recovery") - checkIfSnapshotNotTaken(t, result, "recovery", "prebuilt_recovery_indirect") - }) -} diff --git a/rust/image_test.go b/rust/image_test.go index fb4d9c170..ba94906c6 100644 --- a/rust/image_test.go +++ b/rust/image_test.go @@ -24,7 +24,7 @@ import ( // Test that cc modules can link against vendor_available rust_ffi_static libraries. func TestVendorLinkage(t *testing.T) { - ctx := testRustVndk(t, ` + ctx := testRust(t, ` cc_binary { name: "fizz_vendor", static_libs: ["libfoo_vendor"], @@ -38,7 +38,7 @@ func TestVendorLinkage(t *testing.T) { } `) - vendorBinary := ctx.ModuleForTests("fizz_vendor", "android_vendor.29_arm64_armv8-a").Module().(*cc.Module) + vendorBinary := ctx.ModuleForTests("fizz_vendor", "android_vendor_arm64_armv8-a").Module().(*cc.Module) if !android.InList("libfoo_vendor.vendor", vendorBinary.Properties.AndroidMkStaticLibs) { t.Errorf("vendorBinary should have a dependency on libfoo_vendor: %#v", vendorBinary.Properties.AndroidMkStaticLibs) @@ -46,8 +46,8 @@ func TestVendorLinkage(t *testing.T) { } // Test that variants which use the vndk emit the appropriate cfg flag. -func TestImageVndkCfgFlag(t *testing.T) { - ctx := testRustVndk(t, ` +func TestImageCfgFlag(t *testing.T) { + ctx := testRust(t, ` rust_ffi_static { name: "libfoo", crate_name: "foo", @@ -57,7 +57,7 @@ func TestImageVndkCfgFlag(t *testing.T) { } `) - vendor := ctx.ModuleForTests("libfoo", "android_vendor.29_arm64_armv8-a_static").Rule("rustc") + vendor := ctx.ModuleForTests("libfoo", "android_vendor_arm64_armv8-a_static").Rule("rustc") if !strings.Contains(vendor.Args["rustcFlags"], "--cfg 'android_vndk'") { t.Errorf("missing \"--cfg 'android_vndk'\" for libfoo vendor variant, rustcFlags: %#v", vendor.Args["rustcFlags"]) @@ -69,7 +69,7 @@ func TestImageVndkCfgFlag(t *testing.T) { t.Errorf("unexpected \"--cfg 'android_product'\" for libfoo vendor variant, rustcFlags: %#v", vendor.Args["rustcFlags"]) } - product := ctx.ModuleForTests("libfoo", "android_product.29_arm64_armv8-a_static").Rule("rustc") + product := ctx.ModuleForTests("libfoo", "android_product_arm64_armv8-a_static").Rule("rustc") if !strings.Contains(product.Args["rustcFlags"], "--cfg 'android_vndk'") { t.Errorf("missing \"--cfg 'android_vndk'\" for libfoo product variant, rustcFlags: %#v", product.Args["rustcFlags"]) } @@ -95,7 +95,7 @@ func TestImageVndkCfgFlag(t *testing.T) { // Test that cc modules can link against vendor_ramdisk_available rust_ffi_static libraries. func TestVendorRamdiskLinkage(t *testing.T) { - ctx := testRustVndk(t, ` + ctx := testRust(t, ` cc_library_static { name: "libcc_vendor_ramdisk", static_libs: ["libfoo_vendor_ramdisk"], @@ -119,7 +119,7 @@ func TestVendorRamdiskLinkage(t *testing.T) { // Test that prebuilt libraries cannot be made vendor available. func TestForbiddenVendorLinkage(t *testing.T) { - testRustVndkError(t, "Rust prebuilt modules not supported for non-system images.", ` + testRustError(t, "Rust prebuilt modules not supported for non-system images.", ` rust_prebuilt_library { name: "librust_prebuilt", crate_name: "rust_prebuilt", diff --git a/rust/rust_test.go b/rust/rust_test.go index 295a734b6..6d083f69f 100644 --- a/rust/rust_test.go +++ b/rust/rust_test.go @@ -37,11 +37,7 @@ var prepareForRustTest = android.GroupFixturePreparers( genrule.PrepareForTestWithGenRuleBuildComponents, - PrepareForTestWithRustIncludeVndk, - android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.DeviceVndkVersion = StringPtr("current") - variables.Platform_vndk_version = StringPtr("29") - }), + PrepareForIntegrationTestWithRust, ) var rustMockedFiles = android.MockFS{ @@ -73,60 +69,21 @@ func testRust(t *testing.T, bp string) *android.TestContext { return result.TestContext } -func testRustVndk(t *testing.T, bp string) *android.TestContext { - return testRustVndkFs(t, bp, rustMockedFiles) -} - const ( - sharedVendorVariant = "android_vendor.29_arm64_armv8-a_shared" - rlibVendorVariant = "android_vendor.29_arm64_armv8-a_rlib_rlib-std" - rlibDylibStdVendorVariant = "android_vendor.29_arm64_armv8-a_rlib_rlib-std" - dylibVendorVariant = "android_vendor.29_arm64_armv8-a_dylib" + sharedVendorVariant = "android_vendor_arm64_armv8-a_shared" + rlibVendorVariant = "android_vendor_arm64_armv8-a_rlib_rlib-std" + rlibDylibStdVendorVariant = "android_vendor_arm64_armv8-a_rlib_rlib-std" + dylibVendorVariant = "android_vendor_arm64_armv8-a_dylib" sharedRecoveryVariant = "android_recovery_arm64_armv8-a_shared" rlibRecoveryVariant = "android_recovery_arm64_armv8-a_rlib_dylib-std" rlibRlibStdRecoveryVariant = "android_recovery_arm64_armv8-a_rlib_rlib-std" dylibRecoveryVariant = "android_recovery_arm64_armv8-a_dylib" binaryCoreVariant = "android_arm64_armv8-a" - binaryVendorVariant = "android_vendor.29_arm64_armv8-a" - binaryProductVariant = "android_product.29_arm64_armv8-a" + binaryVendorVariant = "android_vendor_arm64_armv8-a" + binaryProductVariant = "android_product_arm64_armv8-a" binaryRecoveryVariant = "android_recovery_arm64_armv8-a" ) -func testRustVndkFs(t *testing.T, bp string, fs android.MockFS) *android.TestContext { - return testRustVndkFsVersions(t, bp, fs, "current", "current", "29") -} - -func testRustVndkFsVersions(t *testing.T, bp string, fs android.MockFS, device_version, product_version, vndk_version string) *android.TestContext { - skipTestIfOsNotSupported(t) - result := android.GroupFixturePreparers( - prepareForRustTest, - fs.AddToFixture(), - android.FixtureModifyProductVariables( - func(variables android.FixtureProductVariables) { - variables.DeviceVndkVersion = StringPtr(device_version) - variables.Platform_vndk_version = StringPtr(vndk_version) - }, - ), - ).RunTestWithBp(t, bp) - return result.TestContext -} - -func testRustRecoveryFsVersions(t *testing.T, bp string, fs android.MockFS, device_version, vndk_version, recovery_version string) *android.TestContext { - skipTestIfOsNotSupported(t) - result := android.GroupFixturePreparers( - prepareForRustTest, - fs.AddToFixture(), - android.FixtureModifyProductVariables( - func(variables android.FixtureProductVariables) { - variables.DeviceVndkVersion = StringPtr(device_version) - variables.RecoverySnapshotVersion = StringPtr(recovery_version) - variables.Platform_vndk_version = StringPtr(vndk_version) - }, - ), - ).RunTestWithBp(t, bp) - return result.TestContext -} - // testRustCov returns a TestContext in which a basic environment has been // setup. This environment explicitly enables coverage. func testRustCov(t *testing.T, bp string) *android.TestContext { @@ -158,27 +115,6 @@ func testRustError(t *testing.T, pattern string, bp string) { RunTestWithBp(t, bp) } -// testRustVndkError is similar to testRustError, but can be used to test VNDK-related errors. -func testRustVndkError(t *testing.T, pattern string, bp string) { - testRustVndkFsError(t, pattern, bp, rustMockedFiles) -} - -func testRustVndkFsError(t *testing.T, pattern string, bp string, fs android.MockFS) { - skipTestIfOsNotSupported(t) - android.GroupFixturePreparers( - prepareForRustTest, - fs.AddToFixture(), - android.FixtureModifyProductVariables( - func(variables android.FixtureProductVariables) { - variables.DeviceVndkVersion = StringPtr("current") - variables.Platform_vndk_version = StringPtr("VER") - }, - ), - ). - ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(pattern)). - RunTestWithBp(t, bp) -} - // testRustCtx is used to build a particular test environment. Unless your // tests requires a specific setup, prefer the wrapping functions: testRust, // testRustCov or testRustError. diff --git a/rust/testing.go b/rust/testing.go index 986e34e29..4e9a6c6fc 100644 --- a/rust/testing.go +++ b/rust/testing.go @@ -43,10 +43,6 @@ var PrepareForTestWithRustDefaultModules = android.GroupFixturePreparers( // Preparer that will allow use of all rust modules fully. var PrepareForIntegrationTestWithRust = android.GroupFixturePreparers( PrepareForTestWithRustDefaultModules, -) - -var PrepareForTestWithRustIncludeVndk = android.GroupFixturePreparers( - PrepareForIntegrationTestWithRust, cc.PrepareForIntegrationTestWithCc, ) diff --git a/sysprop/sysprop_test.go b/sysprop/sysprop_test.go index dfbbe7dd9..7d4e69d87 100644 --- a/sysprop/sysprop_test.go +++ b/sysprop/sysprop_test.go @@ -134,8 +134,6 @@ func test(t *testing.T, bp string) *android.TestResult { PrepareForTestWithSyspropBuildComponents, android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.DeviceSystemSdkVersions = []string{"28"} - variables.DeviceVndkVersion = proptools.StringPtr("current") - variables.Platform_vndk_version = proptools.StringPtr("29") variables.DeviceCurrentApiLevelForVendorModules = proptools.StringPtr("28") }), java.FixtureWithPrebuiltApis(map[string][]string{ @@ -258,10 +256,10 @@ func TestSyspropLibrary(t *testing.T) { // Check for generated cc_library for _, variant := range []string{ - "android_vendor.29_arm_armv7-a-neon_shared", - "android_vendor.29_arm_armv7-a-neon_static", - "android_vendor.29_arm64_armv8-a_shared", - "android_vendor.29_arm64_armv8-a_static", + "android_vendor_arm_armv7-a-neon_shared", + "android_vendor_arm_armv7-a-neon_static", + "android_vendor_arm64_armv8-a_shared", + "android_vendor_arm64_armv8-a_static", } { result.ModuleForTests("libsysprop-platform", variant) result.ModuleForTests("libsysprop-vendor", variant) @@ -270,10 +268,10 @@ func TestSyspropLibrary(t *testing.T) { // product variant of vendor-owned sysprop_library for _, variant := range []string{ - "android_product.29_arm_armv7-a-neon_shared", - "android_product.29_arm_armv7-a-neon_static", - "android_product.29_arm64_armv8-a_shared", - "android_product.29_arm64_armv8-a_static", + "android_product_arm_armv7-a-neon_shared", + "android_product_arm_armv7-a-neon_static", + "android_product_arm64_armv8-a_shared", + "android_product_arm64_armv8-a_static", } { result.ModuleForTests("libsysprop-vendor-on-product", variant) } @@ -296,16 +294,16 @@ func TestSyspropLibrary(t *testing.T) { // Check for exported includes coreVariant := "android_arm64_armv8-a_static" - vendorVariant := "android_vendor.29_arm64_armv8-a_static" - productVariant := "android_product.29_arm64_armv8-a_static" + vendorVariant := "android_vendor_arm64_armv8-a_static" + productVariant := "android_product_arm64_armv8-a_static" platformInternalPath := "libsysprop-platform/android_arm64_armv8-a_static/gen/sysprop/include" - platformPublicVendorPath := "libsysprop-platform/android_vendor.29_arm64_armv8-a_static/gen/sysprop/public/include" + platformPublicVendorPath := "libsysprop-platform/android_vendor_arm64_armv8-a_static/gen/sysprop/public/include" - platformOnProductPath := "libsysprop-platform-on-product/android_product.29_arm64_armv8-a_static/gen/sysprop/public/include" + platformOnProductPath := "libsysprop-platform-on-product/android_product_arm64_armv8-a_static/gen/sysprop/public/include" - vendorInternalPath := "libsysprop-vendor/android_vendor.29_arm64_armv8-a_static/gen/sysprop/include" - vendorOnProductPath := "libsysprop-vendor-on-product/android_product.29_arm64_armv8-a_static/gen/sysprop/public/include" + vendorInternalPath := "libsysprop-vendor/android_vendor_arm64_armv8-a_static/gen/sysprop/include" + vendorOnProductPath := "libsysprop-vendor-on-product/android_product_arm64_armv8-a_static/gen/sysprop/public/include" platformClient := result.ModuleForTests("cc-client-platform", coreVariant) platformFlags := platformClient.Rule("cc").Args["cFlags"]