mirror of
https://github.com/openharmony/third_party_rust_libc.git
synced 2026-07-22 02:45:21 -04:00
a13489d1f6
Modelled after the cmsg tests, this wraps the C macro into a function, and then compares the results to the Rust implementation in libc.
23 lines
552 B
Rust
23 lines
552 B
Rust
//! Compare libc's SO_EE_OFFENDER function against the actual C macro
|
|
|
|
extern crate libc;
|
|
|
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
|
mod t {
|
|
use libc::{self, sock_extended_err, sockaddr};
|
|
|
|
extern "C" {
|
|
pub fn so_ee_offender(ee: *const sock_extended_err) -> *mut sockaddr;
|
|
}
|
|
|
|
#[test]
|
|
fn test_cmsg_data() {
|
|
for l in 0..128 {
|
|
let ee = l as *const sock_extended_err;
|
|
unsafe {
|
|
assert_eq!(libc::SO_EE_OFFENDER(ee), so_ee_offender(ee));
|
|
}
|
|
}
|
|
}
|
|
}
|