]> git.lizzy.rs Git - rust.git/blobdiff - src/libstd/sys/sgx/waitqueue.rs
SGX target: fix std unit tests
[rust.git] / src / libstd / sys / sgx / waitqueue.rs
index 1dbf2afbf4987e7b47368d7ecca303b69200922f..3f5e03ddad69eee59068aa76735f8a98ba1cc1a0 100644 (file)
@@ -498,6 +498,7 @@ mod tests {
         use super::*;
         use crate::sync::Arc;
         use crate::thread;
+        use crate::time::{SystemTime, Duration};
 
         #[test]
         fn sleep() {
@@ -507,7 +508,13 @@ fn sleep() {
             let t1 = thread::spawn(move || {
                 *mutex2.lock() = 1;
             });
-            thread::sleep_ms(50);
+
+            // "sleep" for 50ms
+            // FIXME: https://github.com/fortanix/rust-sgx/issues/31
+            let start = SystemTime::now();
+            let max = Duration::from_millis(50);
+            while start.elapsed().unwrap() < max {}
+
             assert_eq!(*guard, 0);
             drop(guard);
             t1.join().unwrap();
@@ -530,7 +537,8 @@ fn queue() {
         let locked = wq.lock();
 
         let t1 = thread::spawn(move || {
-            assert!(WaitQueue::notify_one(wq2.lock()).is_none())
+            // if we obtain the lock, the main thread should be waiting
+            assert!(WaitQueue::notify_one(wq2.lock()).is_ok());
         });
 
         WaitQueue::wait(locked);