Skip to content

Commit f034999

Browse files
kirklandsignfacebook-github-bot
authored andcommitted
extension/module c++ test (#3710)
Summary: * Install extension_module_static as well * Keep all symbols (whole-archive) for portable ops * Add test for extension/module Pull Request resolved: #3710 Test Plan: `sh test/run_oss_cpp_tests.sh extension/module/test` Reviewed By: shoumikhin Differential Revision: D57940456 Pulled By: kirklandsign fbshipit-source-id: 4a34633250a8c06c9d0db99cd1320cb2b53824a4
1 parent 0bbc654 commit f034999

File tree

7 files changed

+62
-2
lines changed

7 files changed

+62
-2
lines changed

build/Test.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
#
1313
# This file should be formatted with
1414
# ~~~
15-
# cmake-format -i Utils.cmake
15+
# cmake-format -i Test.cmake
1616
# ~~~
1717
# It should also be cmake-lint clean.
1818
#
1919

20+
include(${EXECUTORCH_ROOT}/build/Utils.cmake)
21+
2022
# Add code coverage flags to supported compilers
2123
if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
2224
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
@@ -54,6 +56,9 @@ cmake_parse_arguments(ET_CXX_TEST "" "" "${multi_arg_names}" ${ARGN})
5456
# Find prebuilt executorch library
5557
find_package(executorch CONFIG REQUIRED)
5658

59+
target_link_options_shared_lib(extension_data_loader)
60+
target_link_options_shared_lib(portable_ops_lib)
61+
5762
enable_testing()
5863
find_package(GTest CONFIG REQUIRED)
5964

build/executorch-config.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ set(lib_list
4343
qnn_executorch_backend
4444
portable_ops_lib
4545
extension_module
46+
extension_module_static
4647
xnnpack_backend
4748
XNNPACK
4849
cpuinfo

extension/module/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ target_compile_options(
4646

4747
# Install libraries
4848
install(
49-
TARGETS extension_module
49+
TARGETS extension_module extension_module_static
5050
DESTINATION lib
5151
INCLUDES
5252
DESTINATION ${_common_include_directories}

extension/module/test/CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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_module_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 module_test.cpp)
27+
28+
et_cxx_test(
29+
extension_module_test
30+
SOURCES
31+
${_test_srcs}
32+
EXTRA_LIBS
33+
extension_data_loader
34+
extension_module_static
35+
portable_kernels
36+
portable_ops_lib
37+
)

extension/module/test/module_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <gtest/gtest.h>
1010

1111
#include <executorch/extension/module/module.h>
12+
#include <array>
1213

1314
using namespace ::testing;
1415

test/run_oss_cpp_tests.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ build_executorch() {
2727
-DCMAKE_INSTALL_PREFIX=cmake-out \
2828
-DEXECUTORCH_USE_CPP_CODE_COVERAGE=ON \
2929
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
30+
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
3031
-Bcmake-out
3132
cmake --build cmake-out -j9 --target install
3233
}
@@ -49,6 +50,8 @@ build_and_run_test() {
4950
-Bcmake-out/"${test_dir}"
5051
cmake --build cmake-out/"${test_dir}" -j9
5152

53+
export RESOURCES_PATH=extension/module/test/resources
54+
5255
for t in cmake-out/"${test_dir}"/*test; do
5356
if [ -e "$t" ]; then
5457
LLVM_PROFILE_FILE="cmake-out/$(basename $t).profraw" ./"$t";

test/utils/OSSTestConfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@
1111
"extension_data_loader"
1212
]
1313
},
14+
{
15+
"directory": "extension/module/test",
16+
"sources": [
17+
"module_test.cpp"
18+
],
19+
"additional_libs": [
20+
"extension_data_loader",
21+
"extension_module_static",
22+
"portable_kernels",
23+
"portable_ops_lib"
24+
25+
]
26+
},
1427
{
1528
"directory": "runtime/core/portable_type/test",
1629
"sources": [

0 commit comments

Comments
 (0)