ATest: GTest auto gen config support run_test_as in Android.bp .
Feature request from developer, support setting uid in Android.bp. Bug:113359343 Test: source build/envsetup.sh ; lunch vim platform_testing/tests/example/native/Android.bp add test_options: { run_test_as: "1234", }, in cc_test make hello_world_test cat out/target/product/xxxx/testcases/hello_world_test/hello_world_test.config Will see <option name="run-test-as" value="1234" /> below <test class="com.android.tradefed.testtype.GTest" > Change-Id: I5604af5f20c45728d19f4c01396a20a74997f8a8
This commit is contained in:
19
cc/test.go
19
cc/test.go
@@ -31,6 +31,12 @@ type TestProperties struct {
|
||||
Isolated *bool
|
||||
}
|
||||
|
||||
// Test option struct.
|
||||
type TestOptions struct {
|
||||
// the UID that you want to run in device.
|
||||
Run_test_as string `android:"arch_variant"`
|
||||
}
|
||||
|
||||
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.
|
||||
@@ -56,6 +62,9 @@ type TestBinaryProperties struct {
|
||||
// the name of the test configuration template (for example "AndroidTestTemplate.xml") that
|
||||
// should be installed with the module.
|
||||
Test_config_template *string `android:"arch_variant"`
|
||||
|
||||
// Test options.
|
||||
Test_options *TestOptions
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -244,8 +253,16 @@ func (test *testBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
||||
|
||||
func (test *testBinary) install(ctx ModuleContext, file android.Path) {
|
||||
test.data = ctx.ExpandSources(test.Properties.Data, nil)
|
||||
|
||||
// Append new line in template like below
|
||||
// <option name="run-test-as" value="1234" />
|
||||
optionsMap := map[string]string{}
|
||||
if test.Properties.Test_options != nil {
|
||||
optionsMap["run-test-as"] = string(test.Properties.Test_options.Run_test_as)
|
||||
}
|
||||
|
||||
test.testConfig = tradefed.AutoGenNativeTestConfig(ctx, test.Properties.Test_config,
|
||||
test.Properties.Test_config_template)
|
||||
test.Properties.Test_config_template, optionsMap)
|
||||
|
||||
test.binaryDecorator.baseInstaller.dir = "nativetest"
|
||||
test.binaryDecorator.baseInstaller.dir64 = "nativetest64"
|
||||
|
Reference in New Issue
Block a user