Skip to content

Commit a35a318

Browse files
authored
Merge pull request #206 from rust-secure-code/stripped-binary-test
Add test for stripped binary
2 parents c657855 + 9f14a09 commit a35a318

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "lto_stripped_binary"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
10+
[workspace]
11+
12+
[profile.release]
13+
lto=true
14+
strip=true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("Hello, world!");
3+
}

cargo-auditable/tests/it.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,26 @@ fn test_lto() {
269269
.any(|p| p.name == "lto_binary_crate"));
270270
}
271271

272+
#[test]
273+
fn test_lto_stripped() {
274+
// Path to workspace fixture Cargo.toml. See that file for overview of workspace members and their dependencies.
275+
let workspace_cargo_toml = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
276+
.join("tests/fixtures/lto_stripped_binary/Cargo.toml");
277+
// Run in workspace root with default features
278+
let bins = run_cargo_auditable(workspace_cargo_toml, &[], &[]);
279+
eprintln!("Stripped binary map: {bins:?}");
280+
281+
// lto_stripped_binary should only depend on itself
282+
let lto_stripped_binary_bin = &bins.get("lto_stripped_binary").unwrap()[0];
283+
let dep_info = get_dependency_info(lto_stripped_binary_bin);
284+
eprintln!("{lto_stripped_binary_bin} dependency info: {dep_info:?}");
285+
assert!(dep_info.packages.len() == 1);
286+
assert!(dep_info
287+
.packages
288+
.iter()
289+
.any(|p| p.name == "lto_stripped_binary"));
290+
}
291+
272292
#[test]
273293
fn test_bin_and_lib_in_one_crate() {
274294
// Path to workspace fixture Cargo.toml. See that file for overview of workspace members and their dependencies.

0 commit comments

Comments
 (0)