From: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
To: Simon Xu <xu.simon@oracle.com>, ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] ip_tests.sh: don't use hardcoded eth0
Date: Fri, 25 Apr 2014 16:26:42 +0400 [thread overview]
Message-ID: <535A5482.2010206@oracle.com> (raw)
In-Reply-To: <1395971064-625-1-git-send-email-xu.simon@oracle.com>
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.simon@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
next prev parent reply other threads:[~2014-04-25 12:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-28 1:44 [LTP] [PATCH] ip_tests.sh: don't use hardcoded eth0 Simon Xu
2014-03-28 5:08 ` Mike Frysinger
2014-04-09 6:09 ` Simon Xu
2014-04-25 12:04 ` Stanislav Kholmanskikh
2014-04-09 6:10 ` Simon Xu
2014-04-25 1:06 ` Simon Xu
2014-04-25 12:26 ` Stanislav Kholmanskikh [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-04-25 13:59 Joseph Beckenbach
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=535A5482.2010206@oracle.com \
--to=stanislav.kholmanskikh@oracle.com \
--cc=ltp-list@lists.sourceforge.net \
--cc=xu.simon@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.