@@ -85,7 +85,9 @@ fn ctest_cfg() -> ctest::TestGenerator {
85
85
}
86
86
87
87
fn ctest_next_cfg ( ) -> ctest_next:: TestGenerator {
88
- ctest_next:: TestGenerator :: new ( )
88
+ let mut cfg = ctest_next:: TestGenerator :: new ( ) ;
89
+ cfg. skip_private ( true ) ;
90
+ cfg
89
91
}
90
92
91
93
fn do_semver ( ) {
@@ -2397,7 +2399,7 @@ fn test_android(target: &str) {
2397
2399
2398
2400
fn test_freebsd ( target : & str ) {
2399
2401
assert ! ( target. contains( "freebsd" ) ) ;
2400
- let mut cfg = ctest_cfg ( ) ;
2402
+ let mut cfg = ctest_next_cfg ( ) ;
2401
2403
2402
2404
let freebsd_ver = which_freebsd ( ) ;
2403
2405
@@ -2539,7 +2541,13 @@ fn test_freebsd(target: &str) {
2539
2541
"wchar.h" ,
2540
2542
}
2541
2543
2542
- cfg. type_name ( move |ty, is_struct, is_union| {
2544
+ cfg. rename_type ( |ty| match ty {
2545
+ // FIXME(freebsd): https://github.com/rust-lang/libc/issues/1273
2546
+ "sighandler_t" => Some ( "sig_t" . to_string ( ) ) ,
2547
+ _ => None ,
2548
+ } ) ;
2549
+
2550
+ cfg. rename_struct_ty ( |ty| {
2543
2551
match ty {
2544
2552
// Just pass all these through, no need for a "struct" prefix
2545
2553
"FILE"
@@ -2554,27 +2562,20 @@ fn test_freebsd(target: &str) {
2554
2562
| "devstat_support_flags"
2555
2563
| "devstat_type_flags"
2556
2564
| "devstat_match_flags"
2557
- | "devstat_priority" => ty. to_string ( ) ,
2558
-
2559
- // FIXME(freebsd): https://github.com/rust-lang/libc/issues/1273
2560
- "sighandler_t" => "sig_t" . to_string ( ) ,
2561
-
2562
- t if is_union => format ! ( "union {t}" ) ,
2563
-
2564
- t if t. ends_with ( "_t" ) => t. to_string ( ) ,
2565
+ | "devstat_priority" => Some ( ty. to_string ( ) ) ,
2565
2566
2566
2567
// sigval is a struct in Rust, but a union in C:
2567
- "sigval" => "union sigval" . to_string ( ) ,
2568
+ "sigval" => Some ( "union sigval" . to_string ( ) ) ,
2568
2569
2569
- // put `struct` in front of all structs:.
2570
- t if is_struct => format ! ( "struct {t}" ) ,
2570
+ t if t. ends_with ( "_t" ) => Some ( t. to_string ( ) ) ,
2571
2571
2572
- t => t . to_string ( ) ,
2572
+ _ => None ,
2573
2573
}
2574
2574
} ) ;
2575
2575
2576
- cfg. field_name ( move |struct_, field| {
2577
- match field {
2576
+ cfg. rename_struct_field ( |struct_, field_| {
2577
+ let struct_ = struct_. ident ( ) ;
2578
+ let replacement = match field_. ident ( ) {
2578
2579
// Our stat *_nsec fields normally don't actually exist but are part
2579
2580
// of a timeval struct
2580
2581
s if s. ends_with ( "_nsec" ) && struct_. starts_with ( "stat" ) => {
@@ -2588,12 +2589,13 @@ fn test_freebsd(target: &str) {
2588
2589
"type_" if struct_ == "input_event" => "type" . to_string ( ) ,
2589
2590
// Field is named `gennum` in Rust because `gen` is a keyword
2590
2591
"gennum" if struct_ == "xktls_session_onedir" => "gen" . to_string ( ) ,
2591
- s => s. to_string ( ) ,
2592
- }
2592
+ _ => return None ,
2593
+ } ;
2594
+ Some ( replacement)
2593
2595
} ) ;
2594
2596
2595
- cfg. skip_const ( move |name | {
2596
- match name {
2597
+ cfg. skip_const ( move |constant | {
2598
+ match constant . ident ( ) {
2597
2599
// These constants were introduced in FreeBSD 13:
2598
2600
"F_ADD_SEALS" | "F_GET_SEALS" | "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW"
2599
2601
| "F_SEAL_WRITE"
@@ -2873,8 +2875,8 @@ fn test_freebsd(target: &str) {
2873
2875
}
2874
2876
} ) ;
2875
2877
2876
- cfg. skip_type ( move |ty| {
2877
- match ty {
2878
+ cfg. skip_alias ( move |ty| {
2879
+ match ty. ident ( ) {
2878
2880
// the struct "__kvm" is quite tricky to bind so since we only use a pointer to it
2879
2881
// for now, it doesn't matter too much...
2880
2882
"kvm_t" => true ,
@@ -2885,7 +2887,9 @@ fn test_freebsd(target: &str) {
2885
2887
}
2886
2888
} ) ;
2887
2889
2888
- cfg. skip_struct ( move |ty| {
2890
+ cfg. skip_union ( |u| u. ident ( ) . starts_with ( "__c_anonymous_" ) ) ;
2891
+ cfg. skip_struct ( move |struct_| {
2892
+ let ty = struct_. ident ( ) ;
2889
2893
if ty. starts_with ( "__c_anonymous_" ) {
2890
2894
return true ;
2891
2895
}
@@ -2930,9 +2934,9 @@ fn test_freebsd(target: &str) {
2930
2934
}
2931
2935
} ) ;
2932
2936
2933
- cfg. skip_fn ( move |name | {
2937
+ cfg. skip_fn ( move |func | {
2934
2938
// skip those that are manually verified
2935
- match name {
2939
+ match func . ident ( ) {
2936
2940
// FIXME: https://github.com/rust-lang/libc/issues/1272
2937
2941
// Also, `execvpe` is introduced in FreeBSD 14.1
2938
2942
"execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true ,
@@ -2993,18 +2997,12 @@ fn test_freebsd(target: &str) {
2993
2997
}
2994
2998
} ) ;
2995
2999
2996
- cfg. volatile_item ( |i| {
2997
- use ctest:: VolatileItemKind :: * ;
2998
- match i {
2999
- // aio_buf is a volatile void** but since we cannot express that in
3000
- // Rust types, we have to explicitly tell the checker about it here:
3001
- StructField ( ref n, ref f) if n == "aiocb" && f == "aio_buf" => true ,
3002
- _ => false ,
3003
- }
3004
- } ) ;
3000
+ // aio_buf is a volatile void* but since we cannot express that in
3001
+ // Rust types, we have to explicitly tell the checker about it here:
3002
+ cfg. volatile_struct_field ( |s, f| s. ident ( ) == "aiocb" && f. ident ( ) == "aio_buf" ) ;
3005
3003
3006
- cfg. skip_field ( move |struct_, field| {
3007
- match ( struct_, field) {
3004
+ cfg. skip_struct_field ( move |struct_, field| {
3005
+ match ( struct_. ident ( ) , field. ident ( ) ) {
3008
3006
// FIXME(freebsd): `sa_sigaction` has type `sighandler_t` but that type is
3009
3007
// incorrect, see: https://github.com/rust-lang/libc/issues/1359
3010
3008
( "sigaction" , "sa_sigaction" ) => true ,
@@ -3079,7 +3077,10 @@ fn test_freebsd(target: &str) {
3079
3077
} ) ;
3080
3078
}
3081
3079
3082
- cfg. generate ( src_hotfix_dir ( ) . join ( "lib.rs" ) , "ctest_output.rs" ) ;
3080
+ // FIXME(ctest): The original ctest bypassed this requirement somehow.
3081
+ cfg. rename_type ( move |ty| ( ty == "dot3Vendors" ) . then_some ( format ! ( "enum {ty}" ) ) ) ;
3082
+
3083
+ ctest_next:: generate_test ( & mut cfg, "../src/lib.rs" , "ctest_output.rs" ) . unwrap ( ) ;
3083
3084
}
3084
3085
3085
3086
fn test_emscripten ( target : & str ) {
0 commit comments