Skip to content

Commit c7162da

Browse files
authored
Rollup merge of #130156 - nebulark:test_buildinfo, r=jieyouxu
Add test for S_OBJNAME & update test for LF_BUILDINFO cl and cmd Update the unit test for checking cl and cmd in LF_BUILDINFO. With llvm-pdbutil we can now more specifically check if the string appears at the right location instead of just checking whether the string exists at all. Context: #96475
2 parents 65a5cd4 + 713828d commit c7162da

File tree

5 files changed

+36
-19
lines changed

5 files changed

+36
-19
lines changed

src/tools/run-make-support/src/external_deps/llvm.rs

+6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ pub fn llvm_dwarfdump() -> LlvmDwarfdump {
5454
LlvmDwarfdump::new()
5555
}
5656

57+
/// Construct a new `llvm-pdbutil` invocation. This assumes that `llvm-pdbutil` is available
58+
/// at `$LLVM_BIN_DIR/llvm-pdbutil`.
59+
pub fn llvm_pdbutil() -> LlvmPdbutil {
60+
LlvmPdbutil::new()
61+
}
62+
5763
/// A `llvm-readobj` invocation builder.
5864
#[derive(Debug)]
5965
#[must_use]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CHECK: LF_BUILDINFO
2+
CHECK: rustc.exe
3+
CHECK: main.rs
4+
CHECK: "-g" "--crate-name" "my_crate_name" "--crate-type" "bin" "-Cmetadata=dc9ef878b0a48666"

tests/run-make/pdb-buildinfo-cl-cmd/rmake.rs

+5-19
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//@ only-windows-msvc
88
// Reason: pdb files are unique to this architecture
99

10-
use run_make_support::{assert_contains, bstr, env_var, rfs, rustc};
10+
use run_make_support::{llvm, rustc};
1111

1212
fn main() {
1313
rustc()
@@ -17,23 +17,9 @@ fn main() {
1717
.crate_type("bin")
1818
.metadata("dc9ef878b0a48666")
1919
.run();
20-
let tests = [
21-
&env_var("RUSTC"),
22-
r#""main.rs""#,
23-
r#""-g""#,
24-
r#""--crate-name""#,
25-
r#""my_crate_name""#,
26-
r#""--crate-type""#,
27-
r#""bin""#,
28-
r#""-Cmetadata=dc9ef878b0a48666""#,
29-
];
30-
for test in tests {
31-
assert_pdb_contains(test);
32-
}
33-
}
3420

35-
fn assert_pdb_contains(needle: &str) {
36-
let needle = needle.as_bytes();
37-
use bstr::ByteSlice;
38-
assert!(&rfs::read("my_crate_name.pdb").find(needle).is_some());
21+
let pdbutil_result =
22+
llvm::llvm_pdbutil().arg("dump").arg("-ids").input("my_crate_name.pdb").run();
23+
24+
llvm::llvm_filecheck().patterns("filecheck.txt").stdin_buf(pdbutil_result.stdout_utf8()).run();
3925
}

tests/run-make/pdb-sobjname/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fn main() {}

tests/run-make/pdb-sobjname/rmake.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Check if the pdb file contains an S_OBJNAME entry with the name of the .o file
2+
3+
// This is because it used to be missing in #96475.
4+
// See https://github.com./rust-lang/rust/pull/115704
5+
6+
//@ only-windows-msvc
7+
// Reason: pdb files are unique to this architecture
8+
9+
use run_make_support::{llvm, rustc};
10+
11+
fn main() {
12+
rustc().input("main.rs").arg("-g").crate_name("my_great_crate_name").crate_type("bin").run();
13+
14+
let pdbutil_result = llvm::llvm_pdbutil()
15+
.arg("dump")
16+
.arg("-symbols")
17+
.input("my_great_crate_name.pdb")
18+
.run()
19+
.assert_stdout_contains_regex("S_OBJNAME.+my_great_crate_name.*\\.o");
20+
}

0 commit comments

Comments
 (0)