11mod config;
22
3+ use cfg_if:: cfg_if;
34use config:: { hw_config, HardwareConfig } ;
4- use nix:: fcntl:: FlockArg ;
5- use nix:: ioctl_none_bad;
65use rstest:: rstest;
7- use serialport:: ErrorKind ;
8- use std:: fs:: File ;
9- use std:: os:: fd:: AsRawFd ;
106
11- // Locally create a wrapper for the TIOCEXCL ioctl.
12- ioctl_none_bad ! ( tiocexcl, libc:: TIOCEXCL ) ;
7+ cfg_if ! {
8+ if #[ cfg( unix) ] {
9+ use std:: os:: unix:: prelude:: * ;
10+ use nix:: fcntl:: FlockArg ;
11+ use nix:: ioctl_none_bad;
12+ use serialport:: ErrorKind ;
13+ use std:: fs:: File ;
14+
15+ // Locally create a wrapper for the TIOCEXCL ioctl.
16+ ioctl_none_bad!( tiocexcl, libc:: TIOCEXCL ) ;
17+ }
18+ }
1319
1420#[ rstest]
1521#[ cfg_attr( not( feature = "hardware-tests" ) , ignore) ]
@@ -23,7 +29,8 @@ fn opening_multiple_times(hw_config: HardwareConfig) {
2329}
2430
2531#[ rstest]
26- #[ cfg_attr( not( all( unix, feature = "hardware-tests" ) ) , ignore) ]
32+ #[ cfg( unix) ]
33+ #[ cfg_attr( not( feature = "hardware-tests" ) , ignore) ]
2734fn second_open_fails_open ( hw_config : HardwareConfig ) {
2835 // Open the port for the first time with serialport. This is expected to put some locking in
2936 // place by default.
@@ -36,7 +43,8 @@ fn second_open_fails_open(hw_config: HardwareConfig) {
3643}
3744
3845#[ rstest]
39- #[ cfg_attr( not( all( unix, feature = "hardware-tests" ) ) , ignore) ]
46+ #[ cfg( unix) ]
47+ #[ cfg_attr( not( feature = "hardware-tests" ) , ignore) ]
4048fn second_open_fails_flock ( hw_config : HardwareConfig ) {
4149 // Open the port for the first time and apply an exclusive flock.
4250 let first = File :: open ( & hw_config. port_1 ) . unwrap ( ) ;
@@ -50,7 +58,8 @@ fn second_open_fails_flock(hw_config: HardwareConfig) {
5058}
5159
5260#[ rstest]
53- #[ cfg_attr( not( all( unix, feature = "hardware-tests" ) ) , ignore) ]
61+ #[ cfg( unix) ]
62+ #[ cfg_attr( not( feature = "hardware-tests" ) , ignore) ]
5463fn second_open_fails_lock ( hw_config : HardwareConfig ) {
5564 // Open the port for the first time and lock it exclusively with Rust's default file locking
5665 // mechanism which is expected to be flock.
@@ -64,7 +73,8 @@ fn second_open_fails_lock(hw_config: HardwareConfig) {
6473}
6574
6675#[ rstest]
67- #[ cfg_attr( not( all( unix, feature = "hardware-tests" ) ) , ignore) ]
76+ #[ cfg( unix) ]
77+ #[ cfg_attr( not( feature = "hardware-tests" ) , ignore) ]
6878fn second_open_fails_tiocexcl ( hw_config : HardwareConfig ) {
6979 // Open the port for the first time and apply locking via TIOCEXL. This is one of the locking
7080 // mechanisms used by TTYPort.
0 commit comments