# Copyright 2021 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.


# Run test product configuration and verify its result.
# The main configuration file is product.rbc.
# It inherits part1.rbc and also includes include1.rbc
# TODO(asmundak): more tests are needed to verify that:
#  * multi-level inheritance works as expected
#  * all runtime functions (wildcard, regex, etc.) work

load("//build/make/core:product_config.rbc", "rblf")
load(":input_variables.rbc", input_variables_init = "init")
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")
load("//build/make/tests/prefixed_sort_order:test.rbc", test_prefixed_sort_order = "test")
load("//build/make/tests/inherits_in_regular_variables:test.rbc", test_inherits_in_regular_variables = "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"]))

assert_eq("", rblf.mkstrip(" \n \t    "))
assert_eq("a b c", rblf.mkstrip("  a b   \n  c \t"))
assert_eq("1", rblf.mkstrip("1 "))

assert_eq(["a", "b"], rblf.words("a b"))
assert_eq(["a", "b", "c"], rblf.words(["a b", "c"]))
# 1-tuple like we use in product variables
assert_eq(["a b", ("c",)], rblf.words(["a b", ("c",)]))

assert_eq("b1 b2", rblf.mksubst("a", "b", "a1 a2"))
assert_eq(["b1", "x2"], rblf.mksubst("a", "b", ["a1", "x2"]))

assert_eq("ABcdYZ", rblf.mkpatsubst("ab%yz", "AB%YZ", "abcdyz"))
assert_eq("bcz", rblf.mkpatsubst("a%z", "A%Z", "bcz"))
assert_eq(["Ay", "Az"], rblf.mkpatsubst("a%", "A%", ["ay", "az"]))
assert_eq("AcZ bcz", rblf.mkpatsubst("a%z", "A%Z", "acz  bcz"))
assert_eq("Abcd", rblf.mkpatsubst("a%", "A%", "abcd"))
assert_eq("abcZ", rblf.mkpatsubst("%z", "%Z", "abcz"))
assert_eq("azx b", rblf.mkpatsubst("az", "AZ", "azx  b"))
assert_eq(["azx", "b"], rblf.mkpatsubst("az", "AZ", ["azx", "b"]))
assert_eq("ABC", rblf.mkpatsubst("abc", "ABC", "abc"))
assert_eq(["%/foo"], rblf.mkpatsubst("%", "\\%/%", ["foo"]))
assert_eq(["foo/%"], rblf.mkpatsubst("%", "%/%", ["foo"]))
assert_eq(["from/a:to/a", "from/b:to/b"], rblf.product_copy_files_by_pattern("from/%", "to/%", "a b"))

assert_eq([], rblf.filter(["a", "", "b"], "f"))
assert_eq(["ab%c", "axyzb%c"], rblf.filter(["a%b%c"], ["ab%c", "axyzb%c", "axyzb%cd", "axyzbwc"]))
assert_eq(["abc", "bcd"], rblf.filter(["a%", "b%"], ["abc", "def", "bcd", "xabc"]))
assert_eq(["b", "ab"], rblf.filter_out(["a", "" ], ["a", "", "b", "ab"]))
assert_eq(["c"], rblf.filter_out(["a", "b" ], ["a", "b", "c"]))
assert_eq(["c"], rblf.filter_out(["a%", "b" ], ["abc", "b", "c"]))

assert_eq("foo.c no_folder", rblf.notdir(["src/foo.c", "no_folder"]))
assert_eq("foo.c no_folder", rblf.notdir("src/foo.c no_folder"))
assert_eq("", rblf.notdir("/"))
assert_eq("", rblf.notdir(""))

cwd = rblf_shell('pwd')
assert_eq(cwd+"/foo/bar", rblf.abspath("foo/bar"))
assert_eq(cwd+"/bar", rblf.abspath("foo/.././bar"))
assert_eq(cwd+"/bar", rblf.abspath("foo/..////bar//"))
assert_eq("/foo/baz", rblf.abspath("/foo/bar/../baz"))
assert_eq(cwd+"/foo/bar "+cwd+"/foo/baz", rblf.abspath("foo/bar foo/baz"))
assert_eq("/baz", rblf.abspath("/../../../../../../../../../../../../../../../../baz"))

assert_eq("foo", rblf.first_word("foo bar"))
assert_eq("foo", rblf.first_word(["foo", "bar"]))
assert_eq("", rblf.first_word(""))
assert_eq("", rblf.first_word([]))
assert_eq("bar", rblf.last_word("foo bar"))
assert_eq("bar", rblf.last_word(["foo", "bar"]))
assert_eq("", rblf.last_word(""))
assert_eq("", rblf.last_word([]))

assert_eq(["foo", "bar"], rblf.flatten_2d_list([["foo", "bar"]]))
assert_eq(["foo", "bar"], rblf.flatten_2d_list([["foo"], ["bar"]]))
assert_eq([], rblf.flatten_2d_list([]))

assert_eq(
    ["build/make/tests/board.rbc", "build/make/tests/board_input_vars.rbc"],
    rblf.expand_wildcard("build/make/tests/board*.rbc")
)
assert_eq(
    ["build/make/tests/run.rbc", "build/make/tests/product.rbc"],
    rblf.expand_wildcard("build/make/tests/run.rbc build/make/tests/product.rbc")
)
assert_eq(
    ["build/make/tests/run.rbc"],
    rblf.expand_wildcard("build/make/tests/run.rbc build/make/tests/nonexistent.rbc")
)

(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(
    {
        "NS1": {
            "v1": "abc abc_part1",
            "v2": "def"
        },
        "NS2": {
            "v3": "xyz",
            "v4": "xyz"
        }
    },
    {k:v for k, v in sorted(ns.items()) }
)

assert_eq("Tiramisu", globals["PLATFORM_VERSION"])
assert_eq("31", globals["PLATFORM_SDK_VERSION"])

assert_eq("xyz", rblf.soong_config_get(globals, "NS2", "v3"))
assert_eq(None, rblf.soong_config_get(globals, "NS2", "nonexistant_var"))

goals = globals["$dist_for_goals"]
assert_eq(
    {
        "goal": [("dir1/file1", "out1"), ("dir1/file2", "out2"), ("dir2/file2", "file2")]
    },
    { k:v for k,v in sorted(goals.items()) }
)

(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)

g = {"FOO": "a", "BAR": "c", "BAZ": "e"}
cfg = {"FOO": "b", "BAR": "d", "BAZ": "f"}
rblf.clear_var_list(g, struct(cfg=cfg), "FOO BAR NEWVAR")
assert_eq("", g["FOO"])
assert_eq("", cfg["FOO"])
assert_eq("", g["BAR"])
assert_eq("", cfg["BAR"])
assert_eq("e", g["BAZ"])
assert_eq("f", cfg["BAZ"])
assert_eq("", g.get("NEWVAR"))

test_single_value_inheritance()
test_artifact_path_requirements()
test_prefixed_sort_order()
test_inherits_in_regular_variables()
