Skip to content
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
46 changes: 46 additions & 0 deletions runtime/core/portable_type/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 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.

# ### Editing this file ###
#
# 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_core_portable_type_test)

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

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

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

# Find prebuilt executorch library
find_package(executorch CONFIG REQUIRED)

enable_testing()
find_package(GTest CONFIG REQUIRED)

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

set(_test_srcs optional_test.cpp executor_tensor_test.cpp half_test.cpp
scalar_test.cpp tensor_impl_test.cpp
)

add_executable(runtime_core_portable_type_test ${_test_srcs})
target_link_libraries(
runtime_core_portable_type_test GTest::gtest GTest::gtest_main executorch
)
add_test(ExecuTorchTest runtime_core_portable_type_test)
23 changes: 23 additions & 0 deletions test/run_oss_cpp_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this script out of portable_type/test/?

# 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.

set -ex

build_executorch() {
cmake . -DCMAKE_INSTALL_PREFIX=cmake-out -DEXECUTORCH_BUILD_GTESTS=ON -Bcmake-out
cmake --build cmake-out -j9 --target install
}

build_and_run_test() {
local test_dir=$1
cmake "${test_dir}" -Bcmake-out/"${test_dir}" -DCMAKE_INSTALL_PREFIX=cmake-out
cmake --build cmake-out/"${test_dir}"
for t in $(cmake-out/"${test_dir}"/*test); do ./"$t"; done
}

build_executorch
build_and_run_test runtime/core/portable_type/test/