-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[coverage] Automatic merger for LLVM profile data #1126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 28 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
eb27ca1
[coverage] Initial commit of profdata merging worker
2cf852f
[coverage] Cleaned up profdata merge worker and added debug flag
c6c0b3d
[coverage] Removed explicit swift-%p.profraw arguments from CMake com…
32fda29
[coverage] Made subclass of list test format so we can hook into each…
a41ec1a
[coverage] Cleaned up argument parsing for swift coverage, and hooked…
78612e5
[coverage] Added before_test and after_test hooks in SwiftTest
03964cc
[coverage] Simplified before_test and after_test
3ea61fb
[coverage] Fixed runtime error in lit.cfg
9eb729c
[coverage] Reworked CMake invocation for coverage testing given there…
fb6ee1a
[coverage] Added argument parsing to profdata merge worker and cleane…
259af4d
[coverage] Cleaned up target generation and lit merging code
c83fb1c
[coverage] Fixed CMake invocation of profdata merge worker
1b30a49
[coverage] Added license header to profdata_merge_worker and added ex…
5a2a809
[coverage] Removed printing in CMake
9fccf50
[coverage] Fixed conflicts with master
bb8160a
[coverage] Declared SWIFT_ANALYZE_CODE_COVERAGE in CMakeLists and doc…
b4c7678
[coverage] Documented modes for SWIFT_ANALYZE_CODE_COVERAGE and added…
e997fc3
[coverage] Changed 'none' to 'false' for coverage default
44be500
[coverage] Changed back to old coverage check in CMakeLists.txt files
7608f88
[coverage] Removed print in built script
b1d6e17
[coverage] Added coverage_mode definitions in validation test and Uni…
0e6f798
[coverage] Made sure code coverage doesn't rename the ninja build dir…
e9d009e
[coverage] Merged and fixed conflicts
44e44ad
Merged upstream master into profdata-merge
b8a2249
Merged upstream master into profdata-merge
96d4261
[coverage] Made some stylistic changes for CMake consistency
1777c20
[coverage] Fixed indentation in CMake
d41bd9a
[coverage] Made SWIFT_ANALYZE_CODE_COVERAGE a string option instead o…
f99fd75
[coverage] Converted global non-constants to explicitly passed parame…
d7eff48
[coverage] Converted to print function
693d7da
[coverage] Converted to explicit super in lit.cfg
6572267
[coverage] Split profdata_merge_worker.py into separate files within …
dea48f4
[coverage] Fixed missing import
eb9fb9c
[coverage] Used gettempdir() instead of hard-coding /tmp
45df849
[coverage] Explicit super in process.py
873af8e
[coverage] Fail gracefully on non-Darwin
f713042
[coverage] Added license header to config.py
c75fa76
[coverage] Added README for the profdata module
6ec0dd3
[coverage] Added log file output to profdata merger
cf30318
[coverage] Converted to python standard logging framework
13bae93
[coverage] pep8
2b22040
[coverage] Removed unused imports
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -24,7 +24,10 @@ import re | |
import subprocess | ||
import sys | ||
import tempfile | ||
import socket | ||
import glob | ||
|
||
import lit | ||
import lit.formats | ||
import lit.util | ||
|
||
|
@@ -129,6 +132,43 @@ if config.test_exec_root is None: | |
|
||
### | ||
|
||
class SwiftTest(lit.formats.ShTest): | ||
def __init__(self, coverage_mode=None, execute_external=True): | ||
lit.formats.ShTest.__init__(self, execute_external=execute_external) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's preferable to use super(SwiftTest, self).__init__(execute_external=excute_external) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
if coverage_mode == "FALSE": | ||
self.coverage_mode = None | ||
else: | ||
self.coverage_mode = coverage_mode | ||
|
||
def profdir_for_test(self, test): | ||
_, tmp_base = lit.TestRunner.getTempPaths(test) | ||
return tmp_base + ".profdir" | ||
|
||
def before_test(self, test, litConfig): | ||
if self.coverage_mode: | ||
profdir = self.profdir_for_test(test) | ||
if not os.path.exists(profdir): | ||
os.makedirs(profdir) | ||
|
||
test.config.environment["LLVM_PROFILE_FILE"] = \ | ||
os.path.join(profdir, "swift-%p.profraw") | ||
|
||
def after_test(self, test, litConfig, result): | ||
if self.coverage_mode == "MERGED": | ||
profdir = self.profdir_for_test(test) | ||
files = glob.glob(os.path.join(profdir, "swift-*.profraw")) | ||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
sock.connect(('localhost', 12400)) | ||
sock.send("\n".join(files)) | ||
sock.close() | ||
return result | ||
|
||
|
||
def execute(self, test, litConfig): | ||
self.before_test(test, litConfig) | ||
result = super(SwiftTest, self).execute(test, litConfig) | ||
return self.after_test(test, litConfig, result) | ||
|
||
# name: The name of this test suite. | ||
config.name = 'Swift' | ||
|
||
|
@@ -138,7 +178,7 @@ if platform.system() == 'Darwin': | |
config.environment['TOOLCHAINS'] = 'default' | ||
|
||
# testFormat: The test format to use to interpret tests. | ||
config.test_format = lit.formats.ShTest(execute_external=True) | ||
config.test_format = SwiftTest(coverage_mode=config.coverage_mode) | ||
|
||
# suffixes: A list of file extensions to treat as test files. | ||
config.suffixes = ['.swift', '.ll', '.sil', '.gyb', '.m'] | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It comes from
lit.site.cfg.in
-- CMake fills it in with the appropriate value, and it's used to determine the pre- and post-test behaviorThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, whoops! I deleted my comment too late--I had misread 😅