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