diff options
author | Hangbin Liu <liuhangbin@gmail.com> | 2015-07-16 22:47:53 +0800 |
---|---|---|
committer | Cyril Hrubis <chrubis@suse.cz> | 2015-07-30 17:44:52 +0200 |
commit | d6a390e44e0caffbb19d96dfd0d6c0c83b27e602 (patch) | |
tree | c07f66ada9bf47cabfee245600b3a2642a6ced1a /doc | |
parent | 5e391383f6f00930123c5c17c4161ebf232063d4 (diff) |
testcases/lib/test.sh: add tst_retry()
The function allows you to retry running command a few times until it
succeeds or until given amount of retries has been reached.
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/test-writing-guidelines.txt | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt index edd59051d..de06dc9b5 100644 --- a/doc/test-writing-guidelines.txt +++ b/doc/test-writing-guidelines.txt @@ -1247,11 +1247,34 @@ fi ... ------------------------------------------------------------------------------- -The tst_fs_has_free shell interface returns 0 if the specified free space is +The 'tst_fs_has_free' shell interface returns 0 if the specified free space is satisfied, 1 if not, and 2 on error. The second argument supports suffixes kB, MB and GB, the default unit is Byte. +.tst_retry +[source,sh] +------------------------------------------------------------------------------- +#!/bin/sh + +... + +# Retry ping command three times +tst_retry "ping -c 1 127.0.0.1" + +if [ $? -ne 0 ]; then + tst_resm TFAIL "Failed to ping 127.0.0.1" +else + tst_resm TPASS "Successfully pinged 127.0.0.1" +fi + +... +------------------------------------------------------------------------------- + +The 'tst_retry' function allows you to retry a command after waiting small +amount of time until it succeeds or until given amount of retries has been +reached (default is three attempts). + 2.3.3 Cleanup ^^^^^^^^^^^^^ |