forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang] unit test support for out-of-tree and in-tree using google te…
…sts framework Review comments addressed.
- Loading branch information
1 parent
7e54df6
commit 93f602b
Showing
8 changed files
with
200 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# -*- Python -*- | ||
|
||
# Configuration file for the 'lit' test runner. | ||
|
||
import os | ||
|
||
import lit.formats | ||
|
||
# name: The name of this test suite. | ||
config.name = 'flang-Unit' | ||
|
||
# suffixes: A list of file extensions to treat as test files. | ||
config.suffixes = [] | ||
|
||
# test_source_root: The root path where unit test binaries are located. | ||
# test_exec_root: The root path where tests should be run. | ||
config.test_source_root = os.path.join(config.flang_obj_root, 'unittests') | ||
config.test_exec_root = config.test_source_root | ||
|
||
# testFormat: The test format to use to interpret tests. | ||
config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, 'Tests') | ||
|
||
# Tweak the PATH to include the tools dir. | ||
path = os.path.pathsep.join((config.flang_tools_dir, config.llvm_tools_dir, config.environment['PATH'])) | ||
config.environment['PATH'] = path | ||
|
||
path = os.path.pathsep.join((config.flang_libs_dir, config.llvm_libs_dir, | ||
config.environment.get('LD_LIBRARY_PATH',''))) | ||
config.environment['LD_LIBRARY_PATH'] = path | ||
|
||
# Propagate PYTHON_EXECUTABLE into the environment | ||
#config.environment['PYTHON_EXECUTABLE'] = sys.executable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
@LIT_SITE_CFG_IN_HEADER@ | ||
|
||
config.llvm_src_root = "@LLVM_SOURCE_DIR@" | ||
config.llvm_obj_root = "@LLVM_BINARY_DIR@" | ||
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" | ||
config.llvm_libs_dir = "@LLVM_LIBS_DIR@" | ||
config.llvm_build_mode = "@LLVM_BUILD_MODE@" | ||
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" | ||
config.flang_obj_root = "@FLANG_BINARY_DIR@" | ||
config.flang_src_root = "@FLANG_SOURCE_DIR@" | ||
config.flang_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@" | ||
config.flang_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@" | ||
config.target_triple = "@TARGET_TRIPLE@" | ||
config.python_executable = "@Python3_EXECUTABLE@" | ||
|
||
# Support substitution of the tools and libs dirs 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_libs_dir = config.llvm_libs_dir % lit_config.params | ||
config.llvm_build_mode = config.llvm_build_mode % lit_config.params | ||
except KeyError as e: | ||
key, = e.args | ||
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key)) | ||
|
||
# Let the main config do the real work. | ||
lit_config.load_config(config, "@FLANG_SOURCE_DIR@/test/Unit/lit.cfg.py") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
add_custom_target(FlangUnitTests) | ||
set_target_properties(FlangUnitTests PROPERTIES FOLDER "Flang Unit Tests") | ||
|
||
function(add_flang_unittest test_dirname) | ||
add_unittest(FlangUnitTests ${test_dirname} ${ARGN}) | ||
endfunction() | ||
|
||
add_subdirectory(Optimizer) | ||
add_subdirectory(Decimal) | ||
add_subdirectory(Evaluate) | ||
add_subdirectory(Runtime) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) | ||
|
||
set(LIBS | ||
FIRDialect | ||
${dialect_libs} | ||
) | ||
|
||
add_flang_unittest(FlangOptimizerTests | ||
InternalNamesTest.cpp | ||
) | ||
target_link_libraries(FlangOptimizerTests | ||
PRIVATE | ||
${LIBS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//===- InternalNames.cpp - InternalNames unit tests ---------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "flang/Optimizer/Support/InternalNames.h" | ||
#include "gtest/gtest.h" | ||
|
||
using namespace fir; | ||
using namespace llvm; | ||
|
||
TEST(genericName, MyTest) { | ||
NameUniquer obj; | ||
std::string val = obj.doCommonBlock("hello"); | ||
std::string val2 = "_QBhello"; | ||
EXPECT_EQ(val, val2); | ||
} |