[LTP] [PATCH] net/host: update to new api

Alexey Kodanev alexey.kodanev@oracle.com
Tue Nov 17 10:39:57 CET 2020


On 16.11.2020 21:41, Petr Vorel wrote:
> Hi Kory,
> 
> thanks for your patch.
> ...
>>  do_test()
>>  {
> 
>> -    tst_resm TINFO "test basic functionality of the \`$TC' command."
>> +    tst_res TINFO "test basic functionality of the host command."
> 
>> -    while [ $TST_COUNT -lt $NUMLOOPS ]; do
>> +    while [ $TST_COUNT -le $NUMLOOPS ]; do
> IMHO there is no need to have loop like this.
> If required, we'd just add -iN parameter to it in the runtest file (where N is
> <1,max int), but IMHO it's enough to test host only once.
> 
>>          if rhost_addr=$(host $RHOST); then
>> -            rhost_addr=$(echo "$rhost_addr" | awk -F, '{print $NF}') >/dev/null 2>&1
>> -            if ! host $rhost_addr >/dev/null 2>&1; then
>> -                end_testcase "reverse lookup with host failed"
>> -            fi
>> -
>> +            rhost_addr=$(echo "$rhost_addr" | awk '{print $NF}') >/dev/null 2>&1
>> +            EXPECT_PASS host $rhost_addr \>/dev/null 2>&1
> We need to redirect also second > and &:
> EXPECT_PASS host $rhost_addr \>/dev/null 2\>\&1
> 
>>          else
>> -            end_testcase "host $RHOST on local machine failed"
>> +            tst_brk TFAIL "host $RHOST on local machine failed"
>>          fi
> 
>> -        incr_tst_count
>> +        TST_COUNT=$((TST_COUNT + 1))
>>          sleep $SLEEPTIME
> Also sleep time is not really needed.
> 
> ...
> 
> Can I merge this simplified variant?
...
> 
> . tst_net.sh
> 
> do_test()
> {
> 	local rhost=${RHOST:-$(hostname)}

Hi Petr, Kory

For new API we shouldn't use RHOST. Also the naming is misleading,
it can be a local host name.


> 	local rhost_addr
> 
>     tst_res TINFO "test basic functionality of the host command"
> 
> 	if rhost_addr=$(host $rhost); then
> 		rhost_addr=$(echo "$rhost_addr" | awk '{print $NF}')
> 		EXPECT_PASS host $rhost_addr \>/dev/null 2\>\&1
> 	else
> 		tst_brk TFAIL "host $rhost on local machine failed"
> 	fi
> }
> 
> tst_run
> 



More information about the ltp mailing list