Hi!

On 03/28/2014 05:44 AM, Simon Xu wrote:
> The script uses hardcoded 'eth0' which used to work on most systems.
> This fix tries to find a 'working' network interface using the hostname.
>
> Signed-off-by: Simon Xu <xu.si...@oracle.com>
> ---
>   testcases/network/iproute/ip_tests.sh | 50 
> +++++++++++++++++++----------------
>   1 file changed, 27 insertions(+), 23 deletions(-)
>
> diff --git a/testcases/network/iproute/ip_tests.sh 
> b/testcases/network/iproute/ip_tests.sh
> index ed20540..4bba243 100755
> --- a/testcases/network/iproute/ip_tests.sh
> +++ b/testcases/network/iproute/ip_tests.sh
> @@ -38,7 +38,7 @@ set +x
>   # Description:      - Check if command ip is available.
>   #               - Check if command ifconfig is available.
>   #               - check if command awk is available.
> -#               - alias eth0 to eth0:1 with IP 10.1.1.12
> +#               - alias $INF to $INF:1 with IP 10.1.1.12
>   #
>   # Return            - zero on success
>   #               - non zero on failure. return value from commands ($RC)
> @@ -46,7 +46,7 @@ init()
>   {
>
>       export TST_TOTAL=2                      # total numner of tests in this 
> file.
> -     export TCID="ip_tests  "                # this is the init function.
> +     export TCID="ip_tests"                  # this is the init function.
>       export TST_COUNT=0                      # init identifier,
>
>       if [ -z $TMP ]
> @@ -107,22 +107,26 @@ init()
>
>       tst_resm TINFO "INIT: Inititalizing tests."
>
> -     # Aliasing eth0 to create private network.
> -     /sbin/ifconfig eth0:1 10.1.1.12 >$LTPTMP/tst_ip.err 2>&1
> +     # Get network interface.
> +     IP=$(dig +short $(hostname))

This would require that the $(hostname) is registered to DNS.

Given that we only need a working device (no matter what ip it has), 
maybe just do something like:
/sbin/ifconfig | grep HWaddr | head -n 1
to get a L2-capable device.

What do you think?

> +     INF=$(ifconfig|grep -B1 $IP|head -1|sed 's/:.*//')
> +
> +     # Aliasing $INF to create private network.
> +     /sbin/ifconfig $INF:1 10.1.1.12 >$LTPTMP/tst_ip.err 2>&1
>       RC=$?
>       if [ $RC -ne 0 ]
>       then

------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to