[LTP] [RFC PATCH 1/2] tst_net.sh: Fix for disabled IPv6

Martin Doucha mdoucha@suse.cz
Mon Jan 24 15:19:06 CET 2022


Hi,

On 19. 01. 22 20:55, Petr Vorel wrote:
> Tests failed in tst_init_iface even IPv4 only test was run.
> Allow to init interfaces at least for IPv4.
> 
> Tests which use TST_IPV6=6 needs to be fixed (unless they use
> just tst_ipaddr_un()).
> 
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  testcases/lib/tst_net.sh | 66 +++++++++++++++++++++++++++++++++-------
>  1 file changed, 55 insertions(+), 11 deletions(-)
> 
> diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh
> index 4dc0fca926..df16e12a26 100644
> --- a/testcases/lib/tst_net.sh
> +++ b/testcases/lib/tst_net.sh
> @@ -24,7 +24,9 @@ TST_IPV6_FLAG=${TST_IPV6_FLAG:-}
>  tst_net_parse_args()
>  {
>  	case $1 in
> -	6) TST_IPV6=6 TST_IPVER=6 TST_IPV6_FLAG="-6";;
> +	6)  tst_net_require_ipv6
> +		TST_IPV6=6 TST_IPVER=6 TST_IPV6_FLAG="-6"
> +		;;
>  	*) [ "$TST_PARSE_ARGS_CALLER" ] && $TST_PARSE_ARGS_CALLER "$1" "$2";;
>  	esac
>  }
> @@ -100,6 +102,30 @@ tst_brk_()
>  	[ -z "$TST_USE_LEGACY_API" ] && tst_brk $@ || tst_brkm $@
>  }
>  
> +tst_net_detect_ipv6()
> +{
> +	local type="${1:-lhost}"
> +	local cmd='[ -f /proc/net/if_inet6 ]'
> +
> +	if [ "$type" = "lhost" ]; then
> +		$cmd
> +		return $?
> +	fi
> +
> +	tst_rhost_run -c "$cmd"
> +	return $?
> +}

tst_net_detect_ipv6() should probably run each check only once and cache
the result. The function is called multiple times and tst_rhost_run()
could be quite slow if the remote side is on a different physical machine.

-- 
Martin Doucha   mdoucha@suse.cz
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic


More information about the ltp mailing list