@@ -136,6 +136,19 @@ static void example_cv_wait (testing t) {
136136 static const char * input [] = { "one" , "two" , "three" , "four" , "five" };
137137 string_priority_queue_cv q ;
138138 a_char output ;
139+ #ifdef NSYNC_TESTING_SLOW_MACHINE
140+ static const uint waiting_factor = 5 ;
141+ static const char * expected =
142+ "one\n"
143+ "three\n"
144+ "two\n"
145+ "timeout 0.5s\n"
146+ "four\n"
147+ "timeout 0.5s\n"
148+ "five\n"
149+ "timeout 5s\n" ;
150+ #else
151+ static const uint waiting_factor = 1 ;
139152 static const char * expected =
140153 "one\n"
141154 "three\n"
@@ -145,24 +158,25 @@ static void example_cv_wait (testing t) {
145158 "timeout 0.1s\n"
146159 "five\n"
147160 "timeout 1s\n" ;
161+ #endif
148162
149163 memset ((void * ) & q , 0 , sizeof (q ));
150164 memset (& output , 0 , sizeof (output ));
151165
152166 closure_fork (closure_add_and_wait_cv (& add_and_wait_cv , & q ,
153- nsync_time_ms (500 ), NELEM (input ), input ));
167+ nsync_time_ms (waiting_factor * 500 ), NELEM (input ), input ));
154168
155169 /* delay: "one", "two", "three" are queued; not "four" */
156- nsync_time_sleep (nsync_time_ms (1200 ));
157-
158- remove_and_print_cv (& q , nsync_time_ms (1000 ), & output ); /* "one" */
159- remove_and_print_cv (& q , nsync_time_ms (1000 ), & output ); /* "three" (less than "two") */
160- remove_and_print_cv (& q , nsync_time_ms (1000 ), & output ); /* "two" */
161- remove_and_print_cv (& q , nsync_time_ms (100 ), & output ); /* time out because 1.3 < 0.5*3 */
162- remove_and_print_cv (& q , nsync_time_ms (1000 ), & output ); /* "four" */
163- remove_and_print_cv (& q , nsync_time_ms (100 ), & output ); /* time out because 0.1 < 0.5 */
164- remove_and_print_cv (& q , nsync_time_ms (1000 ), & output ); /* "five" */
165- remove_and_print_cv (& q , nsync_time_ms (1000 ), & output ); /* time out: no more to fetch */
170+ nsync_time_sleep (nsync_time_ms (waiting_factor * 1200 ));
171+
172+ remove_and_print_cv (& q , nsync_time_ms (waiting_factor * 1000 ), & output ); /* "one" */
173+ remove_and_print_cv (& q , nsync_time_ms (waiting_factor * 1000 ), & output ); /* "three" (less than "two") */
174+ remove_and_print_cv (& q , nsync_time_ms (waiting_factor * 1000 ), & output ); /* "two" */
175+ remove_and_print_cv (& q , nsync_time_ms (waiting_factor * 100 ), & output ); /* time out because 1.3 < 0.5*3 */
176+ remove_and_print_cv (& q , nsync_time_ms (waiting_factor * 1000 ), & output ); /* "four" */
177+ remove_and_print_cv (& q , nsync_time_ms (waiting_factor * 100 ), & output ); /* time out because 0.1 < 0.5 */
178+ remove_and_print_cv (& q , nsync_time_ms (waiting_factor * 1000 ), & output ); /* "five" */
179+ remove_and_print_cv (& q , nsync_time_ms (waiting_factor * 1000 ), & output ); /* time out: no more to fetch */
166180
167181 A_PUSH (& output ) = 0 ;
168182 if (strcmp (& A (& output , 0 ), expected ) != 0 ) {
0 commit comments