# Copyright 2023 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
#
#     http://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.

import os
import sys

import lit.formats
import lit.llvm

# Configuration file for the 'lit' test runner.
# pylint: disable=undefined-variable
lit.llvm.initialize(lit_config, config)

config.name = "Model tests"
config.test_format = lit.formats.ShTest(True)

config.suffixes = [".run"]
config.excludes = ["CMakeLists.txt"]

if os.getenv("ROOTDIR") is None:
    sys.exit("Error: Need to run source build/setup.sh first")

config.environment["ROOTDIR"] = os.getenv("ROOTDIR")
config.environment["OUT"] = config.environment["ROOTDIR"] + "/out"

kelvin_cmd = (
    f"{config.environment['ROOTDIR']}/sw/kelvin/build_tools/test_runner.sh ")
kelvin_hw_cmd = (f"{config.environment['ROOTDIR']}"
                 "/sw/kelvin/build_tools/core_sim_test_runner.sh ")
qemu_cmd = (f"{config.environment['ROOTDIR']}/sw/vec/scripts/test_runner.py "
            "qemu --qemu-path "
            f"{config.environment['OUT']}/host/qemu/qemu-system-riscv32")
renode_cmd = (f"{config.environment['ROOTDIR']}/sw/vec/scripts/test_runner.py "
              "renode --renode-path "
              f"{os.getenv('CACHE')}/renode/renode --quick_test ")

config.test_exec_root = os.path.dirname(__file__) + "/tests"

# Enable features based on -D FEATURES=internal syntax. FEATURE is used in the
# REQUIRES field in the lit test. Can add multiple features with comma
# delimiter.
features_param = lit_config.params.get("FEATURES")
if features_param:
    config.available_features.update(features_param.split(','))

runner = lit_config.params.get("RUNNER")

if runner and runner == "kelvin":
    config.environment["TEST_RUNNER_CMD"] = kelvin_cmd
    config.available_features.add("kelvin")
elif runner and runner == "kelvin_hw":
    config.environment["TEST_RUNNER_CMD"] = kelvin_hw_cmd
    config.available_features.add("kelvin_hw")
elif runner and runner == "qemu":
    config.environment["TEST_RUNNER_CMD"] = qemu_cmd
    config.available_features.add("qemu")
else:
    config.environment["TEST_RUNNER_CMD"] = renode_cmd
    config.available_features.add("renode")
