mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / include / wait_condition.inc
bloba41d8080c9b1ff6de58bca55171db707ea37938b
1 # include/wait_condition.inc
3 # SUMMARY
5 #    Waits until the passed statement returns true, or the operation
6 #    times out.
8 # USAGE
10 #    let $wait_condition=
11 #      SELECT c = 3 FROM t;
12 #    --source include/wait_condition.inc
14 #   OR
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
22 # EXAMPLE
23 #    events_bugs.test, events_time_zone.test
26 --disable_query_log
28 let $wait_counter= 300;
29 if ($wait_timeout)
31   let $wait_counter= `SELECT $wait_timeout * 10`;
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;
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)
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     }
54 if (!$success)
56   echo Timeout in wait_condition.inc for $wait_condition;
59 --enable_query_log