Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5407aaa

Browse files
null77Commit Bot
authored andcommitted
Re-land "Add new test runner harness." (#2)
Re-land #2 changes: * export labels are fixed for the CFI build * crash test disabled because of flakiness and issues with asan Re-land changes: * Unit test is suppressed in ASAN * --deqp-case is fixed * Debug layer errors should correctly work with failure expectations Original message: The ANGLE test harness is a harness around GoogleTest that provides functionality similar to the Chromium test harness. It supports: * splitting a test set into shards * catching and reporting crashes and timeouts * outputting to the Chromium JSON test results format * multi-process execution Unit tests are added in test_utils_unittest.cpp. Bug: angleproject:3162 Bug: chromium:1030192 Change-Id: I71d66a407ea0e53d73cbe75b5b4bfb9e73791534 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1965091 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
1 parent 5cfab19 commit 5407aaa

22 files changed

+1729
-148
lines changed

gni/angle.gni

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,14 @@ set_defaults("angle_test") {
189189
public_deps = []
190190
sources = []
191191
data = []
192+
defines = []
192193
main = ""
193194
suppressed_configs = angle_remove_configs
194195

195-
# TODO(jmadill): Migrate to standalone harness. http://anglebug.com/3162
196-
if (build_with_chromium) {
196+
# By default use the Chromium harness in Chromium. Can be overriden in a target.
197+
standalone_harness = !build_with_chromium
198+
199+
if (!standalone_harness) {
197200
suppressed_configs -= [ "//build/config/compiler:default_include_dirs" ]
198201
}
199202

@@ -286,18 +289,6 @@ template("angle_static_library") {
286289
}
287290

288291
template("angle_test") {
289-
_googletest_deps = [
290-
"//testing/gmock",
291-
"//testing/gtest",
292-
"//third_party/googletest:gmock",
293-
"//third_party/googletest:gtest",
294-
]
295-
296-
# TODO(jmadill): Migrate to standalone harness. http://anglebug.com/3162
297-
if (build_with_chromium) {
298-
_googletest_deps += [ "//base/test:test_support" ]
299-
}
300-
301292
test(target_name) {
302293
forward_variables_from(invoker,
303294
"*",
@@ -311,32 +302,51 @@ template("angle_test") {
311302
forward_variables_from(invoker, [ "visibility" ])
312303

313304
configs += invoker.configs
314-
configs -= invoker.suppressed_configs
315-
configs -= [ angle_root + ":constructor_and_destructor_warnings" ]
316-
configs -= [ angle_root + ":extra_warnings" ]
305+
configs -= invoker.suppressed_configs + [
306+
"$angle_root:constructor_and_destructor_warnings",
307+
"$angle_root:extra_warnings",
308+
]
317309

318310
if (is_linux && !is_component_build) {
319311
# Set rpath to find shared libs in a non-component build.
320312
configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
321313
}
322314

323315
if (is_android) {
324-
configs += [ angle_root + ":build_id_config" ]
325-
if (build_with_chromium) {
326-
configs -= [ "//build/config/android:hide_all_but_jni" ]
327-
}
316+
configs += [ "$angle_root:build_id_config" ]
328317
}
329318

330-
deps += _googletest_deps + [
331-
"$angle_root:angle_common",
332-
"$angle_root:includes",
333-
"$angle_root/util:angle_test_utils",
334-
]
335-
336-
if (build_with_chromium) {
337-
sources += [ "//gpu/${invoker.main}.cc" ]
319+
deps += [
320+
"$angle_root:angle_common",
321+
"$angle_root:includes",
322+
"$angle_root/third_party/rapidjson:rapidjson",
323+
"$angle_root/util:angle_test_utils",
324+
"//testing/gmock",
325+
"//testing/gtest",
326+
"//third_party/googletest:gmock",
327+
"//third_party/googletest:gtest",
328+
]
329+
330+
sources += [
331+
"$angle_root/src/tests/test_utils/runner/TestSuite.cpp",
332+
"$angle_root/src/tests/test_utils/runner/TestSuite.h",
333+
]
334+
335+
# To use the Chromium test infrastructure we must currently use the //base test launcher.
336+
# Eventually we could switch to using standalone testing. See http://crbug.com/837741
337+
if (standalone_harness) {
338+
if (invoker.main != "") {
339+
sources += [ "${invoker.main}.cpp" ]
340+
}
338341
} else {
339-
sources += [ "${invoker.main}.cpp" ]
342+
if (invoker.main != "") {
343+
sources += [ "//gpu/${invoker.main}.cc" ]
344+
}
345+
deps += [ "//base/test:test_support" ]
346+
347+
if (is_android) {
348+
configs -= [ "//build/config/android:hide_all_but_jni" ]
349+
}
340350
}
341351
}
342352
}

src/common/platform.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,11 @@
123123
# endif
124124
#endif
125125

126+
// Define ANGLE_WITH_ASAN macro.
127+
#if defined(__has_feature)
128+
# if __has_feature(address_sanitizer)
129+
# define ANGLE_WITH_ASAN 1
130+
# endif
131+
#endif
132+
126133
#endif // COMMON_PLATFORM_H_

src/common/system_utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ namespace angle
1717
std::string GetExecutablePath();
1818
std::string GetExecutableDirectory();
1919
const char *GetSharedLibraryExtension();
20+
const char *GetExecutableExtension();
21+
char GetPathSeparator();
2022
Optional<std::string> GetCWD();
2123
bool SetCWD(const char *dirName);
2224
bool SetEnvironmentVar(const char *variableName, const char *value);

src/common/system_utils_posix.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,14 @@ void BreakDebugger()
125125
// See https://cs.chromium.org/chromium/src/base/debug/debugger_posix.cc
126126
abort();
127127
}
128+
129+
const char *GetExecutableExtension()
130+
{
131+
return "";
132+
}
133+
134+
char GetPathSeparator()
135+
{
136+
return '/';
137+
}
128138
} // namespace angle

src/common/system_utils_win.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,13 @@ void BreakDebugger()
166166
__debugbreak();
167167
}
168168

169+
const char *GetExecutableExtension()
170+
{
171+
return ".exe";
172+
}
173+
174+
char GetPathSeparator()
175+
{
176+
return '\\';
177+
}
169178
} // namespace angle

src/tests/BUILD.gn

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@ declare_args() {
1313
build_angle_gles1_conform_tests = false
1414
}
1515

16-
angle_executable("test_utils_unittest_helper") {
17-
sources = test_utils_unittest_helper_sources
16+
angle_test("test_utils_unittest_helper") {
17+
standalone_harness = true
18+
19+
sources = [
20+
"../../util/test_utils_unittest_helper.cpp",
21+
"../../util/test_utils_unittest_helper.h",
22+
"test_utils/angle_test_instantiate.h",
23+
"test_utils/runner/TestSuite_unittest.cpp",
24+
]
1825

1926
deps = [
20-
"${angle_root}:angle_common",
27+
"$angle_root:angle_common",
2128
]
2229
}
2330

src/tests/angle_deqp_tests_main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include <gtest/gtest.h>
1010

11+
#include "test_utils/runner/TestSuite.h"
12+
1113
// Defined in angle_deqp_gtest.cpp. Declared here so we don't need to make a header that we import
1214
// in Chromium.
1315
namespace angle
@@ -18,7 +20,7 @@ void InitTestHarness(int *argc, char **argv);
1820
int main(int argc, char **argv)
1921
{
2022
angle::InitTestHarness(&argc, argv);
21-
testing::InitGoogleTest(&argc, argv);
23+
angle::TestSuite testSuite(&argc, argv);
2224
int rt = RUN_ALL_TESTS();
2325
return rt;
2426
}

src/tests/angle_end2end_tests_main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
//
66

77
#include "gtest/gtest.h"
8+
#include "test_utils/runner/TestSuite.h"
89

910
void ANGLEProcessTestArgs(int *argc, char *argv[]);
1011

1112
int main(int argc, char **argv)
1213
{
14+
angle::TestSuite testSuite(&argc, argv);
1315
ANGLEProcessTestArgs(&argc, argv);
14-
testing::InitGoogleTest(&argc, argv);
1516
int rt = RUN_ALL_TESTS();
1617
return rt;
1718
}

src/tests/angle_perftests_main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99

1010
#include <gtest/gtest.h>
1111

12+
#include "test_utils/runner/TestSuite.h"
13+
1214
void ANGLEProcessPerfTestArgs(int *argc, char **argv);
1315

1416
int main(int argc, char **argv)
1517
{
18+
angle::TestSuite testSuite(&argc, argv);
1619
ANGLEProcessPerfTestArgs(&argc, argv);
17-
testing::InitGoogleTest(&argc, argv);
18-
testing::AddGlobalTestEnvironment(new testing::Environment());
1920
int rt = RUN_ALL_TESTS();
2021
return rt;
2122
}

src/tests/angle_unittest_main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "GLSLANG/ShaderLang.h"
88
#include "gtest/gtest.h"
9+
#include "test_utils/runner/TestSuite.h"
910

1011
class CompilerTestEnvironment : public testing::Environment
1112
{
@@ -29,8 +30,7 @@ class CompilerTestEnvironment : public testing::Environment
2930

3031
int main(int argc, char **argv)
3132
{
32-
testing::InitGoogleTest(&argc, argv);
33+
angle::TestSuite testSuite(&argc, argv);
3334
testing::AddGlobalTestEnvironment(new CompilerTestEnvironment());
34-
int rt = RUN_ALL_TESTS();
35-
return rt;
35+
return testSuite.run();
3636
}

0 commit comments

Comments
 (0)