[LTP] [PATCH 1/1] tst_net.sh: Print help ASAP

Alexey Kodanev aleksei.kodanev@bell-sw.com
Thu Jan 27 13:52:10 CET 2022


Hi Petr,
On 26.01.2022 18:08, Petr Vorel wrote:
> This also allows not requiring printing help with root when using
> TST_USE_NETNS:
> 
>     $ PATH="/opt/ltp/testcases/bin:$PATH" gre02.sh -h
>     gre02 1 TCONF: Must be super/root for this test!
> 
> And with root setup was unnecessary things done just to print help:
> 
>     # PATH="/opt/ltp/testcases/bin:$PATH" gre02.sh -h
>     gre02 1 TINFO: initialize 'lhost' 'ltp_ns_veth2' interface
>     gre02 1 TINFO: add local addr 10.0.0.2/24
>     gre02 1 TINFO: add local addr fd00:1:1:1::2/64
>     gre02 1 TINFO: initialize 'rhost' 'ltp_ns_veth1' interface
>     gre02 1 TINFO: add remote addr 10.0.0.1/24
>     gre02 1 TINFO: add remote addr fd00:1:1:1::1/64
>     gre02 1 TINFO: Network config (local -- remote):
>     gre02 1 TINFO: ltp_ns_veth2 -- ltp_ns_veth1
>     gre02 1 TINFO: 10.0.0.2/24 -- 10.0.0.1/24
>     gre02 1 TINFO: fd00:1:1:1::2/64 -- fd00:1:1:1::1/64
>     Usage: /opt/ltp/testcases/bin/gre02.sh [-6]
>     OPTIONS
>     -6      IPv6 tests
>     -h      Prints this help
>     -i n    Execute test n times
> 
> Now just help is printed, work for unprivileged user:
> 
>     $ PATH="/opt/ltp/testcases/bin:$PATH" gre02.sh -h
>     Usage: /opt/ltp/testcases/bin/gre02.sh [-6]
>     OPTIONS
>     -6      IPv6 tests
>     -h      Prints this help
>     -i n    Execute test n times
> 
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  testcases/lib/tst_net.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
> index 4dc0fca926..047686dc39 100644
> --- a/testcases/lib/tst_net.sh
> +++ b/testcases/lib/tst_net.sh
> @@ -937,7 +937,7 @@ tst_default_max_pkt()
>  	echo "$((mtu + mtu / 10))"
>  }
>  
> -[ -n "$TST_NET_SKIP_VARIABLE_INIT" ] && return 0
> +[ -n "$TST_PRINT_HELP" -o -n "$TST_NET_SKIP_VARIABLE_INIT" ] && return 0
>  
>  # Management Link
>  [ -z "$RHOST" ] && TST_USE_NETNS="yes"

Acked-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>


More information about the ltp mailing list