[LTP] [PATCH v4 1/2] net: Add tst_net_run helper
Alexey Kodanev
alexey.kodanev@oracle.com
Mon Nov 19 18:19:33 CET 2018
Hi Petr,
On 11/19/2018 06:40 PM, Petr Vorel wrote:
> Hi Alexey,
>
>>>>> Maybe we could signal where error occurred:
>>>>> * return 0: ok on both lhost and rhost
>>>>> * return 1: failure on lhost
>>>>> * return 2: failure on rhost
>>>>> * return 3: failure on both lhost and rhost
>
>
>>>> It is only when there is no "safe" option, right?
>>> yes, as safe exit with TCONF and warning.
>
>>>> when doing cleanup?
>>> IMHO in any "non-safe" run.
>
>>>> Could we print TWARN message inside tst_net_run() in such case?
>>> I wanted tst_net_run() to behave similarly as tst_rhost_run(), which doesn't
>>> warn about it. So I propose to add warning to both functions, but also add -q
>>> flag (quiet), which suppress this warning.
>
>> I think we don't need it for tst_rhost_run() as it is clear where the
>> error has happened. Unlike tst_net_run() without safe option.
> OK, make sense, I'll put it just into tst_net_run().
>
>
>>> The reason for quiet mode is, that (I suppose) there are cases when some
>>> features is tested and TWARN isn't wanted. Some examples (looks -s is used often
>>> in cleanup functions):
>
>> '-s' is used often in cleanup with tst_rhost_run()?
> Sorry, I was wrong. Previously I meant tst_rhost_run *without -s* option.
>
> tst_rhost_run with -s option in cleanup is only in 2 files:
> testcases/network/mpls/mpls_lib.sh
> testcases/network/tcp_cmds/sendfile/sendfile01
> Maybe that's a mistake (unlike C functions where error in SAFE_* continue with
> warning, in shell it exits during cleanup).
>
For tst_test.sh we could add something like this to tst_brk()
iff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 16081fa..e84cf7f 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -41,6 +41,7 @@ trap "tst_brk TBROK 'test interrupted'" INT
_tst_do_exit()
{
local ret=0
+ TST_DO_EXIT=1
if [ -n "$TST_SETUP_STARTED" -a -n "$TST_CLEANUP" -a \
-z "$TST_NO_CLEANUP" ]; then
@@ -123,6 +124,11 @@ tst_brk()
local res=$1
shift
+ if [ "$TST_DO_EXIT" = 1 ]; then
+ tst_res TWARN "$@"
+ return
+ fi
+
tst_res "$res" "$@"
_tst_do_exit
}
> Without -s we don't get any warning, which is often desirable.
> => I'll put warning and -q switch to suppress it only into tst_net_run().
>
>
> Kind regards,
> Petr
>
More information about the ltp
mailing list