From f61d03d241334e355216e46fecb06a84e8626f8a Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 2 Nov 2023 16:56:39 -0700 Subject: Add TestContext parameter to ContentFromFileRuleForTests The next CL will need a TestContext parameter in ContentFromFileRuleForTests in order to retrieve the file rule contents from the Config. Add it and update all the tests that use it in order to simply review of the next CL. Bug: 306029038 Test: go test ./... Change-Id: Ia4b4c9854017ea3472fa2f8ba42cf7f72720496e --- apex/apex_test.go | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'apex/apex_test.go') diff --git a/apex/apex_test.go b/apex/apex_test.go index ddb9a4051..479bf1ac6 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -595,13 +595,15 @@ func TestBasicApex(t *testing.T) { t.Errorf("Could not find all expected symlinks! foo: %t, foo_link_64: %t. Command was %s", found_foo, found_foo_link_64, copyCmds) } - fullDepsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex").Output("depsinfo/fulllist.txt").Args["content"], "\\n") + fullDepsInfo := strings.Split(android.ContentFromFileRuleForTests(t, ctx, + ctx.ModuleForTests("myapex", "android_common_myapex").Output("depsinfo/fulllist.txt")), "\n") ensureListContains(t, fullDepsInfo, " myjar(minSdkVersion:(no version)) <- myapex") ensureListContains(t, fullDepsInfo, " mylib2(minSdkVersion:(no version)) <- mylib") ensureListContains(t, fullDepsInfo, " myotherjar(minSdkVersion:(no version)) <- myjar") ensureListContains(t, fullDepsInfo, " mysharedjar(minSdkVersion:(no version)) (external) <- myjar") - flatDepsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex").Output("depsinfo/flatlist.txt").Args["content"], "\\n") + flatDepsInfo := strings.Split(android.ContentFromFileRuleForTests(t, ctx, + ctx.ModuleForTests("myapex", "android_common_myapex").Output("depsinfo/flatlist.txt")), "\n") ensureListContains(t, flatDepsInfo, "myjar(minSdkVersion:(no version))") ensureListContains(t, flatDepsInfo, "mylib2(minSdkVersion:(no version))") ensureListContains(t, flatDepsInfo, "myotherjar(minSdkVersion:(no version))") @@ -1281,10 +1283,12 @@ func TestApexWithExplicitStubsDependency(t *testing.T) { // Ensure that libfoo stubs is not linking to libbar (since it is a stubs) ensureNotContains(t, libFooStubsLdFlags, "libbar.so") - fullDepsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2").Output("depsinfo/fulllist.txt").Args["content"], "\\n") + fullDepsInfo := strings.Split(android.ContentFromFileRuleForTests(t, ctx, + ctx.ModuleForTests("myapex2", "android_common_myapex2").Output("depsinfo/fulllist.txt")), "\n") ensureListContains(t, fullDepsInfo, " libfoo(minSdkVersion:(no version)) (external) <- mylib") - flatDepsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2").Output("depsinfo/flatlist.txt").Args["content"], "\\n") + flatDepsInfo := strings.Split(android.ContentFromFileRuleForTests(t, ctx, + ctx.ModuleForTests("myapex2", "android_common_myapex2").Output("depsinfo/flatlist.txt")), "\n") ensureListContains(t, flatDepsInfo, "libfoo(minSdkVersion:(no version)) (external)") } @@ -2030,7 +2034,8 @@ func TestTrackAllowedDeps(t *testing.T) { "out/soong/.intermediates/myapex2/android_common_myapex2/depsinfo/flatlist.txt") myapex := ctx.ModuleForTests("myapex", "android_common_myapex") - flatlist := strings.Split(myapex.Output("depsinfo/flatlist.txt").BuildParams.Args["content"], "\\n") + flatlist := strings.Split(android.ContentFromFileRuleForTests(t, ctx, + myapex.Output("depsinfo/flatlist.txt")), "\n") android.AssertStringListContains(t, "deps with stubs should be tracked in depsinfo as external dep", flatlist, "libbar(minSdkVersion:(no version)) (external)") android.AssertStringListDoesNotContain(t, "do not track if not available for platform", @@ -8154,7 +8159,7 @@ func TestAppBundle(t *testing.T) { `, withManifestPackageNameOverrides([]string{"AppFoo:com.android.foo"})) bundleConfigRule := ctx.ModuleForTests("myapex", "android_common_myapex").Output("bundle_config.json") - content := bundleConfigRule.Args["content"] + content := android.ContentFromFileRuleForTests(t, ctx, bundleConfigRule) ensureContains(t, content, `"compression":{"uncompressed_glob":["apex_payload.img","apex_manifest.*"]}`) ensureContains(t, content, `"apex_config":{"apex_embedded_apk_config":[{"package_name":"com.android.foo","path":"app/AppFoo@TEST.BUILD_ID/AppFoo.apk"}]}`) @@ -8181,7 +8186,7 @@ func TestAppSetBundle(t *testing.T) { }`) mod := ctx.ModuleForTests("myapex", "android_common_myapex") bundleConfigRule := mod.Output("bundle_config.json") - content := bundleConfigRule.Args["content"] + content := android.ContentFromFileRuleForTests(t, ctx, bundleConfigRule) ensureContains(t, content, `"compression":{"uncompressed_glob":["apex_payload.img","apex_manifest.*"]}`) s := mod.Rule("apexRule").Args["copy_commands"] copyCmds := regexp.MustCompile(" *&& *").Split(s, -1) @@ -9126,7 +9131,7 @@ func TestApexKeysTxt(t *testing.T) { `) myapex := ctx.ModuleForTests("myapex", "android_common_myapex") - content := myapex.Output("apexkeys.txt").BuildParams.Args["content"] + content := android.ContentFromFileRuleForTests(t, ctx, myapex.Output("apexkeys.txt")) ensureContains(t, content, `name="myapex.apex" public_key="vendor/foo/devkeys/testkey.avbpubkey" private_key="vendor/foo/devkeys/testkey.pem" container_certificate="vendor/foo/devkeys/test.x509.pem" container_private_key="vendor/foo/devkeys/test.pk8" partition="system" sign_tool="sign_myapex"`) } @@ -9166,9 +9171,11 @@ func TestApexKeysTxtOverrides(t *testing.T) { } `) - content := ctx.ModuleForTests("myapex", "android_common_myapex").Output("apexkeys.txt").BuildParams.Args["content"] + content := android.ContentFromFileRuleForTests(t, ctx, + ctx.ModuleForTests("myapex", "android_common_myapex").Output("apexkeys.txt")) ensureContains(t, content, `name="myapex.apex" public_key="vendor/foo/devkeys/testkey.avbpubkey" private_key="vendor/foo/devkeys/testkey.pem" container_certificate="vendor/foo/devkeys/test.x509.pem" container_private_key="vendor/foo/devkeys/test.pk8" partition="system" sign_tool="sign_myapex"`) - content = ctx.ModuleForTests("myapex_set", "android_common_myapex_set").Output("apexkeys.txt").BuildParams.Args["content"] + content = android.ContentFromFileRuleForTests(t, ctx, + ctx.ModuleForTests("myapex_set", "android_common_myapex_set").Output("apexkeys.txt")) ensureContains(t, content, `name="myapex_set.apex" public_key="PRESIGNED" private_key="PRESIGNED" container_certificate="PRESIGNED" container_private_key="PRESIGNED" partition="system"`) } -- cgit v1.2.3-59-g8ed1b