Skip to content

Commit 10ce1e0

Browse files
authored
Update the backends tests. (#1423)
The "use-libc-auxv" feature is no longer enabled by default, so convert the use-rustix-auxv test that disables it into a use-libc-auxv test that enables it, and add more asserts.
1 parent 7f40ac9 commit 10ce1e0

File tree

4 files changed

+45
-15
lines changed

4 files changed

+45
-15
lines changed

test-crates/use-libc-auxv/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "use-rustix-auxv"
3+
version = "0.0.0"
4+
edition = "2021"
5+
publish = false
6+
7+
[dependencies]
8+
# Request that rustix use the default backend, and enable use-libc-auxv.
9+
rustix = { path = "../..", features = ["use-libc-auxv"] }

test-crates/use-rustix-auxv/Cargo.toml

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/backends.rs

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,62 @@ fn test_backends() {
2020
),
2121
"use-default does not depend on linux-raw-sys"
2222
);
23+
assert!(
24+
!has_dependency("test-crates/use-default", &[], &[], &["RUSTFLAGS"], "libc"),
25+
"use-default depends on libc"
26+
);
27+
// If the libc backend is explicitly requested (by a cfg), check that
28+
// it's used.
29+
assert!(
30+
has_dependency(
31+
"test-crates/use-default",
32+
&[],
33+
&[("RUSTFLAGS", "--cfg=rustix_use_libc")],
34+
&[],
35+
"libc"
36+
),
37+
"use-default with `RUSTFLAGS=--cfg=use-libc` doesn't depend on libc"
38+
);
39+
// If the libc backend is explicitly requested (by a feature flag),
40+
// check that it's used.
41+
assert!(
42+
has_dependency(
43+
"test-crates/use-default",
44+
&["--features=rustix/use-libc"],
45+
&[],
46+
&[],
47+
"libc"
48+
),
49+
"use-default with `--features=use-libc` doesn't depend on libc"
50+
);
2351
}
2452

25-
// Pick an arbitrary platform where linux_raw is enabled by default and
26-
// ensure that the use-rustix-auxv crate uses it, and does not use libc.
53+
// Rustix's use-libc-auxv feature calls into libc, but does not use the
54+
// libc crate to do so. Pick an arbitrary platform where linux_raw is
55+
// enabled by default and ensure that the use-libc-auxv crate uses it,
56+
// and does not use the libc crate.
2757
#[cfg(all(target_os = "linux", target_arch = "aarch64"))]
2858
{
2959
assert!(
3060
!has_dependency(
31-
"test-crates/use-rustix-auxv",
61+
"test-crates/use-libc-auxv",
3262
&[],
3363
&[],
3464
&["RUSTFLAGS"],
3565
"libc"
3666
),
37-
"use-rustix-auxv depends on libc"
67+
"use-libc-auxv depends on libc"
3868
);
3969

4070
assert!(
4171
has_dependency(
42-
"test-crates/use-rustix-auxv",
72+
"test-crates/use-libc-auxv",
4373
&[],
4474
&[],
4575
&["RUSTFLAGS"],
4676
"linux-raw-sys"
4777
),
48-
"use-rustix-auxv does not depend on linux-raw-sys"
78+
"use-libc-auxv does not depend on linux-raw-sys"
4979
);
5080
}
5181

0 commit comments

Comments
 (0)