Remove test_per_src
Remove test_per_src, it never worked well and is incompatible
with all of the test infrastructure. Uses in the platform have
been removed, generally by replacing them with individual cc_test
modules.
Test: builds
Flag: TEST_ONLY
Change-Id: I257c035da35ca8358ae9423b46453878f54efeb1
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 143e86f..4134653 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -351,9 +351,6 @@
ctx.subAndroidMk(entries, test.testDecorator)
entries.Class = "NATIVE_TESTS"
- if Bool(test.Properties.Test_per_src) {
- entries.SubName = "_" + String(test.binaryDecorator.Properties.Stem)
- }
entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
if test.testConfig != nil {
entries.SetString("LOCAL_FULL_TEST_CONFIG", test.testConfig.String())
diff --git a/cc/cc.go b/cc/cc.go
index 24f6b83..134d89c 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -51,7 +51,6 @@
ctx.BottomUp("sdk", sdkMutator).Parallel()
ctx.BottomUp("llndk", llndkMutator).Parallel()
ctx.BottomUp("link", LinkageMutator).Parallel()
- ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
ctx.BottomUp("version", versionMutator).Parallel()
ctx.BottomUp("begin", BeginMutator).Parallel()
})
@@ -799,7 +798,6 @@
dataLibDepTag = dependencyTag{name: "data lib"}
dataBinDepTag = dependencyTag{name: "data bin"}
runtimeDepTag = installDependencyTag{name: "runtime lib"}
- testPerSrcDepTag = dependencyTag{name: "test_per_src"}
stubImplDepTag = dependencyTag{name: "stub_impl"}
JniFuzzLibTag = dependencyTag{name: "jni_fuzz_lib_tag"}
FdoProfileTag = dependencyTag{name: "fdo_profile"}
@@ -826,11 +824,6 @@
return depTag == runtimeDepTag
}
-func IsTestPerSrcDepTag(depTag blueprint.DependencyTag) bool {
- ccDepTag, ok := depTag.(dependencyTag)
- return ok && ccDepTag == testPerSrcDepTag
-}
-
// Module contains the properties and members used by all C/C++ module types, and implements
// the blueprint.Module interface. It delegates to compiler, linker, and installer interfaces
// to construct the output file. Behavior can be customized with a Customizer, or "decorator",
@@ -1786,11 +1779,6 @@
return nil
}
-func (c *Module) IsTestPerSrcAllTestsVariation() bool {
- test, ok := c.linker.(testPerSrc)
- return ok && test.isAllTestsVariation()
-}
-
func (c *Module) DataPaths() []android.DataPath {
if p, ok := c.installer.(interface {
dataPaths() []android.DataPath
@@ -1943,16 +1931,6 @@
TopLevelTarget: c.testModule,
})
- // Handle the case of a test module split by `test_per_src` mutator.
- //
- // The `test_per_src` mutator adds an extra variation named "", depending on all the other
- // `test_per_src` variations of the test module. Set `outputFile` to an empty path for this
- // module and return early, as this module does not produce an output file per se.
- if c.IsTestPerSrcAllTestsVariation() {
- c.outputFile = android.OptionalPath{}
- return
- }
-
c.Properties.SubName = GetSubnameProperty(actx, c)
apexInfo, _ := android.ModuleProvider(actx, android.ApexInfoProvider)
if !apexInfo.IsForPlatform() {
@@ -3758,14 +3736,12 @@
}
// Overrides ApexModule.IsInstallabeToApex()
-// Only shared/runtime libraries and "test_per_src" tests are installable to APEX.
+// Only shared/runtime libraries .
func (c *Module) IsInstallableToApex() bool {
if lib := c.library; lib != nil {
// Stub libs and prebuilt libs in a versioned SDK are not
// installable to APEX even though they are shared libs.
return lib.shared() && !lib.buildStubs()
- } else if _, ok := c.linker.(testPerSrc); ok {
- return true
}
return false
}
diff --git a/cc/cc_test_only_property_test.go b/cc/cc_test_only_property_test.go
index c14f34e..972e86b 100644
--- a/cc/cc_test_only_property_test.go
+++ b/cc/cc_test_only_property_test.go
@@ -78,38 +78,6 @@
}
}
-func TestTestOnlyValueWithTestPerSrcProp(t *testing.T) {
- t.Parallel()
- ctx := android.GroupFixturePreparers(
- prepareForCcTest,
- ).RunTestWithBp(t, `
- // These should be test-only
- cc_test { name: "cc-test",
- gtest: false,
- test_per_src: true,
- srcs: ["foo_test.cpp"],
- test_options: { unit_test: false, },
- }
- `)
-
- // Ensure all variation of test-per-src tests are marked test-only.
- ctx.VisitAllModules(func(m blueprint.Module) {
- testOnly := false
- if provider, ok := android.OtherModuleProvider(ctx.TestContext.OtherModuleProviderAdaptor(), m, android.TestOnlyProviderKey); ok {
- if provider.TestOnly {
- testOnly = true
- }
- }
- if module, ok := m.(*Module); ok {
- if testModule, ok := module.installer.(*testBinary); ok {
- if !testOnly && *testModule.Properties.Test_per_src {
- t.Errorf("%v is not test-only but should be", m)
- }
- }
- }
- })
-}
-
func TestTestOnlyInTeamsProto(t *testing.T) {
t.Parallel()
ctx := android.GroupFixturePreparers(
diff --git a/cc/test.go b/cc/test.go
index a96af31..f5bb761 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -15,11 +15,9 @@
package cc
import (
+ "github.com/google/blueprint/proptools"
"path/filepath"
"strconv"
- "strings"
-
- "github.com/google/blueprint/proptools"
"android/soong/android"
"android/soong/tradefed"
@@ -75,13 +73,9 @@
}
type TestBinaryProperties struct {
- // Create a separate binary for each source file. Useful when there is
- // global state that can not be torn down and reset between each test suite.
- Test_per_src *bool
-
// Disables the creation of a test-specific directory when used with
// relative_install_path. Useful if several tests need to be in the same
- // directory, but test_per_src doesn't work.
+ // directory.
No_named_install_directory *bool
// list of files or filegroup modules that provide data that should be installed alongside
@@ -174,86 +168,14 @@
return module.Init()
}
-type testPerSrc interface {
- testPerSrc() bool
- srcs() []string
- isAllTestsVariation() bool
- setSrc(string, string)
- unsetSrc()
-}
-
-func (test *testBinary) testPerSrc() bool {
- return Bool(test.Properties.Test_per_src)
-}
-
-func (test *testBinary) srcs() []string {
- return test.baseCompiler.Properties.Srcs
-}
-
func (test *testBinary) dataPaths() []android.DataPath {
return test.data
}
-func (test *testBinary) isAllTestsVariation() bool {
- stem := test.binaryDecorator.Properties.Stem
- return stem != nil && *stem == ""
-}
-
-func (test *testBinary) setSrc(name, src string) {
- test.baseCompiler.Properties.Srcs = []string{src}
- test.binaryDecorator.Properties.Stem = StringPtr(name)
-}
-
-func (test *testBinary) unsetSrc() {
- test.baseCompiler.Properties.Srcs = nil
- test.binaryDecorator.Properties.Stem = StringPtr("")
-}
-
func (test *testBinary) testBinary() bool {
return true
}
-var _ testPerSrc = (*testBinary)(nil)
-
-func TestPerSrcMutator(mctx android.BottomUpMutatorContext) {
- if m, ok := mctx.Module().(*Module); ok {
- if test, ok := m.linker.(testPerSrc); ok {
- numTests := len(test.srcs())
- if test.testPerSrc() && numTests > 0 {
- if duplicate, found := android.CheckDuplicate(test.srcs()); found {
- mctx.PropertyErrorf("srcs", "found a duplicate entry %q", duplicate)
- return
- }
- testNames := make([]string, numTests)
- for i, src := range test.srcs() {
- testNames[i] = strings.TrimSuffix(filepath.Base(src), filepath.Ext(src))
- }
- // In addition to creating one variation per test source file,
- // create an additional "all tests" variation named "", and have it
- // depends on all other test_per_src variations. This is useful to
- // create subsequent dependencies of a given module on all
- // test_per_src variations created above: by depending on
- // variation "", that module will transitively depend on all the
- // other test_per_src variations without the need to know their
- // name or even their number.
- testNames = append(testNames, "")
- tests := mctx.CreateLocalVariations(testNames...)
- allTests := tests[numTests]
- allTests.(*Module).linker.(testPerSrc).unsetSrc()
- // Prevent the "all tests" variation from being installable nor
- // exporting to Make, as it won't create any output file.
- allTests.(*Module).Properties.PreventInstall = true
- allTests.(*Module).Properties.HideFromMake = true
- for i, src := range test.srcs() {
- tests[i].(*Module).linker.(testPerSrc).setSrc(testNames[i], src)
- mctx.AddInterVariantDependency(testPerSrcDepTag, allTests, tests[i])
- }
- mctx.AliasVariation("")
- }
- }
- }
-}
-
type testDecorator struct {
LinkerProperties TestLinkerProperties
InstallerProperties TestInstallerProperties
@@ -382,10 +304,6 @@
}
moduleInfoJSON.TestConfig = append(moduleInfoJSON.TestConfig, test.extraTestConfigs.Strings()...)
- if Bool(test.Properties.Test_per_src) {
- moduleInfoJSON.SubName = "_" + String(test.binaryDecorator.Properties.Stem)
- }
-
moduleInfoJSON.DataDependencies = append(moduleInfoJSON.DataDependencies, test.Properties.Data_bins...)
if len(test.InstallerProperties.Test_suites) > 0 {