Skip to content
Open
2 changes: 1 addition & 1 deletion mlir/examples/standalone/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

tool_dirs = [config.standalone_tools_dir, config.llvm_tools_dir]
tools = [
"mlir-opt",
ToolSubst("mlir-opt", post=";", unresolved="fatal"),
"standalone-capi-test",
"standalone-opt",
"standalone-translate",
Expand Down
7 changes: 7 additions & 0 deletions mlir/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ if (MLIR_INCLUDE_INTEGRATION_TESTS)

endif()

option(MLIR_RUN_STANDALONE_INSTALL_TESTS "Run Standalone example install tests." ON)
if(MLIR_RUN_STANDALONE_INSTALL_TESTS AND "${CMAKE_INSTALL_PREFIX}" STREQUAL "")
message(WARNING "Standalone example install tests will install into root!\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by root? The GIT root? /? The build directory root?

Usually, when I do automatic installs for CI, I set it to %build/install, so that it's guaranteed to be writable by the build process and in the same filesystem (ex. the source directory may be NFS and slow).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If CMAKE_INSTALL_PREFIX is empty and you do ninja install it'll try to install to /lib, /include, etc. That's what this means - that if you've enabled MLIR_RUN_STANDALONE_INSTALL_TESTS but you've not explicitly set CMAKE_INSTALL_PREFIX to be something then you probably made a mistake.

If you want to disable this behavior pass -DMLIR_RUN_STANDALONE_INSTALL_TESTS=OFF")
endif()

llvm_canonicalize_cmake_booleans(
LLVM_BUILD_EXAMPLES
LLVM_HAS_NVPTX_TARGET
Expand All @@ -76,6 +82,7 @@ llvm_canonicalize_cmake_booleans(
MLIR_ENABLE_SPIRV_CPU_RUNNER
MLIR_ENABLE_VULKAN_RUNNER
MLIR_INCLUDE_INTEGRATION_TESTS
MLIR_RUN_STANDALONE_INSTALL_TESTS
MLIR_RUN_AMX_TESTS
MLIR_RUN_CUDA_TENSOR_CORE_TESTS
MLIR_RUN_X86VECTOR_TESTS
Expand Down
16 changes: 16 additions & 0 deletions mlir/test/Examples/standalone/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,19 @@ config.substitutions.append(("%host_cc", config.host_cc))
config.substitutions.append(("%enable_libcxx", config.enable_libcxx))
config.substitutions.append(("%mlir_cmake_dir", config.mlir_cmake_dir))
config.substitutions.append(("%llvm_use_linker", config.llvm_use_linker))
config.substitutions.append(("%llvm_obj_root", config.llvm_obj_root))
config.substitutions.append(("%llvm_src_root", config.llvm_src_root))
config.substitutions.append(("%host_cmake_install_prefix", config.host_cmake_install_prefix))
config.substitutions.append(("%cmake_build_type", config.cmake_build_type))
config.substitutions.append(("%cmake_c_compiler_launcher", config.cmake_c_compiler_launcher))
config.substitutions.append(("%cmake_cxx_compiler_launcher", config.cmake_cxx_compiler_launcher))

if config.run_standalone_install_tests:
config.available_features.add("run-standalone-install-tests")
# see https://github.com/llvm/llvm-project/blob/57782eff31e9d454b54a201c7ac43dc1b93dbb3f/llvm/utils/lit/lit/TestRunner.py#L1858
config.substitutions.insert(0, ("FileCheck", "FileChuck"))
config.substitutions.insert(0, ("count", "kount"))
config.substitutions.insert(0, ("not", "mot"))
config.substitutions.append(("kount", "count"))
config.substitutions.append(("mot", "not"))
config.substitutions.append(("FileChuck", "FileCheck"))
28 changes: 28 additions & 0 deletions mlir/test/Examples/standalone/test.install-dir.toy
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# REQUIRES: run-standalone-install-tests

# RUN: echo "test install distribution" | tee %t
# CHECK: test install distribution

# RUN: "%cmake_exe" "%llvm_src_root" -DCMAKE_BUILD_TYPE=%cmake_build_type -B "%llvm_obj_root" \
# RUN: -DLLVM_DISTRIBUTION_COMPONENTS="llvm-headers;llvm-libraries;cmake-exports;FileCheck;count;not;mlir-headers;mlir-libraries;mlir-cmake-exports;mlir-tblgen;mlir-opt;mlir-python-sources" | tee -a %t

# RUN: "%cmake_exe" --build "%llvm_obj_root" --target install-distribution -j | tee -a %t

# RUN: "%cmake_exe" "%mlir_src_root/examples/standalone" -G "%cmake_generator" \
# RUN: -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc \
# RUN: -DCMAKE_CXX_COMPILER_LAUNCHER=%cmake_cxx_compiler_launcher -DCMAKE_C_COMPILER_LAUNCHER=%cmake_c_compiler_launcher \
# RUN: -DLLVM_ENABLE_LIBCXX=%enable_libcxx \
# RUN: -DLLVM_EXTERNAL_LIT="%llvm_obj_root/bin/llvm-lit" \
# RUN: -DMLIR_DIR="%host_cmake_install_prefix/lib/cmake/mlir" \
# RUN: -DLLVM_DIR="%host_cmake_install_prefix/lib/cmake/llvm" \
# RUN: -DLLVM_USE_LINKER=%llvm_use_linker \
# RUN: -DPython3_EXECUTABLE=%python \
# RUN: -DPython_EXECUTABLE=%python | tee -a %t

# RUN: "%cmake_exe" --build . --target check-standalone -j | tee -a %t

# RUN: FileCheck --input-file=%t %s

# CHECK: Passed
# CHECK-NOT: Failed
# UNSUPPORTED: target={{.*(windows|android).*}}
1 change: 1 addition & 0 deletions mlir/test/Examples/standalone/test.toy
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# RUN: "%cmake_exe" "%mlir_src_root/examples/standalone" -G "%cmake_generator" \
# RUN: -DCMAKE_CXX_COMPILER=%host_cxx -DCMAKE_C_COMPILER=%host_cc \
# RUN: -DCMAKE_CXX_COMPILER_LAUNCHER=%cmake_cxx_compiler_launcher -DCMAKE_C_COMPILER_LAUNCHER=%cmake_c_compiler_launcher \
# RUN: -DLLVM_ENABLE_LIBCXX=%enable_libcxx -DMLIR_DIR=%mlir_cmake_dir \
# RUN: -DLLVM_USE_LINKER=%llvm_use_linker \
# RUN: -DPython3_EXECUTABLE=%python \
Expand Down
4 changes: 2 additions & 2 deletions mlir/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def find_real_python_interpreter():
llvm_config.with_environment("PATH", dirs, append_path=True)

tools = [
"mlir-tblgen",
ToolSubst("mlir-tblgen", post=";", unresolved="fatal"),
"mlir-translate",
"mlir-lsp-server",
"mlir-capi-execution-engine-test",
Expand Down Expand Up @@ -318,7 +318,7 @@ def find_real_python_interpreter():
]
)
else:
tools.extend(["mlir-opt"])
tools.extend([ToolSubst("mlir-opt", post=";", unresolved="fatal")])

llvm_config.add_tool_substitutions(tools, tool_dirs)

Expand Down
6 changes: 6 additions & 0 deletions mlir/test/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys

config.target_triple = "@LLVM_TARGET_TRIPLE@"
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
config.llvm_src_root = "@LLVM_SOURCE_DIR@"
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
Expand All @@ -17,7 +18,11 @@ config.host_cc = "@HOST_CC@"
config.host_cxx = "@HOST_CXX@"
config.enable_libcxx = "@LLVM_ENABLE_LIBCXX@"
config.host_cmake = "@CMAKE_COMMAND@"
config.cmake_build_type = "@CMAKE_BUILD_TYPE@"
config.cmake_c_compiler_launcher = "@CMAKE_C_COMPILER_LAUNCHER@"
config.cmake_cxx_compiler_launcher= "@CMAKE_CXX_COMPILER_LAUNCHER@"
config.host_cmake_generator = "@CMAKE_GENERATOR@"
config.host_cmake_install_prefix = "@CMAKE_INSTALL_PREFIX@"
config.llvm_use_linker = "@LLVM_USE_LINKER@"
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
config.host_arch = "@HOST_ARCH@"
Expand All @@ -31,6 +36,7 @@ config.build_examples = @LLVM_BUILD_EXAMPLES@
config.run_nvptx_tests = @LLVM_HAS_NVPTX_TARGET@
config.enable_cuda_runner = @MLIR_ENABLE_CUDA_RUNNER@
config.run_rocm_tests = @MLIR_ENABLE_ROCM_CONVERSIONS@
config.run_standalone_install_tests = @MLIR_RUN_STANDALONE_INSTALL_TESTS@
config.enable_rocm_runner = @MLIR_ENABLE_ROCM_RUNNER@
config.gpu_compilation_format = "@MLIR_GPU_COMPILATION_TEST_FORMAT@"
config.rocm_test_chipset = "@ROCM_TEST_CHIPSET@"
Expand Down