Skip to content

Add more tests and clean up helper #3783

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

Closed
wants to merge 10 commits into from
Closed
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
22 changes: 12 additions & 10 deletions build/Test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@

include(${EXECUTORCH_ROOT}/build/Utils.cmake)

# Find prebuilt executorch library
find_package(executorch CONFIG REQUIRED)

enable_testing()
find_package(GTest CONFIG REQUIRED)

target_link_options_shared_lib(extension_data_loader)
target_link_options_shared_lib(portable_ops_lib)

# Add code coverage flags to supported compilers
if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
Expand Down Expand Up @@ -53,19 +62,12 @@ function(et_cxx_test target_name)
set(multi_arg_names SOURCES EXTRA_LIBS)
cmake_parse_arguments(ET_CXX_TEST "" "" "${multi_arg_names}" ${ARGN})

# Find prebuilt executorch library
find_package(executorch CONFIG REQUIRED)

target_link_options_shared_lib(extension_data_loader)
target_link_options_shared_lib(portable_ops_lib)

enable_testing()
find_package(GTest CONFIG REQUIRED)

# Let files say "include <executorch/path/to/header.h>".
target_include_directories(executorch INTERFACE ${EXECUTORCH_ROOT}/..)

add_executable(${target_name} ${ET_CXX_TEST_SOURCES})
set(ET_TEST_UTIL_SOURCES ${EXECUTORCH_ROOT}/runtime/core/exec_aten/testing_util/tensor_util.cpp)

add_executable(${target_name} ${ET_CXX_TEST_SOURCES} ${ET_TEST_UTIL_SOURCES})
# Includes gtest, gmock, executorch by default
target_link_libraries(
${target_name} GTest::gtest GTest::gtest_main GTest::gmock executorch
Expand Down
28 changes: 28 additions & 0 deletions extension/evalue_util/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# @generated by test/utils/generate_gtest_cmakelists.py
#
# This file should be formatted with
# ~~~
# cmake-format -i CMakeLists.txt
# ~~~
# It should also be cmake-lint clean.
#

cmake_minimum_required(VERSION 3.19)
project(extension_evalue_util_test)

# Use C++17 for test.
set(CMAKE_CXX_STANDARD 17)

set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..)

include(${EXECUTORCH_ROOT}/build/Test.cmake)

set(_test_srcs print_evalue_test.cpp ../print_evalue.cpp)

et_cxx_test(extension_evalue_util_test SOURCES ${_test_srcs} EXTRA_LIBS)
28 changes: 28 additions & 0 deletions extension/kernel_util/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# @generated by test/utils/generate_gtest_cmakelists.py
#
# This file should be formatted with
# ~~~
# cmake-format -i CMakeLists.txt
# ~~~
# It should also be cmake-lint clean.
#

cmake_minimum_required(VERSION 3.19)
project(extension_kernel_util_test)

# Use C++17 for test.
set(CMAKE_CXX_STANDARD 17)

set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..)

include(${EXECUTORCH_ROOT}/build/Test.cmake)

set(_test_srcs make_boxed_from_unboxed_functor_test.cpp)

et_cxx_test(extension_kernel_util_test SOURCES ${_test_srcs} EXTRA_LIBS)
31 changes: 31 additions & 0 deletions kernels/portable/cpu/util/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# @generated by test/utils/generate_gtest_cmakelists.py
#
# This file should be formatted with
# ~~~
# cmake-format -i CMakeLists.txt
# ~~~
# It should also be cmake-lint clean.
#

cmake_minimum_required(VERSION 3.19)
project(kernels_portable_cpu_util_test)

# Use C++17 for test.
set(CMAKE_CXX_STANDARD 17)

set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../../..)

include(${EXECUTORCH_ROOT}/build/Test.cmake)

set(_test_srcs broadcast_test.cpp reduce_test.cpp)

et_cxx_test(
kernels_portable_cpu_util_test SOURCES ${_test_srcs} EXTRA_LIBS
portable_kernels portable_ops_lib
)
2 changes: 1 addition & 1 deletion runtime/core/exec_aten/testing_util/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../../..)

include(${EXECUTORCH_ROOT}/build/Test.cmake)

set(_test_srcs tensor_util_test.cpp tensor_factory_test.cpp ../tensor_util.cpp)
set(_test_srcs tensor_util_test.cpp tensor_factory_test.cpp)

et_cxx_test(
runtime_core_exec_aten_testing_util_test SOURCES ${_test_srcs} EXTRA_LIBS
Expand Down
6 changes: 2 additions & 4 deletions runtime/core/exec_aten/util/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../../..)

include(${EXECUTORCH_ROOT}/build/Test.cmake)

set(_test_srcs
tensor_util_test.cpp scalar_type_util_test.cpp
operator_impl_example_test.cpp dim_order_util_test.cpp
../../testing_util/tensor_util.cpp
set(_test_srcs tensor_util_test.cpp scalar_type_util_test.cpp
operator_impl_example_test.cpp dim_order_util_test.cpp
)

et_cxx_test(runtime_core_exec_aten_util_test SOURCES ${_test_srcs} EXTRA_LIBS)
30 changes: 30 additions & 0 deletions runtime/platform/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# This file should be formatted with
# ~~~
# cmake-format -i CMakeLists.txt
# ~~~
# It should also be cmake-lint clean.
#

cmake_minimum_required(VERSION 3.19)
project(runtime_platform_test)

# Use C++17 for test.
set(CMAKE_CXX_STANDARD 17)

set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..)

include(${EXECUTORCH_ROOT}/build/Test.cmake)

et_cxx_test(platform_test SOURCES executor_pal_test.cpp)

et_cxx_test(platform_death_test SOURCES executor_pal_death_test.cpp)

et_cxx_test(logging_test SOURCES logging_test.cpp)

et_cxx_test(clock_test SOURCES clock_test.cpp stub_platform.cpp)
26 changes: 26 additions & 0 deletions test/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

# This file should be formatted with
# ~~~
# cmake-format -i CMakeLists.txt
# ~~~
# It should also be cmake-lint clean.
#

cmake_minimum_required(VERSION 3.19)
project(test_utils)

# Use C++17 for test.
set(CMAKE_CXX_STANDARD 17)

set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)

include(${EXECUTORCH_ROOT}/build/Test.cmake)

set(_test_srcs alignment_test.cpp UnitTestMain.cpp)

et_cxx_test(test_utils_test SOURCES ${_test_srcs} EXTRA_LIBS)
30 changes: 26 additions & 4 deletions test/utils/OSSTestConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@
"extension_data_loader"
]
},
{
"directory": "extension/evalue_util/test",
"sources": [
"print_evalue_test.cpp",
"../print_evalue.cpp"
]
},
{
"directory": "extension/kernel_util/test",
"sources": [
"make_boxed_from_unboxed_functor_test.cpp"
]
},
{
"directory": "extension/module/test",
"sources": [
Expand All @@ -35,6 +48,17 @@
"portable_ops_lib"
]
},
{
"directory": "kernels/portable/cpu/util/test",
"sources": [
"broadcast_test.cpp",
"reduce_test.cpp"
],
"additional_libs": [
"portable_kernels",
"portable_ops_lib"
]
},
{
"directory": "runtime/core/portable_type/test",
"sources": [
Expand Down Expand Up @@ -64,16 +88,14 @@
"tensor_util_test.cpp",
"scalar_type_util_test.cpp",
"operator_impl_example_test.cpp",
"dim_order_util_test.cpp",
"../../testing_util/tensor_util.cpp"
"dim_order_util_test.cpp"
]
},
{
"directory": "runtime/core/exec_aten/testing_util/test",
"sources": [
"tensor_util_test.cpp",
"tensor_factory_test.cpp",
"../tensor_util.cpp"
"tensor_factory_test.cpp"
]
}
] }
Loading