| 149 | #[cfg(feature = "std")] |
| 150 | #[test] |
| 151 | fn test_wait_timeout() { |
| 152 | use rustix::thread::futex::Timespec; |
| 153 | |
| 154 | let lock = AtomicU32::new(0); |
| 155 | |
| 156 | let err = futex::wait( |
| 157 | &lock, |
| 158 | futex::Flags::empty(), |
| 159 | 0, |
| 160 | Some(&Timespec { |
| 161 | tv_sec: 1, |
| 162 | tv_nsec: 13, |
| 163 | }), |
| 164 | ) |
| 165 | .unwrap_err(); |
| 166 | assert_eq!(err, Errno::TIMEDOUT); |
| 167 | |
| 168 | let err = futex::wait( |
| 169 | &lock, |
| 170 | futex::Flags::empty(), |
| 171 | 0, |
| 172 | Some(&Timespec { |
| 173 | tv_sec: 0, |
| 174 | tv_nsec: 1_000_000_000, |
| 175 | }), |
| 176 | ) |
| 177 | .unwrap_err(); |
| 178 | assert_eq!(err, Errno::INVAL); |
| 179 | |
| 180 | let err = futex::wait( |
| 181 | &lock, |
| 182 | futex::Flags::empty(), |
| 183 | 0, |
| 184 | Some(&Timespec { |
| 185 | tv_sec: -1, |
| 186 | tv_nsec: 0, |
| 187 | }), |
| 188 | ) |
| 189 | .unwrap_err(); |
| 190 | assert_eq!(err, Errno::INVAL); |
| 191 | } |
| 192 | |
| 193 | // Same as `test_wait_timeout` but using `waitv`. |
| 194 | #[cfg(feature = "std")] |