Changeset 4fb510d in mod_gnutls for test/common.bash
- Timestamp:
- Mar 5, 2017, 11:55:51 AM (4 years ago)
- Branches:
- asyncio, debian/master, debian/stretch-backports, master, proxy-ticket, upstream
- Children:
- 339a49d
- Parents:
- 5f3222b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/common.bash
r5f3222b r4fb510d 15 15 sleep 1 16 16 done 17 } 18 19 20 21 # Usage: verbose_log [...] 22 # 23 # If VERBOSE is not empty, write a log message prefixed with the name 24 # of the calling function. The function is defined to a no-op 25 # otherwise. 26 if [ -n "${VERBOSE}" ]; then 27 function verbose_log 28 { 29 echo "${FUNCNAME[1]}: ${@}" 30 } 31 else 32 function verbose_log 33 { 34 return 35 } 36 fi 37 38 39 40 # Usage: wait_ready COMMAND [TIMEOUT] [STEP] 41 # 42 # Wait until COMMAND terminates with success (zero exit code), or 43 # until the TIMEOUT (in milliseconds) expires. TIMEOUT defaults to 44 # $TEST_SERVICE_MAX_WAIT if unset. A TIMEOUT of zero means to try 45 # once. 46 # 47 # COMMAND is retried every STEP milliseconds, the default is 48 # $TEST_SERVICE_WAIT. Note that the last try may happen a little after 49 # TIMEOUT expires if STEP does not evenly divide it. 50 function wait_ready 51 { 52 local command="${1}" 53 if [ -z "${2}" ]; then 54 local -i timeout="${TEST_SERVICE_MAX_WAIT}" 55 else 56 local -i timeout="${2}" 57 fi 58 local -i step="${3}" 59 [ ${step} -gt 0 ] || step="${TEST_SERVICE_WAIT}" 60 # convert step to seconds because that's what "sleep" needs 61 local sec_step="$((${step} / 1000)).$((${step} % 1000))" 62 63 verbose_log "Waiting for \"${command}\" ..." 64 local -i waited=0 65 until eval "${command}"; do 66 if [ "${waited}" -ge "${timeout}" ]; then 67 echo "${FUNCNAME[0]}: Timed out waiting for \"${command}\"" \ 68 "to succeed (waited ${waited} ms)." >&2 69 return 1 70 fi 71 waited=$((waited + step)); 72 sleep "${sec_step}" 73 verbose_log "waiting (${waited} ms)" 74 done 75 verbose_log "done (waited ${waited} ms)" 17 76 } 18 77
Note: See TracChangeset
for help on using the changeset viewer.