1"""Lit configuration to drive test in this repo.""" 2# Copyright 2020 The TensorFlow Authors. All Rights Reserved. 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15# -*- Python -*- 16# pylint: disable=undefined-variable 17 18import os 19 20import lit.formats 21from lit.llvm import llvm_config 22from lit.llvm.subst import ToolSubst 23import lit.util 24 25# Configuration file for the 'lit' test runner. 26 27# name: The name of this test suite. 28config.name = 'MLIR_HLO_OPT' 29 30config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) 31 32# suffixes: A list of file extensions to treat as test files. 33config.suffixes = ['.mlir', '.mlir.py'] 34 35# test_source_root: The root path where tests are located. 36config.test_source_root = os.path.dirname(__file__) 37 38# test_exec_root: The root path where tests should be run. 39config.test_exec_root = os.path.join(config.mlir_hlo_obj_root, 'test') 40 41config.substitutions.append(('%PATH%', config.environment['PATH'])) 42config.substitutions.append(('%shlibext', config.llvm_shlib_ext)) 43 44llvm_config.with_system_environment(['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP']) 45 46llvm_config.use_default_substitutions() 47 48# excludes: A list of directories to exclude from the testsuite. The 'Inputs' 49# subdirectories contain auxiliary inputs for various tests in their parent 50# directories. 51config.excludes = [ 52 'Inputs', 'Examples', 'tosa', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt' 53] 54 55# test_source_root: The root path where tests are located. 56config.test_source_root = os.path.dirname(__file__) 57 58# test_exec_root: The root path where tests should be run. 59config.test_exec_root = os.path.join(config.mlir_hlo_obj_root, 'tests') 60config.mlir_hlo_tools_dir = os.path.join(config.mlir_hlo_obj_root, 'bin') 61 62# Tweak the PATH to include the tools dir. 63llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True) 64 65tool_dirs = [ 66 config.mlir_hlo_tools_dir, 67 config.llvm_tools_dir, 68] 69tools = [ 70 'mlir-hlo-opt', 71 'mlir-cpu-runner', 72 ToolSubst( 73 '%mlir_runner_utils_dir', 74 config.mlir_runner_utils_dir, 75 unresolved='ignore'), 76] 77 78llvm_config.add_tool_substitutions(tools, tool_dirs) 79