Show More
@@ -1,38 +1,36 b'' | |||
|
1 |
#!/bin/ |
|
|
1 | #!/bin/sh | |
|
2 | 2 | # |
|
3 | 3 | # wait up to TIMEOUT seconds until a WAIT_ON_FILE is created. |
|
4 | 4 | # |
|
5 | 5 | # In addition, this script can create CREATE_FILE once it is ready to wait. |
|
6 | 6 | |
|
7 | 7 | if [ $# -lt 2 ] || [ $# -gt 3 ]; then |
|
8 | 8 | echo $# |
|
9 | 9 | echo "USAGE: $0 TIMEOUT WAIT_ON_FILE [CREATE_FILE]" |
|
10 | 10 | fi |
|
11 | 11 | |
|
12 | 12 | timer="$1" |
|
13 | 13 | |
|
14 | 14 | # if the test timeout have been extended, explicitly extend the provided timer |
|
15 | 15 | if [ "$HGTEST_TIMEOUT_DEFAULT" -lt "$HGTEST_TIMEOUT" ]; then |
|
16 | 16 | timer=$(( ( 100 * $timer * $HGTEST_TIMEOUT) / $HGTEST_TIMEOUT_DEFAULT )) |
|
17 | 17 | fi |
|
18 | 18 | |
|
19 | 19 | wait_on="$2" |
|
20 | 20 | create="" |
|
21 | 21 | if [ $# -eq 3 ]; then |
|
22 | 22 | create="$3" |
|
23 | 23 | fi |
|
24 | 24 | |
|
25 | if [ -n "$create" ]; | |
|
26 | then | |
|
25 | if [ -n "$create" ]; then | |
|
27 | 26 | touch "$create" |
|
28 | 27 | create="" |
|
29 | 28 | fi |
|
30 | while [ "$timer" -gt 0 ] && [ ! -f "$wait_on" ]; | |
|
31 | do | |
|
29 | while [ "$timer" -gt 0 ] && [ ! -f "$wait_on" ]; do | |
|
32 | 30 | timer=$(( $timer - 1)) |
|
33 | 31 | sleep 0.01 |
|
34 | 32 | done |
|
35 | 33 | if [ "$timer" -le 0 ]; then |
|
36 | 34 | echo "file not created after $1 seconds: $wait_on" >&2 |
|
37 | 35 | exit 1 |
|
38 | 36 | fi |
General Comments 0
You need to be logged in to leave comments.
Login now