|
@@ -16,6 +16,7 @@ package rust
|
|
|
|
|
|
import (
|
|
|
"android/soong/android"
|
|
|
+ "android/soong/cc"
|
|
|
"fmt"
|
|
|
"strings"
|
|
|
"testing"
|
|
@@ -31,13 +32,27 @@ func TestAfdoEnabled(t *testing.T) {
|
|
|
`
|
|
|
result := android.GroupFixturePreparers(
|
|
|
prepareForRustTest,
|
|
|
- android.FixtureAddTextFile("toolchain/pgo-profiles/sampling/foo.afdo", ""),
|
|
|
+ cc.PrepareForTestWithFdoProfile,
|
|
|
+ android.FixtureAddTextFile("afdo_profiles_package/foo.afdo", ""),
|
|
|
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
|
|
+ variables.AfdoProfiles = []string{
|
|
|
+ "foo://afdo_profiles_package:foo_afdo",
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ android.MockFS{
|
|
|
+ "afdo_profiles_package/Android.bp": []byte(`
|
|
|
+ fdo_profile {
|
|
|
+ name: "foo_afdo",
|
|
|
+ profile: "foo.afdo",
|
|
|
+ }
|
|
|
+ `),
|
|
|
+ }.AddToFixture(),
|
|
|
rustMockedFiles.AddToFixture(),
|
|
|
).RunTestWithBp(t, bp)
|
|
|
|
|
|
foo := result.ModuleForTests("foo", "android_arm64_armv8-a").Rule("rustc")
|
|
|
|
|
|
- expectedCFlag := fmt.Sprintf(afdoFlagFormat, "toolchain/pgo-profiles/sampling/foo.afdo")
|
|
|
+ expectedCFlag := fmt.Sprintf(afdoFlagFormat, "afdo_profiles_package/foo.afdo")
|
|
|
|
|
|
if !strings.Contains(foo.Args["rustcFlags"], expectedCFlag) {
|
|
|
t.Errorf("Expected 'foo' to enable afdo, but did not find %q in cflags %q", expectedCFlag, foo.Args["rustcFlags"])
|
|
@@ -55,16 +70,37 @@ func TestAfdoEnabledWithMultiArchs(t *testing.T) {
|
|
|
`
|
|
|
result := android.GroupFixturePreparers(
|
|
|
prepareForRustTest,
|
|
|
- android.FixtureAddTextFile("toolchain/pgo-profiles/sampling/foo_arm.afdo", ""),
|
|
|
- android.FixtureAddTextFile("toolchain/pgo-profiles/sampling/foo_arm64.afdo", ""),
|
|
|
+ cc.PrepareForTestWithFdoProfile,
|
|
|
+ android.FixtureAddTextFile("afdo_profiles_package/foo_arm.afdo", ""),
|
|
|
+ android.FixtureAddTextFile("afdo_profiles_package/foo_arm64.afdo", ""),
|
|
|
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
|
|
+ variables.AfdoProfiles = []string{
|
|
|
+ "foo://afdo_profiles_package:foo_afdo",
|
|
|
+ }
|
|
|
+ }),
|
|
|
+ android.MockFS{
|
|
|
+ "afdo_profiles_package/Android.bp": []byte(`
|
|
|
+ fdo_profile {
|
|
|
+ name: "foo_afdo",
|
|
|
+ arch: {
|
|
|
+ arm: {
|
|
|
+ profile: "foo_arm.afdo",
|
|
|
+ },
|
|
|
+ arm64: {
|
|
|
+ profile: "foo_arm64.afdo",
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ `),
|
|
|
+ }.AddToFixture(),
|
|
|
rustMockedFiles.AddToFixture(),
|
|
|
).RunTestWithBp(t, bp)
|
|
|
|
|
|
fooArm := result.ModuleForTests("foo", "android_arm_armv7-a-neon").Rule("rustc")
|
|
|
fooArm64 := result.ModuleForTests("foo", "android_arm64_armv8-a").Rule("rustc")
|
|
|
|
|
|
- expectedCFlagArm := fmt.Sprintf(afdoFlagFormat, "toolchain/pgo-profiles/sampling/foo_arm.afdo")
|
|
|
- expectedCFlagArm64 := fmt.Sprintf(afdoFlagFormat, "toolchain/pgo-profiles/sampling/foo_arm64.afdo")
|
|
|
+ expectedCFlagArm := fmt.Sprintf(afdoFlagFormat, "afdo_profiles_package/foo_arm.afdo")
|
|
|
+ expectedCFlagArm64 := fmt.Sprintf(afdoFlagFormat, "afdo_profiles_package/foo_arm64.afdo")
|
|
|
|
|
|
if !strings.Contains(fooArm.Args["rustcFlags"], expectedCFlagArm) {
|
|
|
t.Errorf("Expected 'fooArm' to enable afdo, but did not find %q in cflags %q", expectedCFlagArm, fooArm.Args["rustcFlags"])
|