1
by brian
clean slate |
1 |
# include/wait_condition.inc |
2 |
#
|
|
3 |
# SUMMARY |
|
4 |
#
|
|
5 |
# Waits until the passed statement returns true, or the operation |
|
6 |
# times out. |
|
7 |
#
|
|
8 |
# USAGE |
|
9 |
#
|
|
10 |
# let $wait_condition= |
|
11 |
# SELECT c = 3 FROM t; |
|
12 |
# --source include/wait_condition.inc |
|
13 |
#
|
|
14 |
# OR |
|
15 |
#
|
|
16 |
# let $wait_timeout= 60; # Override default 30 seconds with 60. |
|
17 |
# let $wait_condition= |
|
18 |
# SELECT c = 3 FROM t; |
|
19 |
# --source include/wait_condition.inc |
|
20 |
# --echo Executed the test condition $wait_condition_reps times |
|
21 |
#
|
|
22 |
# EXAMPLE |
|
23 |
# events_bugs.test, events_time_zone.test |
|
24 |
#
|
|
25 |
||
26 |
--disable_query_log |
|
27 |
||
28 |
let $wait_counter= 300; |
|
29 |
if ($wait_timeout) |
|
30 |
{
|
|
31 |
let $wait_counter= `SELECT $wait_timeout * 10`; |
|
32 |
}
|
|
33 |
# Reset $wait_timeout so that its value won't be used on subsequent |
|
34 |
# calls, and default will be used instead. |
|
35 |
let $wait_timeout= 0; |
|
36 |
||
37 |
# Keep track of how many times the wait condition is tested |
|
38 |
# This is used by some tests (e.g., main.status) |
|
39 |
let $wait_condition_reps= 0; |
|
40 |
while ($wait_counter) |
|
41 |
{
|
|
42 |
let $success= `$wait_condition`; |
|
43 |
inc $wait_condition_reps; |
|
44 |
if ($success) |
|
45 |
{
|
|
46 |
let $wait_counter= 0; |
|
47 |
}
|
|
48 |
if (!$success) |
|
49 |
{
|
|
50 |
real_sleep 0.1; |
|
51 |
dec $wait_counter; |
|
52 |
}
|
|
53 |
}
|
|
54 |
if (!$success) |
|
55 |
{
|
|
56 |
echo Timeout in wait_condition.inc for $wait_condition; |
|
57 |
}
|
|
58 |
||
59 |
--enable_query_log |