5
5
6
6
extern crate libc;
7
7
8
- #[ cfg( target_os = "linux" ) ]
8
+ #[ cfg( target_os = "linux, freebsd " ) ]
9
9
fn tmp ( ) -> std:: path:: PathBuf {
10
10
std:: env:: var ( "MIRI_TEMP" ) . map ( std:: path:: PathBuf :: from) . unwrap_or_else ( |_| std:: env:: temp_dir ( ) )
11
11
}
12
12
13
- #[ cfg( target_os = "linux" ) ]
13
+ #[ cfg( target_os = "linux, freebsd " ) ]
14
14
fn test_posix_fadvise ( ) {
15
15
use std:: convert:: TryInto ;
16
16
use std:: fs:: { remove_file, File } ;
@@ -40,7 +40,7 @@ fn test_posix_fadvise() {
40
40
assert_eq ! ( result, 0 ) ;
41
41
}
42
42
43
- #[ cfg( target_os = "linux" ) ]
43
+ #[ cfg( target_os = "linux, freebsd " ) ]
44
44
fn test_sync_file_range ( ) {
45
45
use std:: fs:: { remove_file, File } ;
46
46
use std:: io:: Write ;
@@ -191,7 +191,7 @@ fn test_rwlock_libc_static_initializer() {
191
191
/// Test whether the `prctl` shim correctly sets the thread name.
192
192
///
193
193
/// Note: `prctl` exists only on Linux.
194
- #[ cfg( target_os = "linux" ) ]
194
+ #[ cfg( target_os = "linux,freebsd " ) ]
195
195
fn test_prctl_thread_name ( ) {
196
196
use std:: ffi:: CString ;
197
197
use libc:: c_long;
@@ -231,7 +231,7 @@ fn test_thread_local_errno() {
231
231
}
232
232
233
233
/// Tests whether clock support exists at all
234
- #[ cfg( target_os = "linux" ) ]
234
+ #[ cfg( target_os = "linux,freebsd " ) ]
235
235
fn test_clocks ( ) {
236
236
let mut tp = std:: mem:: MaybeUninit :: < libc:: timespec > :: uninit ( ) ;
237
237
let is_error = unsafe {
@@ -252,26 +252,33 @@ fn test_clocks() {
252
252
assert_eq ! ( is_error, 0 ) ;
253
253
}
254
254
255
+ #[ cfg( target_os = "linux,freebsd,macos" ) ]
256
+ fn test_getpid ( ) {
257
+ unsafe {
258
+ assert_eq ! ( libc:: getpid( ) , std:: process:: id( ) ) ;
259
+ }
260
+ }
261
+
255
262
fn main ( ) {
256
- #[ cfg( target_os = "linux" ) ]
263
+ #[ cfg( target_os = "linux,freebsd " ) ]
257
264
test_posix_fadvise ( ) ;
258
265
259
- #[ cfg( target_os = "linux" ) ]
266
+ #[ cfg( target_os = "linux,freebsd " ) ]
260
267
test_sync_file_range ( ) ;
261
268
262
269
test_mutex_libc_init_recursive ( ) ;
263
270
test_mutex_libc_init_normal ( ) ;
264
271
test_mutex_libc_init_errorcheck ( ) ;
265
272
test_rwlock_libc_static_initializer ( ) ;
266
273
267
- #[ cfg( target_os = "linux" ) ]
274
+ #[ cfg( target_os = "linux,freebsd " ) ]
268
275
test_mutex_libc_static_initializer_recursive ( ) ;
269
276
270
- #[ cfg( target_os = "linux" ) ]
277
+ #[ cfg( target_os = "linux,freebsd " ) ]
271
278
test_prctl_thread_name ( ) ;
272
279
273
280
test_thread_local_errno ( ) ;
274
281
275
- #[ cfg( target_os = "linux" ) ]
282
+ #[ cfg( target_os = "linux,freebsd " ) ]
276
283
test_clocks ( ) ;
277
284
}
0 commit comments