@@ -78,7 +78,9 @@ fn ctest_cfg() -> ctest::TestGenerator {
78
78
}
79
79
80
80
fn ctest_next_cfg ( ) -> ctest_next:: TestGenerator {
81
- ctest_next:: TestGenerator :: new ( )
81
+ let mut cfg = ctest_next:: TestGenerator :: new ( ) ;
82
+ cfg. skip_private ( true ) ;
83
+ cfg
82
84
}
83
85
84
86
fn do_semver ( ) {
@@ -2286,7 +2288,7 @@ fn test_android(target: &str) {
2286
2288
2287
2289
fn test_freebsd ( target : & str ) {
2288
2290
assert ! ( target. contains( "freebsd" ) ) ;
2289
- let mut cfg = ctest_cfg ( ) ;
2291
+ let mut cfg = ctest_next_cfg ( ) ;
2290
2292
2291
2293
let freebsd_ver = which_freebsd ( ) ;
2292
2294
@@ -2428,7 +2430,13 @@ fn test_freebsd(target: &str) {
2428
2430
"wchar.h" ,
2429
2431
}
2430
2432
2431
- cfg. type_name ( move |ty, is_struct, is_union| {
2433
+ cfg. rename_type ( |ty| match ty {
2434
+ // FIXME(freebsd): https://github.com/rust-lang/libc/issues/1273
2435
+ "sighandler_t" => Some ( "sig_t" . to_string ( ) ) ,
2436
+ _ => None ,
2437
+ } ) ;
2438
+
2439
+ cfg. rename_struct_ty ( |ty| {
2432
2440
match ty {
2433
2441
// Just pass all these through, no need for a "struct" prefix
2434
2442
"FILE"
@@ -2443,24 +2451,16 @@ fn test_freebsd(target: &str) {
2443
2451
| "devstat_support_flags"
2444
2452
| "devstat_type_flags"
2445
2453
| "devstat_match_flags"
2446
- | "devstat_priority" => ty. to_string ( ) ,
2447
-
2448
- // FIXME(freebsd): https://github.com/rust-lang/libc/issues/1273
2449
- "sighandler_t" => "sig_t" . to_string ( ) ,
2450
-
2451
- t if is_union => format ! ( "union {t}" ) ,
2454
+ | "devstat_priority" => Some ( ty. to_string ( ) ) ,
2452
2455
2453
- t if t. ends_with ( "_t" ) => t. to_string ( ) ,
2454
-
2455
- // put `struct` in front of all structs:.
2456
- t if is_struct => format ! ( "struct {t}" ) ,
2457
-
2458
- t => t. to_string ( ) ,
2456
+ t if t. ends_with ( "_t" ) => Some ( t. to_string ( ) ) ,
2457
+ _ => None ,
2459
2458
}
2460
2459
} ) ;
2461
2460
2462
- cfg. field_name ( move |struct_, field| {
2463
- match field {
2461
+ cfg. rename_struct_field ( |struct_, field_| {
2462
+ let struct_ = struct_. ident ( ) ;
2463
+ let replacement = match field_. ident ( ) {
2464
2464
// Our stat *_nsec fields normally don't actually exist but are part
2465
2465
// of a timeval struct
2466
2466
s if s. ends_with ( "_nsec" ) && struct_. starts_with ( "stat" ) => {
@@ -2474,12 +2474,13 @@ fn test_freebsd(target: &str) {
2474
2474
"type_" if struct_ == "input_event" => "type" . to_string ( ) ,
2475
2475
// Field is named `gennum` in Rust because `gen` is a keyword
2476
2476
"gennum" if struct_ == "xktls_session_onedir" => "gen" . to_string ( ) ,
2477
- s => s. to_string ( ) ,
2478
- }
2477
+ _ => return None ,
2478
+ } ;
2479
+ Some ( replacement)
2479
2480
} ) ;
2480
2481
2481
- cfg. skip_const ( move |name | {
2482
- match name {
2482
+ cfg. skip_const ( move |constant | {
2483
+ match constant . ident ( ) {
2483
2484
// These constants were introduced in FreeBSD 13:
2484
2485
"F_ADD_SEALS" | "F_GET_SEALS" | "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW"
2485
2486
| "F_SEAL_WRITE"
@@ -2745,8 +2746,8 @@ fn test_freebsd(target: &str) {
2745
2746
}
2746
2747
} ) ;
2747
2748
2748
- cfg. skip_type ( move |ty| {
2749
- match ty {
2749
+ cfg. skip_alias ( move |ty| {
2750
+ match ty. ident ( ) {
2750
2751
// the struct "__kvm" is quite tricky to bind so since we only use a pointer to it
2751
2752
// for now, it doesn't matter too much...
2752
2753
"kvm_t" => true ,
@@ -2757,7 +2758,9 @@ fn test_freebsd(target: &str) {
2757
2758
}
2758
2759
} ) ;
2759
2760
2760
- cfg. skip_struct ( move |ty| {
2761
+ cfg. skip_union ( |u| u. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
2762
+ cfg. skip_struct ( move |struct_| {
2763
+ let ty = struct_. ident ( ) ;
2761
2764
if ty. starts_with ( "__c_anonymous_" ) {
2762
2765
return true ;
2763
2766
}
@@ -2802,9 +2805,9 @@ fn test_freebsd(target: &str) {
2802
2805
}
2803
2806
} ) ;
2804
2807
2805
- cfg. skip_fn ( move |name | {
2808
+ cfg. skip_fn ( move |func | {
2806
2809
// skip those that are manually verified
2807
- match name {
2810
+ match func . ident ( ) {
2808
2811
// This is introduced in FreeBSD 14.1
2809
2812
"execvpe" => true ,
2810
2813
@@ -2864,18 +2867,12 @@ fn test_freebsd(target: &str) {
2864
2867
}
2865
2868
} ) ;
2866
2869
2867
- cfg. volatile_item ( |i| {
2868
- use ctest:: VolatileItemKind :: * ;
2869
- match i {
2870
- // aio_buf is a volatile void* but since we cannot express that in
2871
- // Rust types, we have to explicitly tell the checker about it here:
2872
- StructField ( ref n, ref f) if n == "aiocb" && f == "aio_buf" => true ,
2873
- _ => false ,
2874
- }
2875
- } ) ;
2870
+ // aio_buf is a volatile void* but since we cannot express that in
2871
+ // Rust types, we have to explicitly tell the checker about it here:
2872
+ cfg. volatile_struct_field ( |s, f| s. ident ( ) == "aiocb" && f. ident ( ) == "aio_buf" ) ;
2876
2873
2877
- cfg. skip_field ( move |struct_, field| {
2878
- match ( struct_, field) {
2874
+ cfg. skip_struct_field ( move |struct_, field| {
2875
+ match ( struct_. ident ( ) , field. ident ( ) ) {
2879
2876
// FIXME(freebsd): `sa_sigaction` has type `sighandler_t` but that type is
2880
2877
// incorrect, see: https://github.com/rust-lang/libc/issues/1359
2881
2878
( "sigaction" , "sa_sigaction" ) => true ,
@@ -2947,7 +2944,10 @@ fn test_freebsd(target: &str) {
2947
2944
} ) ;
2948
2945
}
2949
2946
2950
- cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "ctest_output.rs" ) ;
2947
+ // FIXME(ctest): The original ctest bypassed this requirement somehow.
2948
+ cfg. rename_type ( move |ty| ( ty == "dot3Vendors" ) . then_some ( format ! ( "enum {ty}" ) ) ) ;
2949
+
2950
+ ctest_next:: generate_test ( & mut cfg, "../src/lib.rs" , "ctest_output.rs" ) . unwrap ( ) ;
2951
2951
}
2952
2952
2953
2953
fn test_emscripten ( target : & str ) {
0 commit comments