Skip to content

Commit f83f796

Browse files
committed
coverage: Add UI tests for values accepted by -Cinstrument-coverage
1 parent 62fae23 commit f83f796

12 files changed

+71
-2
lines changed

src/tools/tidy/src/ui_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
1111
const ENTRY_LIMIT: usize = 900;
1212
// FIXME: The following limits should be reduced eventually.
1313
const ISSUES_ENTRY_LIMIT: usize = 1854;
14-
const ROOT_ENTRY_LIMIT: usize = 865;
14+
const ROOT_ENTRY_LIMIT: usize = 866;
1515

1616
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
1717
"rs", // test source files
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Test that `-Cinstrument-coverage=off` does not add coverage instrumentation to LLVM IR.
2+
3+
// needs-profiler-support
4+
// revisions: n no off false zero
5+
// [n] compile-flags: -Cinstrument-coverage=n
6+
// [no] compile-flags: -Cinstrument-coverage=no
7+
// [off] compile-flags: -Cinstrument-coverage=off
8+
// [false] compile-flags: -Cinstrument-coverage=false
9+
// [zero] compile-flags: -Cinstrument-coverage=0
10+
11+
// CHECK-NOT: __llvm_profile_filename
12+
// CHECK-NOT: __llvm_coverage_mapping
13+
14+
#![crate_type="lib"]
15+
16+
#[inline(never)]
17+
fn some_function() {
18+
19+
}
20+
21+
pub fn some_other_function() {
22+
some_function();
23+
}

tests/codegen/instrument-coverage.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
// Test that `-Cinstrument-coverage` creates expected __llvm_profile_filename symbol in LLVM IR.
22

33
// needs-profiler-support
4-
// compile-flags: -Cinstrument-coverage
4+
// revisions: default y yes on true all
5+
// [default] compile-flags: -Cinstrument-coverage
6+
// [y] compile-flags: -Cinstrument-coverage=y
7+
// [yes] compile-flags: -Cinstrument-coverage=yes
8+
// [on] compile-flags: -Cinstrument-coverage=on
9+
// [true] compile-flags: -Cinstrument-coverage=true
10+
// [all] compile-flags: -Cinstrument-coverage=all
511

612
// CHECK: @__llvm_profile_filename = {{.*}}"default_%m_%p.profraw\00"{{.*}}
13+
// CHECK: @__llvm_coverage_mapping
714

815
#![crate_type="lib"]
916

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: incorrect value `bad-value` for codegen option `instrument-coverage` - `all` (default), `except-unused-generics`, `except-unused-functions`, or `off` was expected
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: incorrect value `` for codegen option `instrument-coverage` - `all` (default), `except-unused-generics`, `except-unused-functions`, or `off` was expected
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// revisions: blank bad
2+
// [blank] compile-flags: -Cinstrument-coverage=
3+
// [bad] compile-flags: -Cinstrument-coverage=bad-value
4+
5+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// compile-flags: -Cinstrument-coverage=except-unused-functions
2+
3+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: `-C instrument-coverage=except-*` requires `-Z unstable-options`
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// compile-flags: -Cinstrument-coverage=except-unused-generics
2+
3+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: `-C instrument-coverage=except-*` requires `-Z unstable-options`
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// check-pass
2+
// revisions: n no off false zero
3+
// [n] compile-flags: -Cinstrument-coverage=n
4+
// [no] compile-flags: -Cinstrument-coverage=no
5+
// [off] compile-flags: -Cinstrument-coverage=off
6+
// [false] compile-flags: -Cinstrument-coverage=false
7+
// [zero] compile-flags: -Cinstrument-coverage=0
8+
9+
fn main() {}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// check-pass
2+
// needs-profiler-support
3+
// revisions: default y yes on true all
4+
// [default] compile-flags: -Cinstrument-coverage
5+
// [y] compile-flags: -Cinstrument-coverage=y
6+
// [yes] compile-flags: -Cinstrument-coverage=yes
7+
// [on] compile-flags: -Cinstrument-coverage=on
8+
// [true] compile-flags: -Cinstrument-coverage=true
9+
// [all] compile-flags: -Cinstrument-coverage=all
10+
11+
fn main() {}

0 commit comments

Comments
 (0)