Skip to content

[tests] Re-enable unittesting and partial fix for the existing errors #249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85827 for details. The issue is
# fixed in GCC 10.
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "10.0")
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-Wno-unused-but-set-parameter" CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER)
append_if(CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER "-Wno-unused-but-set-parameter" CMAKE_CXX_FLAGS)
if(CXX_SUPPORTS_WNO_UNUSED_BUT_SET_PARAMETER)
Copy link
Author

Choose a reason for hiding this comment

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

These lines originally occur after including LLVM cmake, so we don't need to include them by ourselves. A recent refactor swaps the location of these lines with include(LLVM...), so it breaks cmake when g++ < 10.0

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-parameter")
endif()
endif()
################################################################################

Expand Down
2 changes: 1 addition & 1 deletion lib/gc/Transforms/Pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void populateCPURuntimePasses(mlir::OpPassManager &pm) {
pm.addPass(createForallToParallelLoopPass());
pm.addPass(createParallelLoopFusionPass());
pm.addPass(createLoopInvariantCodeMotionPass());
pm.addPass(createConvertMemRefToCPURuntime());
pm.addNestedPass<func::FuncOp>(createConvertMemRefToCPURuntime());
Copy link
Contributor

Choose a reason for hiding this comment

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

can we merge this now? bench tool has an issue for some mlir, and it needs this change.

pm.addPass(createConvertSCFToOpenMPPass());
populateCleanUpPasses(pm);
}
Expand Down
7 changes: 7 additions & 0 deletions test/mlir/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
)

configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/gc/Unit/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/gc/Unit/lit.site.cfg.py
MAIN_CONFIG
${CMAKE_CURRENT_SOURCE_DIR}/gc/Unit/lit.cfg.py
)

set(GC_OPT_TEST_DEPENDS
FileCheck count not split-file
# mlir-gen
Expand Down
50 changes: 50 additions & 0 deletions test/mlir/test/gc/Unit/lit.cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# -*- Python -*-

# Configuration file for the 'lit' test runner.

import os
import subprocess

import lit.formats

# name: The name of this test suite.
config.name = "GC-Unit"

# suffixes: A list of file extensions to treat as test files.
config.suffixes = []

# test_source_root: The root path where tests are located.
# test_exec_root: The root path where tests should be run.
config.test_exec_root = os.path.join(config.gc_obj_root, "test", "mlir", "unittests")
config.test_source_root = config.test_exec_root

# testFormat: The test format to use to interpret tests.
config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, "Tests")

# Propagate the temp directory. Windows requires this because it uses \Windows\
# if none of these are present.
if "TMP" in os.environ:
config.environment["TMP"] = os.environ["TMP"]
if "TEMP" in os.environ:
config.environment["TEMP"] = os.environ["TEMP"]

# Propagate HOME as it can be used to override incorrect homedir in passwd
# that causes the tests to fail.
if "HOME" in os.environ:
config.environment["HOME"] = os.environ["HOME"]
Comment on lines +26 to +34
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: seems we can also put these into var list below?


# Propagate sanitizer options.
for var in [
"ASAN_SYMBOLIZER_PATH",
"HWASAN_SYMBOLIZER_PATH",
"MSAN_SYMBOLIZER_PATH",
"TSAN_SYMBOLIZER_PATH",
"UBSAN_SYMBOLIZER_PATH",
"ASAN_OPTIONS",
"HWASAN_OPTIONS",
"MSAN_OPTIONS",
"TSAN_OPTIONS",
"UBSAN_OPTIONS",
]:
if var in os.environ:
config.environment[var] = os.environ[var]
12 changes: 12 additions & 0 deletions test/mlir/test/gc/Unit/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@LIT_SITE_CFG_IN_HEADER@

import sys
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
config.llvm_build_mode = lit_config.substitute("@LLVM_BUILD_MODE@")
config.mlir_obj_root = "@MLIR_BINARY_DIR@"
config.gc_src_root = "@CMAKE_SOURCE_DIR@"
config.gc_obj_root = "@PROJECT_BINARY_DIR@"
config.gc_lib_dir = os.path.join(config.gc_obj_root, "lib")

# Let the main config do the real work.
lit_config.load_config(config, "@CMAKE_SOURCE_DIR@/test/mlir/test/gc/Unit/lit.cfg.py")
2 changes: 1 addition & 1 deletion test/mlir/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
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.gc_obj_root, "test")
config.test_exec_root = os.path.join(config.gc_obj_root, "test", "mlir", "test")
config.gc_tools_dir = os.path.join(config.gc_obj_root, "bin")

config.substitutions.append(("%PATH%", config.environment["PATH"]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ dlti.target_system_spec = #dlti.target_system_spec<
>} {}
)mlir";

TEST(TargetDescriptionAnalysis, CPUMissingValue) {
TEST(DISABLED_TargetDescriptionAnalysis, CPUMissingValue) {
Copy link
Author

Choose a reason for hiding this comment

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

We need to re-enable this UT after it is fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a TODO/FIXME for future reminder

MLIRContext ctx{gc::initCompilerAndGetDialects()};
std::unique_ptr<llvm::MemoryBuffer> ir_buffer =
llvm::MemoryBuffer::getMemBuffer(code2);
Expand Down