@@ -5,13 +5,13 @@ use qos_core::{
55 handles:: Handles ,
66 io:: { SocketAddress , StreamPool } ,
77 protocol:: services:: boot:: ManifestEnvelope ,
8- reaper:: { Reaper , REAPER_EXIT_DELAY_IN_SECONDS } ,
8+ reaper:: { Reaper , REAPER_EXIT_DELAY } ,
99} ;
1010use qos_nsm:: mock:: MockNsm ;
1111use qos_test_primitives:: PathWrapper ;
1212
13- #[ test]
14- fn reaper_works ( ) {
13+ #[ tokio :: test]
14+ async fn reaper_works ( ) {
1515 let secret_path: PathWrapper = "/tmp/reaper_works.secret" . into ( ) ;
1616 // let eph_path = "reaper_works.eph.key";
1717 let usock: PathWrapper = "/tmp/reaper_works.sock" . into ( ) ;
@@ -43,18 +43,19 @@ fn reaper_works() {
4343 let app_pool =
4444 StreamPool :: new ( SocketAddress :: new_unix ( "./never.sock" ) , 1 ) . unwrap ( ) ;
4545
46- let reaper_handle = std :: thread :: spawn ( move || {
46+ let reaper_handle = tokio :: spawn ( async move {
4747 Reaper :: execute (
4848 & handles,
4949 Box :: new ( MockNsm ) ,
5050 enclave_pool,
5151 app_pool,
5252 None ,
5353 )
54+ . await ;
5455 } ) ;
5556
5657 // Give the enclave server time to bind to the socket
57- std :: thread :: sleep ( std:: time:: Duration :: from_secs ( 1 ) ) ;
58+ tokio :: time :: sleep ( std:: time:: Duration :: from_secs ( 1 ) ) . await ;
5859
5960 // Check that the reaper is still running, presumably waiting for
6061 // the secret.
@@ -65,14 +66,14 @@ fn reaper_works() {
6566 fs:: write ( & * secret_path, b"super dank tank secret tech" ) . unwrap ( ) ;
6667
6768 // Make the sure the reaper executed successfully.
68- reaper_handle. join ( ) . unwrap ( ) ;
69+ reaper_handle. await . unwrap ( ) ;
6970 let contents = fs:: read ( integration:: PIVOT_OK_SUCCESS_FILE ) . unwrap ( ) ;
7071 assert_eq ! ( std:: str :: from_utf8( & contents) . unwrap( ) , msg) ;
7172 assert ! ( fs:: remove_file( integration:: PIVOT_OK_SUCCESS_FILE ) . is_ok( ) ) ;
7273}
7374
74- #[ test]
75- fn reaper_handles_non_zero_exits ( ) {
75+ #[ tokio :: test]
76+ async fn reaper_handles_non_zero_exits ( ) {
7677 let secret_path: PathWrapper =
7778 "/tmp/reaper_handles_non_zero_exits.secret" . into ( ) ;
7879 let usock: PathWrapper = "/tmp/reaper_handles_non_zero_exits.sock" . into ( ) ;
@@ -100,18 +101,19 @@ fn reaper_handles_non_zero_exits() {
100101 let app_pool =
101102 StreamPool :: new ( SocketAddress :: new_unix ( "./never.sock" ) , 1 ) . unwrap ( ) ;
102103
103- let reaper_handle = std :: thread :: spawn ( move || {
104+ let reaper_handle = tokio :: spawn ( async move {
104105 Reaper :: execute (
105106 & handles,
106107 Box :: new ( MockNsm ) ,
107108 enclave_pool,
108109 app_pool,
109110 None ,
110111 )
112+ . await ;
111113 } ) ;
112114
113115 // Give the enclave server time to bind to the socket
114- std :: thread :: sleep ( std:: time:: Duration :: from_secs ( 1 ) ) ;
116+ tokio :: time :: sleep ( std:: time:: Duration :: from_secs ( 1 ) ) . await ;
115117
116118 // Check that the reaper is still running, presumably waiting for
117119 // the secret.
@@ -123,15 +125,13 @@ fn reaper_handles_non_zero_exits() {
123125
124126 // Ensure the reaper has enough time to detect the secret, launch the
125127 // pivot, and let the pivot exit.
126- std:: thread:: sleep ( std:: time:: Duration :: from_secs (
127- REAPER_EXIT_DELAY_IN_SECONDS * 2 ,
128- ) ) ;
128+ tokio:: time:: sleep ( REAPER_EXIT_DELAY * 2 ) . await ;
129129
130130 assert ! ( reaper_handle. is_finished( ) ) ;
131131}
132132
133- #[ test]
134- fn reaper_handles_panic ( ) {
133+ #[ tokio :: test]
134+ async fn reaper_handles_panic ( ) {
135135 let secret_path: PathWrapper = "/tmp/reaper_handles_panics.secret" . into ( ) ;
136136 let usock: PathWrapper = "/tmp/reaper_handles_panics.sock" . into ( ) ;
137137 let manifest_path: PathWrapper =
@@ -158,18 +158,19 @@ fn reaper_handles_panic() {
158158 let app_pool =
159159 StreamPool :: new ( SocketAddress :: new_unix ( "./never.sock" ) , 1 ) . unwrap ( ) ;
160160
161- let reaper_handle = std :: thread :: spawn ( move || {
161+ let reaper_handle = tokio :: spawn ( async move {
162162 Reaper :: execute (
163163 & handles,
164164 Box :: new ( MockNsm ) ,
165165 enclave_pool,
166166 app_pool,
167167 None ,
168168 )
169+ . await ;
169170 } ) ;
170171
171172 // Give the enclave server time to bind to the socket
172- std :: thread :: sleep ( std:: time:: Duration :: from_secs ( 1 ) ) ;
173+ tokio :: time :: sleep ( std:: time:: Duration :: from_secs ( 1 ) ) . await ;
173174
174175 // Check that the reaper is still running, presumably waiting for
175176 // the secret.
@@ -181,9 +182,7 @@ fn reaper_handles_panic() {
181182
182183 // Ensure the reaper has enough time to detect the secret, launch the
183184 // pivot, and let the pivot exit.
184- std:: thread:: sleep ( std:: time:: Duration :: from_secs (
185- REAPER_EXIT_DELAY_IN_SECONDS * 2 ,
186- ) ) ;
185+ tokio:: time:: sleep ( REAPER_EXIT_DELAY * 2 ) . await ;
187186
188187 assert ! ( reaper_handle. is_finished( ) ) ;
189188}
0 commit comments