forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LIT] Added an option to llvm-lit to emit the necessary test coverage…
… data, divided per test case This patch is the first part of https://llvm.org/OpenProjects.html#llvm_patch_coverage. We have first define a new variable LLVM_TEST_COVERAGE which when set, pass --per-test-coverage option to llvm-lit which will help in setting a unique value to LLVM_PROFILE_FILE for each RUN. So for example coverage data for test case llvm/test/Analysis/AliasSet/memtransfer.ll will be emitted as build/test/Analysis/AliasSet/memtransfer0.profraw Reviewed By: hnrklssn Differential Revision: https://reviews.llvm.org/D154280
- Loading branch information
Showing
14 changed files
with
123 additions
and
16 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
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
8 changes: 8 additions & 0 deletions
8
llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/lit.cfg
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,8 @@ | ||
import lit.formats | ||
import os | ||
|
||
config.name = "per-test-coverage-by-lit-cfg" | ||
config.suffixes = [".py"] | ||
config.test_format = lit.formats.ShTest(execute_external=True) | ||
lit_config.per_test_coverage = True | ||
config.substitutions.append(("%{python}", '"%s"' % (sys.executable))) |
11 changes: 11 additions & 0 deletions
11
llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/per-test-coverage-by-lit-cfg.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,11 @@ | ||
# Check that the environment variable is set correctly | ||
# RUN: %{python} %s | FileCheck %s | ||
|
||
# Python script to read the environment variable | ||
# and print its value | ||
import os | ||
|
||
llvm_profile_file = os.environ.get('LLVM_PROFILE_FILE') | ||
print(llvm_profile_file) | ||
|
||
# CHECK: per-test-coverage-by-lit-cfg0.profraw |
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,8 @@ | ||
import lit.formats | ||
import os | ||
|
||
config.name = "per-test-coverage" | ||
config.suffixes = [".py"] | ||
config.test_format = lit.formats.ShTest(execute_external=True) | ||
config.substitutions.append(("%{python}", '"%s"' % (sys.executable))) | ||
|
11 changes: 11 additions & 0 deletions
11
llvm/utils/lit/tests/Inputs/per-test-coverage/per-test-coverage.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,11 @@ | ||
# Check that the environment variable is set correctly | ||
# RUN: %{python} %s | FileCheck %s | ||
|
||
# Python script to read the environment variable | ||
# and print its value | ||
import os | ||
|
||
llvm_profile_file = os.environ.get('LLVM_PROFILE_FILE') | ||
print(llvm_profile_file) | ||
|
||
# CHECK: per-test-coverage0.profraw |
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,6 @@ | ||
# Test if lit_config.per_test_coverage in lit.cfg sets individual test case coverage. | ||
|
||
# RUN: %{lit} -a -v %{inputs}/per-test-coverage-by-lit-cfg/per-test-coverage-by-lit-cfg.py \ | ||
# RUN: | FileCheck -match-full-lines %s | ||
# | ||
# CHECK: PASS: per-test-coverage-by-lit-cfg :: per-test-coverage-by-lit-cfg.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,6 @@ | ||
# Test LLVM_PROFILE_FILE is set when --per-test-coverage is passed to command line. | ||
|
||
# RUN: %{lit} -a -v --per-test-coverage %{inputs}/per-test-coverage/per-test-coverage.py \ | ||
# RUN: | FileCheck -match-full-lines %s | ||
# | ||
# CHECK: PASS: per-test-coverage :: per-test-coverage.py ({{[^)]*}}) |