# 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
#
#      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"

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

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 == "qemu":
    config.environment["TEST_RUNNER_CMD"] = qemu_cmd
else:
    config.environment["TEST_RUNNER_CMD"] = renode_cmd
