diff --git a/runtime/core/portable_type/test/CMakeLists.txt b/runtime/core/portable_type/test/CMakeLists.txt new file mode 100644 index 00000000000..3ea05677c3d --- /dev/null +++ b/runtime/core/portable_type/test/CMakeLists.txt @@ -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 ". +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) diff --git a/test/run_oss_cpp_tests.sh b/test/run_oss_cpp_tests.sh new file mode 100644 index 00000000000..dcc8b4d27f6 --- /dev/null +++ b/test/run_oss_cpp_tests.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# 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/