Skip to content

Commit fbbec00

Browse files
guangy10facebook-github-bot
authored andcommitted
Initial gtest bringup for executorch c++ tests (#271)
Summary: Pull Request resolved: #271 Buck build and run executorch c++ tests on OSS with `gtest` Reviewed By: mergennachin Differential Revision: D49171169 fbshipit-source-id: 7082ac4bf3371d9a93b04a3e2ff21ed06a384c11
1 parent 8c0dcea commit fbbec00

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

shim/xplat/executorch/build/env_interface.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ _EXTERNAL_DEPS = {
2929
"gen-oplist-lib": "//third-party:gen_oplist_lib",
3030
# Commandline flags library
3131
"gflags": "//third-party:gflags",
32-
"gmock": [], # TODO(larryliu0820): Add support
32+
"gmock": "//third-party:gmock",
3333
"gtest": "//third-party:gtest",
3434
"libtorch": "//third-party:libtorch",
3535
"prettytable": "//third-party:prettytable",

shim/xplat/executorch/build/runtime_wrapper.bzl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,17 @@ def _patch_test_compiler_flags(kwargs):
115115
if "compiler_flags" not in kwargs:
116116
kwargs["compiler_flags"] = []
117117

118+
# Required globally by all c++ tests.
119+
kwargs["compiler_flags"].extend([
120+
"-std=c++17",
121+
])
122+
118123
# Relaxing some constraints for tests
119-
kwargs["compiler_flags"].extend(["-Wno-missing-prototypes", "-Wno-unused-variable", "-Wno-error"])
124+
kwargs["compiler_flags"].extend([
125+
"-Wno-missing-prototypes",
126+
"-Wno-unused-variable",
127+
"-Wno-error",
128+
])
120129
return kwargs
121130

122131
def _external_dep_location(name):

test/utils/UnitTestMain.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,17 @@
99
/**
1010
* @file
1111
* Custom main function for unit test executables.
12-
* Based on `fbcode//common/gtest/LightMain.cpp`
1312
*/
1413

1514
#include <executorch/runtime/platform/compiler.h>
1615
#include <executorch/runtime/platform/runtime.h>
17-
#include <folly/init/Init.h>
1816
#include <gtest/gtest.h>
1917

2018
// Define main as a weak symbol to allow trivial overriding.
2119
int main(int argc, char** argv) __ET_WEAK;
2220

2321
int main(int argc, char** argv) {
2422
::testing::InitGoogleTest(&argc, argv);
25-
folly::init(&argc, &argv);
2623
torch::executor::runtime_init();
2724
return RUN_ALL_TESTS();
2825
}

test/utils/targets.bzl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@ def define_common_targets():
2424
"//executorch/runtime/platform:platform",
2525
"//executorch/runtime/core:core",
2626
],
27-
fbcode_exported_deps = [
28-
"//common/init:init",
29-
"//common/gtest:gtest",
30-
],
31-
xplat_exported_deps = [
32-
"//xplat/folly:init_init",
33-
"//xplat/third-party/gmock:gmock",
27+
exported_external_deps = [
28+
"gtest",
29+
"gmock",
3430
],
3531
)
3632

0 commit comments

Comments
 (0)