2016-07-29 21:48:20 +02:00
|
|
|
// Copyright 2016 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package cc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"android/soong/android"
|
2018-08-08 01:49:25 +02:00
|
|
|
"android/soong/tradefed"
|
2016-07-29 21:48:20 +02:00
|
|
|
)
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
type TestProperties struct {
|
2016-07-29 21:48:20 +02:00
|
|
|
// if set, build against the gtest library. Defaults to true.
|
2016-09-13 21:26:16 +02:00
|
|
|
Gtest *bool
|
2018-08-21 21:40:08 +02:00
|
|
|
|
|
|
|
// if set, use the isolated gtest runner. Defaults to false.
|
|
|
|
Isolated *bool
|
2016-07-30 02:28:03 +02:00
|
|
|
}
|
2016-07-29 21:48:20 +02:00
|
|
|
|
2018-10-01 13:23:14 +02:00
|
|
|
// Test option struct.
|
|
|
|
type TestOptions struct {
|
|
|
|
// The UID that you want to run the test as on a device.
|
|
|
|
Run_test_as *string
|
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
type TestBinaryProperties struct {
|
2016-07-29 21:48:20 +02:00
|
|
|
// 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
|
2016-12-27 23:40:40 +01:00
|
|
|
|
|
|
|
// 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.
|
|
|
|
No_named_install_directory *bool
|
2017-02-01 23:12:44 +01:00
|
|
|
|
|
|
|
// list of files or filegroup modules that provide data that should be installed alongside
|
|
|
|
// the test
|
2019-03-05 07:35:41 +01:00
|
|
|
Data []string `android:"path"`
|
2017-03-28 01:27:50 +02:00
|
|
|
|
|
|
|
// list of compatibility suites (for example "cts", "vts") that the module should be
|
|
|
|
// installed into.
|
2017-09-19 01:49:28 +02:00
|
|
|
Test_suites []string `android:"arch_variant"`
|
2018-08-03 00:00:46 +02:00
|
|
|
|
|
|
|
// the name of the test configuration (for example "AndroidTest.xml") that should be
|
|
|
|
// installed with the module.
|
2019-03-05 07:35:41 +01:00
|
|
|
Test_config *string `android:"path,arch_variant"`
|
2018-09-19 11:21:28 +02:00
|
|
|
|
|
|
|
// the name of the test configuration template (for example "AndroidTestTemplate.xml") that
|
|
|
|
// should be installed with the module.
|
2019-03-05 07:35:41 +01:00
|
|
|
Test_config_template *string `android:"path,arch_variant"`
|
2018-10-01 13:23:14 +02:00
|
|
|
|
|
|
|
// Test options.
|
|
|
|
Test_options TestOptions
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2017-11-03 05:38:28 +01:00
|
|
|
android.RegisterModuleType("cc_test", TestFactory)
|
|
|
|
android.RegisterModuleType("cc_test_library", TestLibraryFactory)
|
|
|
|
android.RegisterModuleType("cc_benchmark", BenchmarkFactory)
|
|
|
|
android.RegisterModuleType("cc_test_host", TestHostFactory)
|
|
|
|
android.RegisterModuleType("cc_benchmark_host", BenchmarkHostFactory)
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2019-03-20 01:00:29 +01:00
|
|
|
// cc_test generates a test config file and an executable binary file to test
|
|
|
|
// specific functionality on a device. The executable binary gets an implicit
|
|
|
|
// static_libs dependency on libgtests unless the gtest flag is set to false.
|
2017-11-03 05:38:28 +01:00
|
|
|
func TestFactory() android.Module {
|
2016-07-29 21:48:20 +02:00
|
|
|
module := NewTest(android.HostAndDeviceSupported)
|
|
|
|
return module.Init()
|
|
|
|
}
|
|
|
|
|
2019-03-20 01:00:29 +01:00
|
|
|
// cc_test_library creates an archive of files (i.e. .o files) which is later
|
|
|
|
// referenced by another module (such as cc_test, cc_defaults or cc_test_library)
|
|
|
|
// for archiving or linking.
|
2017-11-03 05:38:28 +01:00
|
|
|
func TestLibraryFactory() android.Module {
|
2016-07-29 21:48:20 +02:00
|
|
|
module := NewTestLibrary(android.HostAndDeviceSupported)
|
|
|
|
return module.Init()
|
|
|
|
}
|
|
|
|
|
2019-03-20 01:00:29 +01:00
|
|
|
// cc_benchmark compiles an executable binary that performs benchmark testing
|
|
|
|
// of a specific component in a device. Additional files such as test suites
|
|
|
|
// and test configuration are installed on the side of the compiled executed
|
|
|
|
// binary.
|
2017-11-03 05:38:28 +01:00
|
|
|
func BenchmarkFactory() android.Module {
|
2016-07-29 21:48:20 +02:00
|
|
|
module := NewBenchmark(android.HostAndDeviceSupported)
|
|
|
|
return module.Init()
|
|
|
|
}
|
|
|
|
|
2019-03-20 01:00:29 +01:00
|
|
|
// cc_test_host compiles a test host binary.
|
2017-11-03 05:38:28 +01:00
|
|
|
func TestHostFactory() android.Module {
|
2016-07-29 21:48:20 +02:00
|
|
|
module := NewTest(android.HostSupported)
|
|
|
|
return module.Init()
|
|
|
|
}
|
|
|
|
|
2019-03-20 01:00:29 +01:00
|
|
|
// cc_benchmark_host compiles an executable binary that performs benchmark
|
|
|
|
// testing of a specific component in the host. Additional files such as
|
|
|
|
// test suites and test configuration are installed on the side of the
|
|
|
|
// compiled executed binary.
|
2017-11-03 05:38:28 +01:00
|
|
|
func BenchmarkHostFactory() android.Module {
|
2016-07-29 21:48:20 +02:00
|
|
|
module := NewBenchmark(android.HostSupported)
|
|
|
|
return module.Init()
|
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
type testPerSrc interface {
|
|
|
|
testPerSrc() bool
|
|
|
|
srcs() []string
|
|
|
|
setSrc(string, string)
|
|
|
|
}
|
|
|
|
|
|
|
|
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) setSrc(name, src string) {
|
|
|
|
test.baseCompiler.Properties.Srcs = []string{src}
|
2017-11-07 19:57:05 +01:00
|
|
|
test.binaryDecorator.Properties.Stem = StringPtr(name)
|
2016-07-30 02:28:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var _ testPerSrc = (*testBinary)(nil)
|
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
func testPerSrcMutator(mctx android.BottomUpMutatorContext) {
|
|
|
|
if m, ok := mctx.Module().(*Module); ok {
|
2016-07-30 02:28:03 +02:00
|
|
|
if test, ok := m.linker.(testPerSrc); ok {
|
|
|
|
if test.testPerSrc() && len(test.srcs()) > 0 {
|
2019-02-28 10:06:34 +01:00
|
|
|
if duplicate, found := checkDuplicate(test.srcs()); found {
|
|
|
|
mctx.PropertyErrorf("srcs", "found a duplicate entry %q", duplicate)
|
|
|
|
return
|
|
|
|
}
|
2016-07-30 02:28:03 +02:00
|
|
|
testNames := make([]string, len(test.srcs()))
|
|
|
|
for i, src := range test.srcs() {
|
2016-07-29 21:48:20 +02:00
|
|
|
testNames[i] = strings.TrimSuffix(filepath.Base(src), filepath.Ext(src))
|
|
|
|
}
|
|
|
|
tests := mctx.CreateLocalVariations(testNames...)
|
2016-07-30 02:28:03 +02:00
|
|
|
for i, src := range test.srcs() {
|
|
|
|
tests[i].(*Module).linker.(testPerSrc).setSrc(testNames[i], src)
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-28 10:06:34 +01:00
|
|
|
func checkDuplicate(values []string) (duplicate string, found bool) {
|
|
|
|
seen := make(map[string]string)
|
|
|
|
for _, v := range values {
|
|
|
|
if duplicate, found = seen[v]; found {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
seen[v] = v
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
type testDecorator struct {
|
|
|
|
Properties TestProperties
|
|
|
|
linker *baseLinker
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-09-13 21:26:16 +02:00
|
|
|
func (test *testDecorator) gtest() bool {
|
2018-04-11 01:14:46 +02:00
|
|
|
return BoolDefault(test.Properties.Gtest, true)
|
2016-09-13 21:26:16 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (test *testDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
2016-09-13 21:26:16 +02:00
|
|
|
if !test.gtest() {
|
2016-07-29 21:48:20 +02:00
|
|
|
return flags
|
|
|
|
}
|
|
|
|
|
|
|
|
flags.CFlags = append(flags.CFlags, "-DGTEST_HAS_STD_STRING")
|
|
|
|
if ctx.Host() {
|
|
|
|
flags.CFlags = append(flags.CFlags, "-O0", "-g")
|
|
|
|
|
|
|
|
switch ctx.Os() {
|
|
|
|
case android.Windows:
|
|
|
|
flags.CFlags = append(flags.CFlags, "-DGTEST_OS_WINDOWS")
|
|
|
|
case android.Linux:
|
|
|
|
flags.CFlags = append(flags.CFlags, "-DGTEST_OS_LINUX")
|
|
|
|
case android.Darwin:
|
|
|
|
flags.CFlags = append(flags.CFlags, "-DGTEST_OS_MAC")
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
flags.CFlags = append(flags.CFlags, "-DGTEST_OS_LINUX_ANDROID")
|
|
|
|
}
|
|
|
|
|
|
|
|
return flags
|
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (test *testDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
|
2016-09-13 21:26:16 +02:00
|
|
|
if test.gtest() {
|
2017-09-28 02:01:44 +02:00
|
|
|
if ctx.useSdk() && ctx.Device() {
|
2018-02-10 00:22:59 +01:00
|
|
|
deps.StaticLibs = append(deps.StaticLibs, "libgtest_main_ndk_c++", "libgtest_ndk_c++")
|
2018-08-21 21:40:08 +02:00
|
|
|
} else if BoolDefault(test.Properties.Isolated, false) {
|
|
|
|
deps.StaticLibs = append(deps.StaticLibs, "libgtest_isolated_main")
|
2016-07-29 21:48:20 +02:00
|
|
|
} else {
|
|
|
|
deps.StaticLibs = append(deps.StaticLibs, "libgtest_main", "libgtest")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
return deps
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (test *testDecorator) linkerInit(ctx BaseModuleContext, linker *baseLinker) {
|
2018-05-07 08:41:20 +02:00
|
|
|
// 1. Add ../../lib[64] to rpath so that out/host/linux-x86/nativetest/<test dir>/<test> can
|
2017-07-01 02:27:55 +02:00
|
|
|
// find out/host/linux-x86/lib[64]/library.so
|
2018-05-07 08:41:20 +02:00
|
|
|
// 2. Add ../../../lib[64] to rpath so that out/host/linux-x86/testcases/<test dir>/<CPU>/<test> can
|
|
|
|
// also find out/host/linux-x86/lib[64]/library.so
|
|
|
|
runpaths := []string{"../../lib", "../../../lib"}
|
|
|
|
for _, runpath := range runpaths {
|
|
|
|
if ctx.toolchain().Is64Bit() {
|
|
|
|
runpath += "64"
|
|
|
|
}
|
|
|
|
linker.dynamicProperties.RunPaths = append(linker.dynamicProperties.RunPaths, runpath)
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
2017-07-01 02:27:55 +02:00
|
|
|
|
|
|
|
// add "" to rpath so that test binaries can find libraries in their own test directory
|
|
|
|
linker.dynamicProperties.RunPaths = append(linker.dynamicProperties.RunPaths, "")
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (test *testDecorator) linkerProps() []interface{} {
|
|
|
|
return []interface{}{&test.Properties}
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func NewTestInstaller() *baseInstaller {
|
|
|
|
return NewBaseInstaller("nativetest", "nativetest64", InstallInData)
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
type testBinary struct {
|
|
|
|
testDecorator
|
|
|
|
*binaryDecorator
|
|
|
|
*baseCompiler
|
|
|
|
Properties TestBinaryProperties
|
2017-02-01 23:12:44 +01:00
|
|
|
data android.Paths
|
2018-08-08 01:49:25 +02:00
|
|
|
testConfig android.Path
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (test *testBinary) linkerProps() []interface{} {
|
|
|
|
props := append(test.testDecorator.linkerProps(), test.binaryDecorator.linkerProps()...)
|
|
|
|
props = append(props, &test.Properties)
|
|
|
|
return props
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (test *testBinary) linkerInit(ctx BaseModuleContext) {
|
|
|
|
test.testDecorator.linkerInit(ctx, test.binaryDecorator.baseLinker)
|
|
|
|
test.binaryDecorator.linkerInit(ctx)
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-12-14 02:06:13 +01:00
|
|
|
func (test *testBinary) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
2016-07-30 02:28:03 +02:00
|
|
|
deps = test.testDecorator.linkerDeps(ctx, deps)
|
|
|
|
deps = test.binaryDecorator.linkerDeps(ctx, deps)
|
2016-07-29 21:48:20 +02:00
|
|
|
return deps
|
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (test *testBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
|
|
|
flags = test.binaryDecorator.linkerFlags(ctx, flags)
|
|
|
|
flags = test.testDecorator.linkerFlags(ctx, flags)
|
|
|
|
return flags
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (test *testBinary) install(ctx ModuleContext, file android.Path) {
|
2019-03-06 07:25:09 +01:00
|
|
|
test.data = android.PathsForModuleSrc(ctx, test.Properties.Data)
|
2019-02-28 17:45:28 +01:00
|
|
|
optionsMap := map[string]string{}
|
|
|
|
if Bool(test.testDecorator.Properties.Isolated) {
|
|
|
|
optionsMap["not-shardable"] = "true"
|
|
|
|
}
|
2018-10-01 13:23:14 +02:00
|
|
|
|
|
|
|
if test.Properties.Test_options.Run_test_as != nil {
|
|
|
|
optionsMap["run-test-as"] = String(test.Properties.Test_options.Run_test_as)
|
|
|
|
}
|
|
|
|
|
2018-09-19 11:21:28 +02:00
|
|
|
test.testConfig = tradefed.AutoGenNativeTestConfig(ctx, test.Properties.Test_config,
|
2019-02-28 17:45:28 +01:00
|
|
|
test.Properties.Test_config_template,
|
|
|
|
test.Properties.Test_suites, optionsMap)
|
2017-02-01 23:12:44 +01:00
|
|
|
|
2016-09-13 21:26:16 +02:00
|
|
|
test.binaryDecorator.baseInstaller.dir = "nativetest"
|
|
|
|
test.binaryDecorator.baseInstaller.dir64 = "nativetest64"
|
2016-12-27 23:40:40 +01:00
|
|
|
|
|
|
|
if !Bool(test.Properties.No_named_install_directory) {
|
|
|
|
test.binaryDecorator.baseInstaller.relative = ctx.ModuleName()
|
2017-11-07 19:57:05 +01:00
|
|
|
} else if String(test.binaryDecorator.baseInstaller.Properties.Relative_install_path) == "" {
|
2016-12-27 23:40:40 +01:00
|
|
|
ctx.PropertyErrorf("no_named_install_directory", "Module install directory may only be disabled if relative_install_path is set")
|
|
|
|
}
|
|
|
|
|
2016-08-30 00:53:15 +02:00
|
|
|
test.binaryDecorator.baseInstaller.install(ctx, file)
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewTest(hod android.HostOrDeviceSupported) *Module {
|
2016-07-30 02:28:03 +02:00
|
|
|
module, binary := NewBinary(hod)
|
|
|
|
module.multilib = android.MultilibBoth
|
2016-08-30 00:53:15 +02:00
|
|
|
binary.baseInstaller = NewTestInstaller()
|
2016-07-30 02:28:03 +02:00
|
|
|
|
|
|
|
test := &testBinary{
|
|
|
|
testDecorator: testDecorator{
|
|
|
|
linker: binary.baseLinker,
|
2016-07-29 21:48:20 +02:00
|
|
|
},
|
2016-07-30 02:28:03 +02:00
|
|
|
binaryDecorator: binary,
|
|
|
|
baseCompiler: NewBaseCompiler(),
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
2016-07-30 02:28:03 +02:00
|
|
|
module.compiler = test
|
|
|
|
module.linker = test
|
|
|
|
module.installer = test
|
2016-07-29 21:48:20 +02:00
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
type testLibrary struct {
|
|
|
|
testDecorator
|
|
|
|
*libraryDecorator
|
|
|
|
}
|
|
|
|
|
|
|
|
func (test *testLibrary) linkerProps() []interface{} {
|
|
|
|
return append(test.testDecorator.linkerProps(), test.libraryDecorator.linkerProps()...)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (test *testLibrary) linkerInit(ctx BaseModuleContext) {
|
|
|
|
test.testDecorator.linkerInit(ctx, test.libraryDecorator.baseLinker)
|
|
|
|
test.libraryDecorator.linkerInit(ctx)
|
|
|
|
}
|
|
|
|
|
2016-12-14 02:06:13 +01:00
|
|
|
func (test *testLibrary) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
2016-07-30 02:28:03 +02:00
|
|
|
deps = test.testDecorator.linkerDeps(ctx, deps)
|
|
|
|
deps = test.libraryDecorator.linkerDeps(ctx, deps)
|
|
|
|
return deps
|
|
|
|
}
|
|
|
|
|
|
|
|
func (test *testLibrary) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
|
|
|
flags = test.libraryDecorator.linkerFlags(ctx, flags)
|
|
|
|
flags = test.testDecorator.linkerFlags(ctx, flags)
|
|
|
|
return flags
|
|
|
|
}
|
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
func NewTestLibrary(hod android.HostOrDeviceSupported) *Module {
|
2016-12-09 23:46:15 +01:00
|
|
|
module, library := NewLibrary(android.HostAndDeviceSupported)
|
2016-09-01 01:32:55 +02:00
|
|
|
library.baseInstaller = NewTestInstaller()
|
2016-07-30 02:28:03 +02:00
|
|
|
test := &testLibrary{
|
|
|
|
testDecorator: testDecorator{
|
|
|
|
linker: library.baseLinker,
|
2016-07-29 21:48:20 +02:00
|
|
|
},
|
2016-07-30 02:28:03 +02:00
|
|
|
libraryDecorator: library,
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
2016-07-30 02:28:03 +02:00
|
|
|
module.linker = test
|
2016-07-29 21:48:20 +02:00
|
|
|
return module
|
|
|
|
}
|
|
|
|
|
2017-04-25 03:10:29 +02:00
|
|
|
type BenchmarkProperties struct {
|
2017-07-15 00:20:13 +02:00
|
|
|
// list of files or filegroup modules that provide data that should be installed alongside
|
|
|
|
// the test
|
2019-03-05 07:35:41 +01:00
|
|
|
Data []string `android:"path"`
|
2017-07-15 00:20:13 +02:00
|
|
|
|
2017-04-25 03:10:29 +02:00
|
|
|
// list of compatibility suites (for example "cts", "vts") that the module should be
|
|
|
|
// installed into.
|
2018-08-03 00:00:46 +02:00
|
|
|
Test_suites []string `android:"arch_variant"`
|
|
|
|
|
|
|
|
// the name of the test configuration (for example "AndroidTest.xml") that should be
|
|
|
|
// installed with the module.
|
2019-03-05 07:35:41 +01:00
|
|
|
Test_config *string `android:"path,arch_variant"`
|
2018-09-19 11:21:28 +02:00
|
|
|
|
|
|
|
// the name of the test configuration template (for example "AndroidTestTemplate.xml") that
|
|
|
|
// should be installed with the module.
|
2019-03-05 07:35:41 +01:00
|
|
|
Test_config_template *string `android:"path,arch_variant"`
|
2017-04-25 03:10:29 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
type benchmarkDecorator struct {
|
|
|
|
*binaryDecorator
|
2017-04-25 03:10:29 +02:00
|
|
|
Properties BenchmarkProperties
|
2017-07-15 00:20:13 +02:00
|
|
|
data android.Paths
|
2018-08-08 01:49:25 +02:00
|
|
|
testConfig android.Path
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (benchmark *benchmarkDecorator) linkerInit(ctx BaseModuleContext) {
|
|
|
|
runpath := "../../lib"
|
|
|
|
if ctx.toolchain().Is64Bit() {
|
|
|
|
runpath += "64"
|
|
|
|
}
|
|
|
|
benchmark.baseLinker.dynamicProperties.RunPaths = append(benchmark.baseLinker.dynamicProperties.RunPaths, runpath)
|
|
|
|
benchmark.binaryDecorator.linkerInit(ctx)
|
|
|
|
}
|
|
|
|
|
2017-04-25 03:10:29 +02:00
|
|
|
func (benchmark *benchmarkDecorator) linkerProps() []interface{} {
|
|
|
|
props := benchmark.binaryDecorator.linkerProps()
|
|
|
|
props = append(props, &benchmark.Properties)
|
|
|
|
return props
|
|
|
|
}
|
|
|
|
|
2016-12-14 02:06:13 +01:00
|
|
|
func (benchmark *benchmarkDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
2016-07-30 02:28:03 +02:00
|
|
|
deps = benchmark.binaryDecorator.linkerDeps(ctx, deps)
|
2016-07-29 21:48:20 +02:00
|
|
|
deps.StaticLibs = append(deps.StaticLibs, "libgoogle-benchmark")
|
|
|
|
return deps
|
|
|
|
}
|
|
|
|
|
2016-07-30 02:28:03 +02:00
|
|
|
func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Path) {
|
2019-03-06 07:25:09 +01:00
|
|
|
benchmark.data = android.PathsForModuleSrc(ctx, benchmark.Properties.Data)
|
2018-09-19 11:21:28 +02:00
|
|
|
benchmark.testConfig = tradefed.AutoGenNativeBenchmarkTestConfig(ctx, benchmark.Properties.Test_config,
|
2019-02-13 14:45:47 +01:00
|
|
|
benchmark.Properties.Test_config_template, benchmark.Properties.Test_suites)
|
2018-08-08 01:49:25 +02:00
|
|
|
|
2017-09-09 01:20:30 +02:00
|
|
|
benchmark.binaryDecorator.baseInstaller.dir = filepath.Join("benchmarktest", ctx.ModuleName())
|
|
|
|
benchmark.binaryDecorator.baseInstaller.dir64 = filepath.Join("benchmarktest64", ctx.ModuleName())
|
2016-08-30 00:53:15 +02:00
|
|
|
benchmark.binaryDecorator.baseInstaller.install(ctx, file)
|
2016-07-30 02:28:03 +02:00
|
|
|
}
|
|
|
|
|
2016-07-29 21:48:20 +02:00
|
|
|
func NewBenchmark(hod android.HostOrDeviceSupported) *Module {
|
2016-07-30 02:28:03 +02:00
|
|
|
module, binary := NewBinary(hod)
|
|
|
|
module.multilib = android.MultilibBoth
|
2017-09-09 01:20:30 +02:00
|
|
|
binary.baseInstaller = NewBaseInstaller("benchmarktest", "benchmarktest64", InstallInData)
|
2016-07-30 02:28:03 +02:00
|
|
|
|
|
|
|
benchmark := &benchmarkDecorator{
|
|
|
|
binaryDecorator: binary,
|
2016-07-29 21:48:20 +02:00
|
|
|
}
|
2016-07-30 02:28:03 +02:00
|
|
|
module.linker = benchmark
|
|
|
|
module.installer = benchmark
|
2016-07-29 21:48:20 +02:00
|
|
|
return module
|
|
|
|
}
|