Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lit] Use sharding for GoogleTest format
This helps lit unit test performance by a lot, especially on windows. The performance gain comes from launching one gtest executable for many subtests instead of one (this is the current situation). The shards are executed by the test runner and the results are stored in the json format supported by the GoogleTest. Later in the test reporting stage, all test results in the json file are retrieved to continue the test results summary etc. On my Win10 desktop, before this patch: `check-clang-unit`: 177s, `check-llvm-unit`: 38s; after this patch: `check-clang-unit`: 37s, `check-llvm-unit`: 11s. On my Linux machine, before this patch: `check-clang-unit`: 46s, `check-llvm-unit`: 8s; after this patch: `check-clang-unit`: 7s, `check-llvm-unit`: 4s. Reviewed By: yln, rnk Differential Revision: https://reviews.llvm.org/D122251
- Loading branch information
Yuanfang Chen
committed
Apr 4, 2022
1 parent
f830392
commit a87ba5c
Showing
13 changed files
with
327 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
llvm/utils/lit/tests/Inputs/googletest-crash/DummySubDir/OneTest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
import sys | ||
|
||
if len(sys.argv) == 3 and sys.argv[1] == "--gtest_list_tests": | ||
if sys.argv[2] != '--gtest_filter=-*DISABLED_*': | ||
raise ValueError("unexpected argument: %s" % (sys.argv[2])) | ||
print("""\ | ||
FirstTest. | ||
subTestA | ||
subTestB | ||
subTestC | ||
subTestD | ||
ParameterizedTest/0. | ||
subTest | ||
ParameterizedTest/1. | ||
subTest""") | ||
sys.exit(0) | ||
elif len(sys.argv) != 1: | ||
# sharding and json output are specified using environment variables | ||
raise ValueError("unexpected argument: %r" % (' '.join(sys.argv[1:]))) | ||
|
||
for e in ['GTEST_TOTAL_SHARDS', 'GTEST_SHARD_INDEX', 'GTEST_OUTPUT']: | ||
if e not in os.environ: | ||
raise ValueError("missing environment variables: " + e) | ||
|
||
if not os.environ['GTEST_OUTPUT'].startswith('json:'): | ||
raise ValueError("must emit json output: " + os.environ['GTEST_OUTPUT']) | ||
|
||
dummy_output = """\ | ||
{ | ||
"testsuites": [ | ||
] | ||
}""" | ||
|
||
if os.environ['GTEST_SHARD_INDEX'] == '0': | ||
exit_code = 1 | ||
else: | ||
json_filename = os.environ['GTEST_OUTPUT'].split(':', 1)[1] | ||
with open(json_filename, 'w') as f: | ||
f.write(dummy_output) | ||
exit_code = 0 | ||
|
||
sys.exit(exit_code) |
Oops, something went wrong.