File tree Expand file tree Collapse file tree 4 files changed +40
-0
lines changed Expand file tree Collapse file tree 4 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -52,3 +52,8 @@ harness = false
52
52
name = " cmsg"
53
53
path = " test/cmsg.rs"
54
54
harness = true
55
+
56
+ [[test ]]
57
+ name = " errqueue"
58
+ path = " test/errqueue.rs"
59
+ harness = true
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ fn do_cc() {
10
10
if cfg ! ( unix) && !target. contains ( "wasi" ) {
11
11
cc:: Build :: new ( ) . file ( "src/cmsg.c" ) . compile ( "cmsg" ) ;
12
12
}
13
+ if target. contains ( "android" ) || target. contains ( "linux" ) {
14
+ cc:: Build :: new ( ) . file ( "src/errqueue.c" ) . compile ( "errqueue" ) ;
15
+ }
13
16
}
14
17
15
18
fn do_ctest ( ) {
Original file line number Diff line number Diff line change
1
+ #include <time.h>
2
+ #include <linux/errqueue.h>
3
+
4
+ // SO_EE_OFFENDER is defined as a macro in linux/errqueue.h. This file wraps
5
+ // that macro in a function so we can test the reimplementation in this package
6
+ // is equivalent.
7
+
8
+ struct sockaddr * so_ee_offender (struct sock_extended_err * ee ) {
9
+ return SO_EE_OFFENDER (ee );
10
+ }
Original file line number Diff line number Diff line change
1
+ //! Compare libc's SO_EE_OFFENDER function against the actual C macro
2
+
3
+ extern crate libc;
4
+
5
+ #[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
6
+ mod t {
7
+ use libc:: { self , sock_extended_err, sockaddr} ;
8
+
9
+ extern "C" {
10
+ pub fn so_ee_offender ( ee : * const sock_extended_err ) -> * mut sockaddr ;
11
+ }
12
+
13
+ #[ test]
14
+ fn test_cmsg_data ( ) {
15
+ for l in 0 ..128 {
16
+ let ee = l as * const sock_extended_err ;
17
+ unsafe {
18
+ assert_eq ! ( libc:: SO_EE_OFFENDER ( ee) , so_ee_offender( ee) ) ;
19
+ }
20
+ }
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments