From bdce0dfbdf04384f7a740aefcd320bda0bc6a56b Mon Sep 17 00:00:00 2001 From: Liz Kammer Date: Fri, 15 Oct 2021 13:34:27 -0400 Subject: [PATCH] Add tests for defaults used in conditions_default Bug: 203123704 Test: go test soong tests Change-Id: Ia12c51d01108ad1f311d738b182d4bb94c500810 --- android/soong_config_modules_test.go | 38 ++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/android/soong_config_modules_test.go b/android/soong_config_modules_test.go index b2f8eaad8..0ec9bcbd5 100644 --- a/android/soong_config_modules_test.go +++ b/android/soong_config_modules_test.go @@ -60,7 +60,7 @@ func TestSoongConfigModule(t *testing.T) { module_type: "test", config_namespace: "acme", variables: ["board", "feature1", "FEATURE3", "unused_string_var"], - bool_variables: ["feature2", "unused_feature"], + bool_variables: ["feature2", "unused_feature", "always_true"], value_variables: ["size", "unused_size"], properties: ["cflags", "srcs", "defaults"], } @@ -148,6 +148,11 @@ func TestSoongConfigModule(t *testing.T) { cflags: ["DEFAULT_B"], } + test_defaults { + name: "foo_defaults_always_true", + cflags: ["DEFAULT_ALWAYS_TRUE"], + } + acme_test { name: "foo_with_defaults", cflags: ["-DGENERIC"], @@ -176,6 +181,15 @@ func TestSoongConfigModule(t *testing.T) { FEATURE3: { cflags: ["-DFEATURE3"], }, + always_true: { + defaults: ["foo_defaults_always_true"], + conditions_default: { + // verify that conditions_default is skipped if the + // soong config variable is true by specifying a + // non-existent module in conditions_default + defaults: ["//nonexistent:defaults"], + } + }, }, } ` @@ -205,6 +219,7 @@ func TestSoongConfigModule(t *testing.T) { "unused_feature": "true", // unused "unused_size": "1", // unused "unused_string_var": "a", // unused + "always_true": "true", }, }), fooExpectedFlags: []string{ @@ -217,6 +232,7 @@ func TestSoongConfigModule(t *testing.T) { }, fooDefaultsExpectedFlags: []string{ "DEFAULT_A", + "DEFAULT_ALWAYS_TRUE", "DEFAULT", "-DGENERIC", "-DSIZE=42", @@ -227,7 +243,10 @@ func TestSoongConfigModule(t *testing.T) { { name: "empty_prop_for_string_var", preparer: fixtureForVendorVars(map[string]map[string]string{ - "acme": {"board": "soc_c"}}), + "acme": { + "board": "soc_c", + "always_true": "true", + }}), fooExpectedFlags: []string{ "DEFAULT", "-DGENERIC", @@ -236,6 +255,7 @@ func TestSoongConfigModule(t *testing.T) { "-DF1_CONDITIONS_DEFAULT", }, fooDefaultsExpectedFlags: []string{ + "DEFAULT_ALWAYS_TRUE", "DEFAULT", "-DGENERIC", }, @@ -243,7 +263,10 @@ func TestSoongConfigModule(t *testing.T) { { name: "unused_string_var", preparer: fixtureForVendorVars(map[string]map[string]string{ - "acme": {"board": "soc_d"}}), + "acme": { + "board": "soc_d", + "always_true": "true", + }}), fooExpectedFlags: []string{ "DEFAULT", "-DGENERIC", @@ -253,14 +276,18 @@ func TestSoongConfigModule(t *testing.T) { "-DF1_CONDITIONS_DEFAULT", }, fooDefaultsExpectedFlags: []string{ + "DEFAULT_ALWAYS_TRUE", "DEFAULT", "-DGENERIC", }, }, { - name: "conditions_default", - preparer: fixtureForVendorVars(map[string]map[string]string{}), + name: "conditions_default", + preparer: fixtureForVendorVars(map[string]map[string]string{ + "acme": { + "always_true": "true", + }}), fooExpectedFlags: []string{ "DEFAULT", "-DGENERIC", @@ -270,6 +297,7 @@ func TestSoongConfigModule(t *testing.T) { "-DF1_CONDITIONS_DEFAULT", }, fooDefaultsExpectedFlags: []string{ + "DEFAULT_ALWAYS_TRUE", "DEFAULT", "-DGENERIC", },