@@ -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