Add tests for the ignored "profile_guided: true" property.

This is tricky and is worth some tests.

Bug: 241823638
Test: m nothing
Change-Id: I9c09451d075dca7563eb42c63812375cfd974fbf
diff --git a/apex/systemserver_classpath_fragment_test.go b/apex/systemserver_classpath_fragment_test.go
index c404a2e..1803fcf 100644
--- a/apex/systemserver_classpath_fragment_test.go
+++ b/apex/systemserver_classpath_fragment_test.go
@@ -15,10 +15,11 @@
 package apex
 
 import (
-	"android/soong/dexpreopt"
+	"strings"
 	"testing"
 
 	"android/soong/android"
+	"android/soong/dexpreopt"
 	"android/soong/java"
 )
 
@@ -31,7 +32,7 @@
 	result := android.GroupFixturePreparers(
 		prepareForTestWithSystemserverclasspathFragment,
 		prepareForTestWithMyapex,
-		dexpreopt.FixtureSetApexSystemServerJars("myapex:foo", "myapex:bar"),
+		dexpreopt.FixtureSetApexSystemServerJars("myapex:foo", "myapex:bar", "myapex:baz"),
 	).RunTestWithBp(t, `
 		apex {
 			name: "myapex",
@@ -69,11 +70,24 @@
 			],
 		}
 
+		java_library {
+			name: "baz",
+			srcs: ["d.java"],
+			installable: true,
+			dex_preopt: {
+				profile_guided: true, // ignored
+			},
+			apex_available: [
+				"myapex",
+			],
+		}
+
 		systemserverclasspath_fragment {
 			name: "mysystemserverclasspathfragment",
 			contents: [
 				"foo",
 				"bar",
+				"baz",
 			],
 			apex_available: [
 				"myapex",
@@ -81,17 +95,24 @@
 		}
 	`)
 
-	ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex_image", []string{
+	ctx := result.TestContext
+
+	ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
 		"etc/classpaths/systemserverclasspath.pb",
 		"javalib/foo.jar",
 		"javalib/bar.jar",
 		"javalib/bar.jar.prof",
+		"javalib/baz.jar",
 	})
 
-	java.CheckModuleDependencies(t, result.TestContext, "myapex", "android_common_myapex_image", []string{
+	java.CheckModuleDependencies(t, ctx, "myapex", "android_common_myapex_image", []string{
 		`myapex.key`,
 		`mysystemserverclasspathfragment`,
 	})
+
+	assertProfileGuided(t, ctx, "foo", "android_common_apex10000", false)
+	assertProfileGuided(t, ctx, "bar", "android_common_apex10000", true)
+	assertProfileGuided(t, ctx, "baz", "android_common_apex10000", false)
 }
 
 func TestSystemserverclasspathFragmentNoGeneratedProto(t *testing.T) {
@@ -251,7 +272,7 @@
 	result := android.GroupFixturePreparers(
 		prepareForTestWithSystemserverclasspathFragment,
 		prepareForTestWithMyapex,
-		dexpreopt.FixtureSetApexStandaloneSystemServerJars("myapex:foo", "myapex:bar"),
+		dexpreopt.FixtureSetApexStandaloneSystemServerJars("myapex:foo", "myapex:bar", "myapex:baz"),
 	).RunTestWithBp(t, `
 		apex {
 			name: "myapex",
@@ -289,11 +310,24 @@
 			],
 		}
 
+		java_library {
+			name: "baz",
+			srcs: ["d.java"],
+			dex_preopt: {
+				profile_guided: true, // ignored
+			},
+			installable: true,
+			apex_available: [
+				"myapex",
+			],
+		}
+
 		systemserverclasspath_fragment {
 			name: "mysystemserverclasspathfragment",
 			standalone_contents: [
 				"foo",
 				"bar",
+				"baz",
 			],
 			apex_available: [
 				"myapex",
@@ -301,12 +335,19 @@
 		}
 	`)
 
-	ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex_image", []string{
+	ctx := result.TestContext
+
+	ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{
 		"etc/classpaths/systemserverclasspath.pb",
 		"javalib/foo.jar",
 		"javalib/bar.jar",
 		"javalib/bar.jar.prof",
+		"javalib/baz.jar",
 	})
+
+	assertProfileGuided(t, ctx, "foo", "android_common_apex10000", false)
+	assertProfileGuided(t, ctx, "bar", "android_common_apex10000", true)
+	assertProfileGuided(t, ctx, "baz", "android_common_apex10000", false)
 }
 
 func TestPrebuiltStandaloneSystemserverclasspathFragmentContents(t *testing.T) {
@@ -353,3 +394,11 @@
 		`prebuilt_foo`,
 	})
 }
+
+func assertProfileGuided(t *testing.T, ctx *android.TestContext, moduleName string, variant string, expected bool) {
+	dexpreopt := ctx.ModuleForTests(moduleName, variant).Rule("dexpreopt")
+	actual := strings.Contains(dexpreopt.RuleParams.Command, "--profile-file=")
+	if expected != actual {
+		t.Fatalf("Expected profile-guided to be %v, got %v", expected, actual)
+	}
+}