Show More
@@ -1,38 +1,36 b'' | |||||
1 |
#!/bin/ |
|
1 | #!/bin/sh | |
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=$(( ( 100 * $timer * $HGTEST_TIMEOUT) / $HGTEST_TIMEOUT_DEFAULT )) |
|
16 | timer=$(( ( 100 * $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" ]; then | |
26 | then |
|
|||
27 | touch "$create" |
|
26 | touch "$create" | |
28 | create="" |
|
27 | create="" | |
29 | fi |
|
28 | fi | |
30 | while [ "$timer" -gt 0 ] && [ ! -f "$wait_on" ]; |
|
29 | while [ "$timer" -gt 0 ] && [ ! -f "$wait_on" ]; do | |
31 | do |
|
|||
32 | timer=$(( $timer - 1)) |
|
30 | timer=$(( $timer - 1)) | |
33 | sleep 0.01 |
|
31 | sleep 0.01 | |
34 | done |
|
32 | done | |
35 | if [ "$timer" -le 0 ]; then |
|
33 | if [ "$timer" -le 0 ]; then | |
36 | echo "file not created after $1 seconds: $wait_on" >&2 |
|
34 | echo "file not created after $1 seconds: $wait_on" >&2 | |
37 | exit 1 |
|
35 | exit 1 | |
38 | fi |
|
36 | fi |
General Comments 0
You need to be logged in to leave comments.
Login now