From d136a6aa010d9b2ab4cc32edf56ae20a827bc8b9 Mon Sep 17 00:00:00 2001 From: Yu Liu Date: Mon, 21 Aug 2023 21:23:04 +0000 Subject: [PATCH] Support dynamic config file for cc_test. Bug: 280028705 Test: local build Change-Id: Ife445f6a7642bf08651ed7a9501a60950f05f9c4 --- bp2build/cc_test_conversion_test.go | 4 +++- tradefed/autogen_bazel.go | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bp2build/cc_test_conversion_test.go b/bp2build/cc_test_conversion_test.go index abceac844..76bbb5798 100644 --- a/bp2build/cc_test_conversion_test.go +++ b/bp2build/cc_test_conversion_test.go @@ -238,7 +238,8 @@ func TestCcTest_TestConfigAndroidTestXML(t *testing.T) { runCcTestTestCase(t, ccTestBp2buildTestCase{ description: "cc test that defaults to test config AndroidTest.xml", filesystem: map[string]string{ - "AndroidTest.xml": "", + "AndroidTest.xml": "", + "DynamicConfig.xml": "", }, blueprint: ` cc_test { @@ -253,6 +254,7 @@ cc_test { "srcs": `["test.cpp"]`, "target_compatible_with": `["//build/bazel/platforms/os:android"]`, "test_config": `"AndroidTest.xml"`, + "dynamic_config": `"DynamicConfig.xml"`, "deps": `[ ":libgtest_main", ":libgtest", diff --git a/tradefed/autogen_bazel.go b/tradefed/autogen_bazel.go index 9575f7aef..8283984c9 100644 --- a/tradefed/autogen_bazel.go +++ b/tradefed/autogen_bazel.go @@ -39,7 +39,8 @@ const ( ) type TestConfigAttributes struct { - Test_config *bazel.Label + Test_config *bazel.Label + Dynamic_config *bazel.Label Auto_generate_test_config *bool Template_test_config *bazel.Label @@ -58,6 +59,11 @@ func GetTestConfigAttributes( templateInstallBase *string) TestConfigAttributes { attrs := TestConfigAttributes{} + + dynamicConfig := "DynamicConfig.xml" + c, _ := android.BazelStringOrLabelFromProp(ctx, &dynamicConfig) + attrs.Dynamic_config = c.Value + attrs.Test_config = GetTestConfig(ctx, testConfig) // do not generate a test config if // 1) test config already found