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