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