Skip to content

Commit 1d7c7c8

Browse files
kirklandsignfacebook-github-bot
authored andcommitted
Add more tests and clean up helper (#3783)
Summary: Added extension/evalue_util/test, extension/kernel_util/test, runtime/platform/test, kernels/portable/cpu/util/test Clean up Test.cmake Pull Request resolved: #3783 Reviewed By: shoumikhin Differential Revision: D58031811 Pulled By: kirklandsign fbshipit-source-id: 4e5bbfcee486a2e0c1d9d9e596649bb9b6268443
1 parent a463f0b commit 1d7c7c8

File tree

9 files changed

+184
-19
lines changed

9 files changed

+184
-19
lines changed

build/Test.cmake

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919

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

22+
# Find prebuilt executorch library
23+
find_package(executorch CONFIG REQUIRED)
24+
25+
enable_testing()
26+
find_package(GTest CONFIG REQUIRED)
27+
28+
target_link_options_shared_lib(extension_data_loader)
29+
target_link_options_shared_lib(portable_ops_lib)
30+
2231
# Add code coverage flags to supported compilers
2332
if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
2433
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
@@ -53,19 +62,12 @@ function(et_cxx_test target_name)
5362
set(multi_arg_names SOURCES EXTRA_LIBS)
5463
cmake_parse_arguments(ET_CXX_TEST "" "" "${multi_arg_names}" ${ARGN})
5564

56-
# Find prebuilt executorch library
57-
find_package(executorch CONFIG REQUIRED)
58-
59-
target_link_options_shared_lib(extension_data_loader)
60-
target_link_options_shared_lib(portable_ops_lib)
61-
62-
enable_testing()
63-
find_package(GTest CONFIG REQUIRED)
64-
6565
# Let files say "include <executorch/path/to/header.h>".
6666
target_include_directories(executorch INTERFACE ${EXECUTORCH_ROOT}/..)
6767

68-
add_executable(${target_name} ${ET_CXX_TEST_SOURCES})
68+
set(ET_TEST_UTIL_SOURCES ${EXECUTORCH_ROOT}/runtime/core/exec_aten/testing_util/tensor_util.cpp)
69+
70+
add_executable(${target_name} ${ET_CXX_TEST_SOURCES} ${ET_TEST_UTIL_SOURCES})
6971
# Includes gtest, gmock, executorch by default
7072
target_link_libraries(
7173
${target_name} GTest::gtest GTest::gtest_main GTest::gmock executorch
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# @generated by test/utils/generate_gtest_cmakelists.py
8+
#
9+
# This file should be formatted with
10+
# ~~~
11+
# cmake-format -i CMakeLists.txt
12+
# ~~~
13+
# It should also be cmake-lint clean.
14+
#
15+
16+
cmake_minimum_required(VERSION 3.19)
17+
project(extension_evalue_util_test)
18+
19+
# Use C++17 for test.
20+
set(CMAKE_CXX_STANDARD 17)
21+
22+
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
23+
24+
include(${EXECUTORCH_ROOT}/build/Test.cmake)
25+
26+
set(_test_srcs print_evalue_test.cpp ../print_evalue.cpp)
27+
28+
et_cxx_test(extension_evalue_util_test SOURCES ${_test_srcs} EXTRA_LIBS)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# @generated by test/utils/generate_gtest_cmakelists.py
8+
#
9+
# This file should be formatted with
10+
# ~~~
11+
# cmake-format -i CMakeLists.txt
12+
# ~~~
13+
# It should also be cmake-lint clean.
14+
#
15+
16+
cmake_minimum_required(VERSION 3.19)
17+
project(extension_kernel_util_test)
18+
19+
# Use C++17 for test.
20+
set(CMAKE_CXX_STANDARD 17)
21+
22+
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
23+
24+
include(${EXECUTORCH_ROOT}/build/Test.cmake)
25+
26+
set(_test_srcs make_boxed_from_unboxed_functor_test.cpp)
27+
28+
et_cxx_test(extension_kernel_util_test SOURCES ${_test_srcs} EXTRA_LIBS)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# @generated by test/utils/generate_gtest_cmakelists.py
8+
#
9+
# This file should be formatted with
10+
# ~~~
11+
# cmake-format -i CMakeLists.txt
12+
# ~~~
13+
# It should also be cmake-lint clean.
14+
#
15+
16+
cmake_minimum_required(VERSION 3.19)
17+
project(kernels_portable_cpu_util_test)
18+
19+
# Use C++17 for test.
20+
set(CMAKE_CXX_STANDARD 17)
21+
22+
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../../..)
23+
24+
include(${EXECUTORCH_ROOT}/build/Test.cmake)
25+
26+
set(_test_srcs broadcast_test.cpp reduce_test.cpp)
27+
28+
et_cxx_test(
29+
kernels_portable_cpu_util_test SOURCES ${_test_srcs} EXTRA_LIBS
30+
portable_kernels portable_ops_lib
31+
)

runtime/core/exec_aten/testing_util/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../../..)
2323

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

26-
set(_test_srcs tensor_util_test.cpp tensor_factory_test.cpp ../tensor_util.cpp)
26+
set(_test_srcs tensor_util_test.cpp tensor_factory_test.cpp)
2727

2828
et_cxx_test(
2929
runtime_core_exec_aten_testing_util_test SOURCES ${_test_srcs} EXTRA_LIBS

runtime/core/exec_aten/util/test/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../../..)
2323

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

26-
set(_test_srcs
27-
tensor_util_test.cpp scalar_type_util_test.cpp
28-
operator_impl_example_test.cpp dim_order_util_test.cpp
29-
../../testing_util/tensor_util.cpp
26+
set(_test_srcs tensor_util_test.cpp scalar_type_util_test.cpp
27+
operator_impl_example_test.cpp dim_order_util_test.cpp
3028
)
3129

3230
et_cxx_test(runtime_core_exec_aten_util_test SOURCES ${_test_srcs} EXTRA_LIBS)

runtime/platform/test/CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# This file should be formatted with
8+
# ~~~
9+
# cmake-format -i CMakeLists.txt
10+
# ~~~
11+
# It should also be cmake-lint clean.
12+
#
13+
14+
cmake_minimum_required(VERSION 3.19)
15+
project(runtime_platform_test)
16+
17+
# Use C++17 for test.
18+
set(CMAKE_CXX_STANDARD 17)
19+
20+
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
21+
22+
include(${EXECUTORCH_ROOT}/build/Test.cmake)
23+
24+
et_cxx_test(platform_test SOURCES executor_pal_test.cpp)
25+
26+
et_cxx_test(platform_death_test SOURCES executor_pal_death_test.cpp)
27+
28+
et_cxx_test(logging_test SOURCES logging_test.cpp)
29+
30+
et_cxx_test(clock_test SOURCES clock_test.cpp stub_platform.cpp)

test/utils/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# This file should be formatted with
8+
# ~~~
9+
# cmake-format -i CMakeLists.txt
10+
# ~~~
11+
# It should also be cmake-lint clean.
12+
#
13+
14+
cmake_minimum_required(VERSION 3.19)
15+
project(test_utils)
16+
17+
# Use C++17 for test.
18+
set(CMAKE_CXX_STANDARD 17)
19+
20+
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
21+
22+
include(${EXECUTORCH_ROOT}/build/Test.cmake)
23+
24+
set(_test_srcs alignment_test.cpp UnitTestMain.cpp)
25+
26+
et_cxx_test(test_utils_test SOURCES ${_test_srcs} EXTRA_LIBS)

test/utils/OSSTestConfig.json

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@
1111
"extension_data_loader"
1212
]
1313
},
14+
{
15+
"directory": "extension/evalue_util/test",
16+
"sources": [
17+
"print_evalue_test.cpp",
18+
"../print_evalue.cpp"
19+
]
20+
},
21+
{
22+
"directory": "extension/kernel_util/test",
23+
"sources": [
24+
"make_boxed_from_unboxed_functor_test.cpp"
25+
]
26+
},
1427
{
1528
"directory": "extension/module/test",
1629
"sources": [
@@ -35,6 +48,17 @@
3548
"portable_ops_lib"
3649
]
3750
},
51+
{
52+
"directory": "kernels/portable/cpu/util/test",
53+
"sources": [
54+
"broadcast_test.cpp",
55+
"reduce_test.cpp"
56+
],
57+
"additional_libs": [
58+
"portable_kernels",
59+
"portable_ops_lib"
60+
]
61+
},
3862
{
3963
"directory": "runtime/core/portable_type/test",
4064
"sources": [
@@ -64,16 +88,14 @@
6488
"tensor_util_test.cpp",
6589
"scalar_type_util_test.cpp",
6690
"operator_impl_example_test.cpp",
67-
"dim_order_util_test.cpp",
68-
"../../testing_util/tensor_util.cpp"
91+
"dim_order_util_test.cpp"
6992
]
7093
},
7194
{
7295
"directory": "runtime/core/exec_aten/testing_util/test",
7396
"sources": [
7497
"tensor_util_test.cpp",
75-
"tensor_factory_test.cpp",
76-
"../tensor_util.cpp"
98+
"tensor_factory_test.cpp"
7799
]
78100
}
79101
] }

0 commit comments

Comments
 (0)