[CI]Added initial framework of CXX unittest (#98)
Based on the discussion in #53 , I just added the initial flow of CXX unittests for this repo, with providing two dummy UTs as placeholder to show the usage, feel free to add your own CXX unittests. @Superjomn @ptillet @ptillet , in this PR, I also configure the integration-tests.yml to add the unittest into github CI check. Thanks
This commit is contained in:
5
unittest/Analysis/CMakeLists.txt
Normal file
5
unittest/Analysis/CMakeLists.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
add_triton_ut(
|
||||
NAME TritonAnalysisTests
|
||||
SRCS UtilityTest.cpp
|
||||
LIBS TritonAnalysis
|
||||
)
|
14
unittest/Analysis/UtilityTest.cpp
Normal file
14
unittest/Analysis/UtilityTest.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
//===- UtilityTest.cpp - Tests for
|
||||
// Utility----------------------------------===//
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "triton/Analysis/Utility.h"
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace mlir {
|
||||
|
||||
TEST(UtilityTest, DummyTest) { EXPECT_EQ(true, true); }
|
||||
|
||||
} // namespace mlir
|
27
unittest/CMakeLists.txt
Normal file
27
unittest/CMakeLists.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
include (${CMAKE_CURRENT_SOURCE_DIR}/googletest.cmake)
|
||||
|
||||
include(GoogleTest)
|
||||
enable_testing()
|
||||
|
||||
function(add_triton_ut)
|
||||
set(options)
|
||||
set(oneValueArgs NAME)
|
||||
set(multiValueArgs SRCS LIBS)
|
||||
cmake_parse_arguments(_ "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
add_test(NAME ${__NAME}
|
||||
COMMAND ${__NAME})
|
||||
add_executable(
|
||||
${__NAME}
|
||||
${__SRCS})
|
||||
target_link_libraries(
|
||||
${__NAME}
|
||||
GTest::gtest_main
|
||||
gmock
|
||||
${__LIBS})
|
||||
|
||||
gtest_discover_tests(${__NAME})
|
||||
endfunction()
|
||||
|
||||
add_subdirectory(Analysis)
|
||||
add_subdirectory(Conversion)
|
1
unittest/Conversion/CMakeLists.txt
Normal file
1
unittest/Conversion/CMakeLists.txt
Normal file
@@ -0,0 +1 @@
|
||||
add_subdirectory(TritonGPUToLLVM)
|
5
unittest/Conversion/TritonGPUToLLVM/CMakeLists.txt
Normal file
5
unittest/Conversion/TritonGPUToLLVM/CMakeLists.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
add_triton_ut(
|
||||
NAME TritonGPUToLLVMTests
|
||||
SRCS TritonGPUToLLVMTests.cpp
|
||||
LIBS TritonGPUToLLVM
|
||||
)
|
14
unittest/Conversion/TritonGPUToLLVM/TritonGPUToLLVMTests.cpp
Normal file
14
unittest/Conversion/TritonGPUToLLVM/TritonGPUToLLVMTests.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
//===- TritonGPUToLLVMTests.cpp - Tests for
|
||||
// TritonGPUToLLVM----------------------------------===//
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "triton/Conversion/TritonGPUToLLVM/PtxAsmFormat.h"
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace mlir {
|
||||
|
||||
TEST(PtxAsmFormatTest, BasicTest) { EXPECT_EQ(true, true); }
|
||||
|
||||
} // namespace mlir
|
23
unittest/googletest.cmake
Normal file
23
unittest/googletest.cmake
Normal file
@@ -0,0 +1,23 @@
|
||||
include(FetchContent)
|
||||
|
||||
set(GOOGLETEST_DIR "" CACHE STRING "Location of local GoogleTest repo to build against")
|
||||
|
||||
if(GOOGLETEST_DIR)
|
||||
set(FETCHCONTENT_SOURCE_DIR_GOOGLETEST ${GOOGLETEST_DIR} CACHE STRING "GoogleTest source directory override")
|
||||
endif()
|
||||
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
GIT_REPOSITORY https://github.com/google/googletest.git
|
||||
GIT_TAG release-1.12.1
|
||||
)
|
||||
|
||||
FetchContent_GetProperties(googletest)
|
||||
|
||||
if(NOT googletest_POPULATED)
|
||||
FetchContent_Populate(googletest)
|
||||
if (MSVC)
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
Reference in New Issue
Block a user