diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/artifact_path_requirements/inherit1.rbc | 21 | ||||
-rw-r--r-- | tests/artifact_path_requirements/inherit2.rbc | 22 | ||||
-rw-r--r-- | tests/artifact_path_requirements/inherit3.rbc | 22 | ||||
-rw-r--r-- | tests/artifact_path_requirements/inherit4.rbc | 21 | ||||
-rw-r--r-- | tests/artifact_path_requirements/product.rbc | 24 | ||||
-rw-r--r-- | tests/artifact_path_requirements/test.rbc | 27 | ||||
-rw-r--r-- | tests/run.rbc | 55 | ||||
-rw-r--r-- | tests/single_value_inheritance/test.rbc | 8 |
8 files changed, 170 insertions, 30 deletions
diff --git a/tests/artifact_path_requirements/inherit1.rbc b/tests/artifact_path_requirements/inherit1.rbc new file mode 100644 index 0000000000..dcef1bf089 --- /dev/null +++ b/tests/artifact_path_requirements/inherit1.rbc @@ -0,0 +1,21 @@ +# Copyright 2022 Google LLC +# +# 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 +# +# https://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. + +load("//build/make/core:product_config.rbc", "rblf") +load(":inherit3.rbc", _inherit3_init = "init") + +def init(g, handle): + cfg = rblf.cfg(handle) + + rblf.inherit(handle, "test/inherit3", _inherit3_init) diff --git a/tests/artifact_path_requirements/inherit2.rbc b/tests/artifact_path_requirements/inherit2.rbc new file mode 100644 index 0000000000..597b4e92c7 --- /dev/null +++ b/tests/artifact_path_requirements/inherit2.rbc @@ -0,0 +1,22 @@ +# Copyright 2022 Google LLC +# +# 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 +# +# https://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. + +load("//build/make/core:product_config.rbc", "rblf") +load(":inherit4.rbc", _inherit4_init = "init") + +def init(g, handle): + cfg = rblf.cfg(handle) + + rblf.inherit(handle, "test/inherit4", _inherit4_init) + rblf.require_artifacts_in_path(handle, "vendor/", "") diff --git a/tests/artifact_path_requirements/inherit3.rbc b/tests/artifact_path_requirements/inherit3.rbc new file mode 100644 index 0000000000..597b4e92c7 --- /dev/null +++ b/tests/artifact_path_requirements/inherit3.rbc @@ -0,0 +1,22 @@ +# Copyright 2022 Google LLC +# +# 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 +# +# https://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. + +load("//build/make/core:product_config.rbc", "rblf") +load(":inherit4.rbc", _inherit4_init = "init") + +def init(g, handle): + cfg = rblf.cfg(handle) + + rblf.inherit(handle, "test/inherit4", _inherit4_init) + rblf.require_artifacts_in_path(handle, "vendor/", "") diff --git a/tests/artifact_path_requirements/inherit4.rbc b/tests/artifact_path_requirements/inherit4.rbc new file mode 100644 index 0000000000..52028fea64 --- /dev/null +++ b/tests/artifact_path_requirements/inherit4.rbc @@ -0,0 +1,21 @@ +# Copyright 2022 Google LLC +# +# 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 +# +# https://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. + +load("//build/make/core:product_config.rbc", "rblf") + +def init(g, handle): + cfg = rblf.cfg(handle) + + rblf.setdefault(handle, "PRODUCT_COPY_FILES") + cfg["PRODUCT_COPY_FILES"] += ["foo/bar/baz.txt:vendor/etc/baz.txt"] diff --git a/tests/artifact_path_requirements/product.rbc b/tests/artifact_path_requirements/product.rbc new file mode 100644 index 0000000000..7d1f169fc7 --- /dev/null +++ b/tests/artifact_path_requirements/product.rbc @@ -0,0 +1,24 @@ +# Copyright 2022 Google LLC +# +# 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 +# +# https://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. + +load("//build/make/core:product_config.rbc", "rblf") +load(":inherit1.rbc", _inherit1_init = "init") +load(":inherit2.rbc", _inherit2_init = "init") +load(":inherit3.rbc", _inherit3_init = "init") + +def init(g, handle): + cfg = rblf.cfg(handle) + rblf.inherit(handle, "test/inherit1", _inherit1_init) + rblf.inherit(handle, "test/inherit2", _inherit2_init) + rblf.inherit(handle, "test/inherit3", _inherit3_init) diff --git a/tests/artifact_path_requirements/test.rbc b/tests/artifact_path_requirements/test.rbc new file mode 100644 index 0000000000..0a344d1405 --- /dev/null +++ b/tests/artifact_path_requirements/test.rbc @@ -0,0 +1,27 @@ +# Copyright 2022 Google LLC +# +# 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 +# +# https://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. + +load("//build/make/core:product_config.rbc", "rblf") +load("//build/make/tests/input_variables.rbc", input_variables_init = "init") +load(":product.rbc", "init") + +def assert_eq(expected, actual): + if expected != actual: + fail("Expected '%s', got '%s'" % (expected, actual)) + +def test(): + (globals, globals_base) = rblf.product_configuration("test/product", init, input_variables_init) + assert_eq(["foo/bar/baz.txt:vendor/etc/baz.txt"], globals["PRODUCTS.test/product.mk.PRODUCT_COPY_FILES"]) + assert_eq(["foo/bar/baz.txt:vendor/etc/baz.txt"], globals["PRODUCTS.test/inherit2.mk.PRODUCT_COPY_FILES"]) + assert_eq(["foo/bar/baz.txt:vendor/etc/baz.txt"], globals["PRODUCTS.test/inherit3.mk.PRODUCT_COPY_FILES"]) diff --git a/tests/run.rbc b/tests/run.rbc index 58cc4d6517..56ba39413b 100644 --- a/tests/run.rbc +++ b/tests/run.rbc @@ -26,11 +26,16 @@ load(":product.rbc", "init") load(":board.rbc", board_init = "init") load(":board_input_vars.rbc", board_input_vars_init = "init") load("//build/make/tests/single_value_inheritance:test.rbc", test_single_value_inheritance = "test") +load("//build/make/tests/artifact_path_requirements:test.rbc", test_artifact_path_requirements = "test") def assert_eq(expected, actual): if expected != actual: fail("Expected '%s', got '%s'" % (expected, actual)) +def assert_dict_subset(expected, actual): + for key, val in expected.items(): + assert_eq(val, actual[key]) + # Unit tests for non-trivial runtime functions assert_eq(["a", "b", "c"], rblf.mksort("b a c c")) assert_eq(["a", "b", "c"], rblf.mksort(["b", "a", "c", "c"])) @@ -80,31 +85,28 @@ assert_eq( rblf.expand_wildcard("build/make/tests/run.rbc build/make/tests/nonexistent.rbc") ) -(globals, config, globals_base) = rblf.product_configuration("test/device", init, input_variables_init) -assert_eq( - { - "PRODUCT_COPY_FILES": [ - "part_from:part_to", - "device_from:device_to", - "device/google/redfin/audio/audio_platform_info_noextcodec_snd.xml:||VENDOR-PATH-PH||/etc/audio/audio_platform_info_noextcodec_snd.xml", - "xyz:/etc/xyz", - "x.xml:/etc/x.xml", - "y.xml:/etc/y.xml", - "from/sub/x:to/x", - "from/sub/y:to/y", - ], - "PRODUCT_HOST_PACKAGES": ["host"], - "PRODUCT_PACKAGES": [ - "dev", - "inc", - "dev_after", - "board1_in", - "board1_is", - ], - "PRODUCT_PRODUCT_PROPERTIES": ["part_properties"] - }, - { k:v for k, v in sorted(config.items()) } -) +(globals, globals_base) = rblf.product_configuration("test/device", init, input_variables_init) +assert_dict_subset({ + "PRODUCTS.test/device.mk.PRODUCT_COPY_FILES": [ + "part_from:part_to", + "device_from:device_to", + "device/google/redfin/audio/audio_platform_info_noextcodec_snd.xml:||VENDOR-PATH-PH||/etc/audio/audio_platform_info_noextcodec_snd.xml", + "xyz:/etc/xyz", + "x.xml:/etc/x.xml", + "y.xml:/etc/y.xml", + "from/sub/x:to/x", + "from/sub/y:to/y", + ], + "PRODUCTS.test/device.mk.PRODUCT_HOST_PACKAGES": ["host"], + "PRODUCTS.test/device.mk.PRODUCT_PACKAGES": [ + "dev", + "inc", + "dev_after", + "board1_in", + "board1_is", + ], + "PRODUCTS.test/device.mk.PRODUCT_PRODUCT_PROPERTIES": ["part_properties"] +}, globals) ns = globals["$SOONG_CONFIG_NAMESPACES"] assert_eq( @@ -134,8 +136,9 @@ assert_eq( { k:v for k,v in sorted(goals.items()) } ) -(board_globals, board_config, board_globals_base) = rblf.board_configuration(board_init, board_input_vars_init) +(board_globals, board_globals_base) = rblf.board_configuration(board_init, board_input_vars_init) assert_eq({"A_LIST_VARIABLE": ["foo", "bar"]}, board_globals) assert_eq({"A_LIST_VARIABLE": ["foo"]}, board_globals_base) test_single_value_inheritance() +test_artifact_path_requirements() diff --git a/tests/single_value_inheritance/test.rbc b/tests/single_value_inheritance/test.rbc index dcde7e0db7..e4f44f4ae8 100644 --- a/tests/single_value_inheritance/test.rbc +++ b/tests/single_value_inheritance/test.rbc @@ -22,7 +22,7 @@ def assert_eq(expected, actual): fail("Expected '%s', got '%s'" % (expected, actual)) def test(): - (globals, config, globals_base) = rblf.product_configuration("test/device", init, input_variables_init) - assert_eq("tablet", config["PRODUCT_CHARACTERISTICS"]) - assert_eq("vendor/myvendor/certs/devkeys/devkey", config["PRODUCT_DEFAULT_DEV_CERTIFICATE"]) - assert_eq(["foo", "bar"], config["PRODUCT_PACKAGES"]) + (globals, globals_base) = rblf.product_configuration("test/device", init, input_variables_init) + assert_eq("tablet", globals["PRODUCTS.test/device.mk.PRODUCT_CHARACTERISTICS"]) + assert_eq("vendor/myvendor/certs/devkeys/devkey", globals["PRODUCTS.test/device.mk.PRODUCT_DEFAULT_DEV_CERTIFICATE"]) + assert_eq(["foo", "bar"], globals["PRODUCTS.test/device.mk.PRODUCT_PACKAGES"]) |