aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2021-09-28 14:50:44 +0100
committerYann Herklotz <git@yannherklotz.com>2021-09-28 14:50:44 +0100
commita08f79d3e01c92859e6b33f602b2be2bb8c52e61 (patch)
treeaa6fe94ea8b3ad841dbda0e354a88f8291d6973d /test
downloadgsa-mlir-a08f79d3e01c92859e6b33f602b2be2bb8c52e61.tar.gz
gsa-mlir-a08f79d3e01c92859e6b33f602b2be2bb8c52e61.zip
Add initial files
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt20
-rw-r--r--test/Standalone/dummy.mlir11
-rw-r--r--test/Standalone/standalone-opt.mlir3
-rw-r--r--test/Standalone/standalone-translate.mlir5
-rw-r--r--test/lit.cfg.py61
-rw-r--r--test/lit.site.cfg.py.in51
6 files changed, 151 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 0000000..29da2b8
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,20 @@
+configure_lit_site_cfg(
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
+ ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
+ MAIN_CONFIG
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
+)
+
+set(STANDALONE_TEST_DEPENDS
+ FileCheck count not
+ standalone-opt
+ standalone-translate
+ )
+
+add_lit_testsuite(check-standalone "Running the standalone regression tests"
+ ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${STANDALONE_TEST_DEPENDS}
+ )
+set_target_properties(check-standalone PROPERTIES FOLDER "Tests")
+
+add_lit_testsuites(STANDALONE ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${STANDALONE_TEST_DEPENDS})
diff --git a/test/Standalone/dummy.mlir b/test/Standalone/dummy.mlir
new file mode 100644
index 0000000..ada4280
--- /dev/null
+++ b/test/Standalone/dummy.mlir
@@ -0,0 +1,11 @@
+// RUN: standalone-opt %s | standalone-opt | FileCheck %s
+
+module {
+ // CHECK-LABEL: func @bar()
+ func @bar() {
+ %0 = constant 1 : i32
+ // CHECK: %{{.*}} = standalone.foo %{{.*}} : i32
+ %res = standalone.foo %0 : i32
+ return
+ }
+}
diff --git a/test/Standalone/standalone-opt.mlir b/test/Standalone/standalone-opt.mlir
new file mode 100644
index 0000000..1a78a9d
--- /dev/null
+++ b/test/Standalone/standalone-opt.mlir
@@ -0,0 +1,3 @@
+// RUN: standalone-opt --show-dialects | FileCheck %s
+// CHECK: Available Dialects:
+// CHECK: standalone
diff --git a/test/Standalone/standalone-translate.mlir b/test/Standalone/standalone-translate.mlir
new file mode 100644
index 0000000..16d4978
--- /dev/null
+++ b/test/Standalone/standalone-translate.mlir
@@ -0,0 +1,5 @@
+// RUN: standalone-translate --help | FileCheck %s
+// CHECK: --deserialize-spirv
+// CHECK: --import-llvm
+// CHECK: --mlir-to-llvmir
+// CHECK: --serialize-spirv
diff --git a/test/lit.cfg.py b/test/lit.cfg.py
new file mode 100644
index 0000000..9fb5b54
--- /dev/null
+++ b/test/lit.cfg.py
@@ -0,0 +1,61 @@
+# -*- Python -*-
+
+import os
+import platform
+import re
+import subprocess
+import tempfile
+
+import lit.formats
+import lit.util
+
+from lit.llvm import llvm_config
+from lit.llvm.subst import ToolSubst
+from lit.llvm.subst import FindTool
+
+# Configuration file for the 'lit' test runner.
+
+# name: The name of this test suite.
+config.name = 'STANDALONE'
+
+config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
+
+# suffixes: A list of file extensions to treat as test files.
+config.suffixes = ['.mlir']
+
+# test_source_root: The root path where tests are located.
+config.test_source_root = os.path.dirname(__file__)
+
+# test_exec_root: The root path where tests should be run.
+config.test_exec_root = os.path.join(config.standalone_obj_root, 'test')
+
+config.substitutions.append(('%PATH%', config.environment['PATH']))
+config.substitutions.append(('%shlibext', config.llvm_shlib_ext))
+
+llvm_config.with_system_environment(
+ ['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP'])
+
+llvm_config.use_default_substitutions()
+
+# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
+# subdirectories contain auxiliary inputs for various tests in their parent
+# directories.
+config.excludes = ['Inputs', 'Examples', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt']
+
+# test_source_root: The root path where tests are located.
+config.test_source_root = os.path.dirname(__file__)
+
+# test_exec_root: The root path where tests should be run.
+config.test_exec_root = os.path.join(config.standalone_obj_root, 'test')
+config.standalone_tools_dir = os.path.join(config.standalone_obj_root, 'bin')
+
+# Tweak the PATH to include the tools dir.
+llvm_config.with_environment('PATH', config.llvm_tools_dir, append_path=True)
+
+tool_dirs = [config.standalone_tools_dir, config.llvm_tools_dir]
+tools = [
+ 'standalone-opt',
+ 'standalone-translate'
+]
+
+llvm_config.add_tool_substitutions(tools, tool_dirs)
diff --git a/test/lit.site.cfg.py.in b/test/lit.site.cfg.py.in
new file mode 100644
index 0000000..26fb8aa
--- /dev/null
+++ b/test/lit.site.cfg.py.in
@@ -0,0 +1,51 @@
+@LIT_SITE_CFG_IN_HEADER@
+
+import sys
+
+config.host_triple = "@LLVM_HOST_TRIPLE@"
+config.target_triple = "@TARGET_TRIPLE@"
+config.llvm_src_root = "@LLVM_SOURCE_DIR@"
+config.llvm_obj_root = "@LLVM_BINARY_DIR@"
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.llvm_lib_dir = "@LLVM_LIBS_DIR@"
+config.llvm_shlib_dir = "@SHLIBDIR@"
+config.llvm_shlib_ext = "@SHLIBEXT@"
+config.llvm_exe_ext = "@EXEEXT@"
+config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
+config.python_executable = "@PYTHON_EXECUTABLE@"
+config.gold_executable = "@GOLD_EXECUTABLE@"
+config.ld64_executable = "@LD64_EXECUTABLE@"
+config.enable_shared = @ENABLE_SHARED@
+config.enable_assertions = @ENABLE_ASSERTIONS@
+config.targets_to_build = "@TARGETS_TO_BUILD@"
+config.native_target = "@LLVM_NATIVE_ARCH@"
+config.llvm_bindings = "@LLVM_BINDINGS@".split(' ')
+config.host_os = "@HOST_OS@"
+config.host_cc = "@HOST_CC@"
+config.host_cxx = "@HOST_CXX@"
+config.enable_libcxx = "@LLVM_ENABLE_LIBCXX@"
+# Note: ldflags can contain double-quoted paths, so must use single quotes here.
+config.host_ldflags = '@HOST_LDFLAGS@'
+config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
+config.llvm_host_triple = '@LLVM_HOST_TRIPLE@'
+config.host_arch = "@HOST_ARCH@"
+config.standalone_src_root = "@CMAKE_SOURCE_DIR@"
+config.standalone_obj_root = "@CMAKE_BINARY_DIR@"
+
+# Support substitution of the tools_dir with user parameters. This is
+# used when we can't determine the tool dir at configuration time.
+try:
+ config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
+ config.llvm_lib_dir = config.llvm_lib_dir % lit_config.params
+ config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
+except KeyError:
+ e = sys.exc_info()[1]
+ key, = e.args
+ lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
+
+
+import lit.llvm
+lit.llvm.initialize(lit_config, config)
+
+# Let the main config do the real work.
+lit_config.load_config(config, "@CMAKE_SOURCE_DIR@/test/lit.cfg.py")