ip_tests.sh: don't use hardcoded eth0
PATCH 1/1 ip_tests.sh: don't use hardcoded eth0
The script uses hardcoded 'eth0' which used to work on most systems. This fix tries to find a 'working' network interface using the hostname.
--- testcases/network/iproute/ip_tests.sh | 50 +++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 23 deletions(-)
testcases/network/iproute/ip_tests.sh +27 -23
@@ -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)) + 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 - tst_brk TBROK NULL NULL "INIT: failed aliasing eth0:1 with IP 10.1.1.12" + tst_brk TBROK NULL NULL "INIT: failed aliasing $INF:1 with IP 10.1.1.12" return $RC else - /sbin/route add -host 10.1.1.12 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1 + /sbin/route add -host 10.1.1.12 dev $INF:1 >$LTPTMP/tst_ip.err 2>&1 RC=$? if [ $RC -ne 0 ] then tst_brk TBROK NULL NULL "INIT: failed adding route to 10.1.1.12" return $RC else - tst_resm TINFO "INIT: added alias: `ifconfig eth0:1`" + tst_resm TINFO "INIT: added alias: `ifconfig $INF:1`" fi fi
@@ -148,7 +152,7 @@ init() # Function: cleanup # # Description - remove temporary files and directories. -# - remove alias to eth0 +# - remove alias to $INF # # Return - zero on success # - non zero on failure. return value from commands ($RC)
@@ -157,11 +161,11 @@ cleanup() TCID=dhcpd TST_COUNT=0 - /sbin/ifconfig eth0:1 >$LTPTMP/tst_ip.err 2>&1 + /sbin/ifconfig $INF:1 >$LTPTMP/tst_ip.err 2>&1 RC=$? if [ $RC -eq 0 ] then - /sbin/ifconfig eth0:1 down >$LTPTMP/tst_ip.err 2>&1 + /sbin/ifconfig $INF:1 down >$LTPTMP/tst_ip.err 2>&1 fi rm -fr $LTPTMP
@@ -189,11 +193,11 @@ test01() tst_resm TINFO \ "Test #1: ip link set DEVICE mtu MTU changes the device mtu size" - tst_resm TINFO "Test #1: changing mtu size of eth0:1 device." + tst_resm TINFO "Test #1: changing mtu size of $INF:1 device." MTUSZ_BAK=`ifconfig eth0:1 | grep -i MTU | sed "s/^.*MTU://" \ | awk '{print $1}'` - ip link set eth0:1 mtu 300 >$LTPTMP/tst_ip.err 2>&1 + ip link set $INF:1 mtu 300 >$LTPTMP/tst_ip.err 2>&1 if [ $RC -ne 0 ] then tst_res TFAIL $LTPTMP/tst_ip.err \
@@ -204,7 +208,7 @@ test01() if [ $MTUSZ -eq 300 ] then tst_resm TPASS "Test #1: changing mtu size success" - ip link set eth0:1 mtu $MTUSZ_BAK \ + ip link set $INF:1 mtu $MTUSZ_BAK \ >$LTPTMP/tst_ip.err 2>&1 else tst_resm FAIL NULL \
@@ -256,7 +260,7 @@ test02() return $RC else tst_resm TPASS \ - "Test #2: Listed eth0:1 and returned correct attributes" + "Test #2: Listed $INF:1 and returned correct attributes" fi return $RC }
@@ -365,7 +369,7 @@ test04() return $RC else tst_resm TINFO \ - "Test #4: ip neigh show - shows all neighbour entries in arp tables." + "Test #4: ip neigh show - shows all neighbour entries in arp tables." cat > $LTPTMP/tst_ip.exp <<-EOF 127.0.0.1 dev lo lladdr 00:00:00:00:00:00 REACHABLE
@@ -443,14 +447,14 @@ test05() tst_resm TINFO \ - "Test #5: create an interface with inet 10.6.6.6 alias to eth0" + "Test #5: create an interface with inet 10.6.6.6 alias to $INF" - ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1 + ifconfig $INF:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1 RC=$? if [ $RC -ne 0 ] then tst_brk TBROK $LTPTMP/tst_ip.err NULL \ - "Test #5: unable to create interface eth0:1 inet 10.6.6.6. Reason:" + "Test #5: unable to create interface $INF:1 inet 10.6.6.6. Reason:" return $RC fi
@@ -541,16 +545,16 @@ test06() tst_resm TINFO \ "Test #6: ip maddr add - adds a new multicast addr" - ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1 + ifconfig $INF:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1 RC=$? if [ $RC -ne 0 ] then tst_brk TBROK $LTPTMP/tst_ip.err NULL \ - "Test #6: unable to create interface eth0:1 inet 10.6.6.6. Reason:" + "Test #6: unable to create interface $INF:1 inet 10.6.6.6. Reason:" return $RC fi - ip maddr add 66:66:00:00:00:66 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1 + ip maddr add 66:66:00:00:00:66 dev $INF:1 >$LTPTMP/tst_ip.err 2>&1 RC=$? if [ $RC -ne 0 ] then
@@ -579,7 +583,7 @@ test06() if [ $RC -ne 0 ] then tst_res FAIL $LTPTMP/tst_ip.err \ - "Test #6: multicast addr not added to eth0:1. Details:" + "Test #6: multicast addr not added to $INF:1. Details:" return $RC fi fi
@@ -587,7 +591,7 @@ test06() tst_resm TINFO \ "Test #6: ip maddr del - deletes multicast addr." - ip maddr del 66:66:00:00:00:66 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1 + ip maddr del 66:66:00:00:00:66 dev $INF:1 >$LTPTMP/tst_ip.err 2>&1 RC=$? if [ $RC -ne 0 ] then
Signature · 8 lines
1.9.1 ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 2 lines · On Fri 28 Mar 2014 09:44:24 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.
why doesn't hardcoding "lo" work ?
-mike
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
In my CentOS box, running "ifconfig lo:1 10.1.1.12" immediately hangs the ssh connection, I have to run "systemctl restart network" in local tty to make network work again. Could you help to try the testcases in ip_tests.sh on your box and report back?
Thanks
Simon
Quoted 5 lines · Mike Frysinger
Quoted 2 lines · On Fri 28 Mar 2014 09:44:24 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.
why doesn't hardcoding "lo" work ?
-mike
------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration Continuously Automate Build, Test & Deployment Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Ltp-list mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Could anyone else help to review the patch?
Thanks
Simon
Quoted 174 lines · Simon Xu
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 <[email protected]>--- testcases/network/iproute/ip_tests.sh | 50 +++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 23 deletions(-)testcases/network/iproute/ip_tests.sh +26
-22@@ -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)) + 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 - tst_brk TBROK NULL NULL "INIT: failed aliasing eth0:1 with IP 10.1.1.12" + tst_brk TBROK NULL NULL "INIT: failed aliasing $INF:1 with IP 10.1.1.12" return $RC else - /sbin/route add -host 10.1.1.12 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1 + /sbin/route add -host 10.1.1.12 dev $INF:1 >$LTPTMP/tst_ip.err 2>&1 RC=$? if [ $RC -ne 0 ] then tst_brk TBROK NULL NULL "INIT: failed adding route to 10.1.1.12" return $RC else - tst_resm TINFO "INIT: added alias: `ifconfig eth0:1`" + tst_resm TINFO "INIT: added alias: `ifconfig $INF:1`" fi fi@@ -148,7 +152,7 @@ init() # Function: cleanup # # Description - remove temporary files and directories. -# - remove alias to eth0 +# - remove alias to $INF # # Return - zero on success # - non zero on failure. return value from commands ($RC)@@ -157,11 +161,11 @@ cleanup() TCID=dhcpd TST_COUNT=0 - /sbin/ifconfig eth0:1 >$LTPTMP/tst_ip.err 2>&1 + /sbin/ifconfig $INF:1 >$LTPTMP/tst_ip.err 2>&1 RC=$? if [ $RC -eq 0 ] then - /sbin/ifconfig eth0:1 down >$LTPTMP/tst_ip.err 2>&1 + /sbin/ifconfig $INF:1 down >$LTPTMP/tst_ip.err 2>&1 fi rm -fr $LTPTMP@@ -189,11 +193,11 @@ test01() tst_resm TINFO \ "Test #1: ip link set DEVICE mtu MTU changes the device mtu size" - tst_resm TINFO "Test #1: changing mtu size of eth0:1 device." + tst_resm TINFO "Test #1: changing mtu size of $INF:1 device." MTUSZ_BAK=`ifconfig eth0:1 | grep -i MTU | sed "s/^.*MTU://" \ | awk '{print $1}'` - ip link set eth0:1 mtu 300 >$LTPTMP/tst_ip.err 2>&1 + ip link set $INF:1 mtu 300 >$LTPTMP/tst_ip.err 2>&1 if [ $RC -ne 0 ] then tst_res TFAIL $LTPTMP/tst_ip.err \@@ -204,7 +208,7 @@ test01() if [ $MTUSZ -eq 300 ] then tst_resm TPASS "Test #1: changing mtu size success" - ip link set eth0:1 mtu $MTUSZ_BAK \ + ip link set $INF:1 mtu $MTUSZ_BAK \ >$LTPTMP/tst_ip.err 2>&1 else tst_resm FAIL NULL \@@ -256,7 +260,7 @@ test02() return $RC else tst_resm TPASS \ - "Test #2: Listed eth0:1 and returned correct attributes" + "Test #2: Listed $INF:1 and returned correct attributes" fi return $RC }@@ -365,7 +369,7 @@ test04() return $RC else tst_resm TINFO \ - "Test #4: ip neigh show - shows all neighbour entries in arp tables." + "Test #4: ip neigh show - shows all neighbour entries in arp tables." cat > $LTPTMP/tst_ip.exp <<-EOF 127.0.0.1 dev lo lladdr 00:00:00:00:00:00 REACHABLE@@ -443,14 +447,14 @@ test05() tst_resm TINFO \ - "Test #5: create an interface with inet 10.6.6.6 alias to eth0" + "Test #5: create an interface with inet 10.6.6.6 alias to $INF" - ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1 + ifconfig $INF:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1 RC=$? if [ $RC -ne 0 ] then tst_brk TBROK $LTPTMP/tst_ip.err NULL \ - "Test #5: unable to create interface eth0:1 inet 10.6.6.6. Reason:" + "Test #5: unable to create interface $INF:1 inet 10.6.6.6. Reason:" return $RC fi@@ -541,16 +545,16 @@ test06() tst_resm TINFO \ "Test #6: ip maddr add - adds a new multicast addr" - ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1 + ifconfig $INF:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1 RC=$? if [ $RC -ne 0 ] then tst_brk TBROK $LTPTMP/tst_ip.err NULL \ - "Test #6: unable to create interface eth0:1 inet 10.6.6.6. Reason:" + "Test #6: unable to create interface $INF:1 inet 10.6.6.6. Reason:" return $RC fi - ip maddr add 66:66:00:00:00:66 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1 + ip maddr add 66:66:00:00:00:66 dev $INF:1 >$LTPTMP/tst_ip.err 2>&1 RC=$? if [ $RC -ne 0 ] then@@ -579,7 +583,7 @@ test06() if [ $RC -ne 0 ] then tst_res FAIL $LTPTMP/tst_ip.err \ - "Test #6: multicast addr not added to eth0:1. Details:" + "Test #6: multicast addr not added to $INF:1. Details:" return $RC fi fi
testcases/network/iproute/ip_tests.sh test06() · line 597
Quoted 8 lines
testcases/network/iproute/ip_tests.sh +1
-1@@ -587,7 +591,7 @@ test06() tst_resm TINFO \ "Test #6: ip maddr del - deletes multicast addr." - ip maddr del 66:66:00:00:00:66 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1 + ip maddr del 66:66:00:00:00:66 dev $INF:1 >$LTPTMP/tst_ip.err 2>&1 RC=$? if [ $RC -ne 0 ] then
------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration Continuously Automate Build, Test & Deployment Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Ltp-list mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Could anyone help to review this?
Thanks
Simon
Quoted 174 lines · Simon Xu
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 <[email protected]>--- testcases/network/iproute/ip_tests.sh | 50 +++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 23 deletions(-)testcases/network/iproute/ip_tests.sh +26
-22@@ -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)) + 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 - tst_brk TBROK NULL NULL "INIT: failed aliasing eth0:1 with IP 10.1.1.12" + tst_brk TBROK NULL NULL "INIT: failed aliasing $INF:1 with IP 10.1.1.12" return $RC else - /sbin/route add -host 10.1.1.12 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1 + /sbin/route add -host 10.1.1.12 dev $INF:1 >$LTPTMP/tst_ip.err 2>&1 RC=$? if [ $RC -ne 0 ] then tst_brk TBROK NULL NULL "INIT: failed adding route to 10.1.1.12" return $RC else - tst_resm TINFO "INIT: added alias: `ifconfig eth0:1`" + tst_resm TINFO "INIT: added alias: `ifconfig $INF:1`" fi fi@@ -148,7 +152,7 @@ init() # Function: cleanup # # Description - remove temporary files and directories. -# - remove alias to eth0 +# - remove alias to $INF # # Return - zero on success # - non zero on failure. return value from commands ($RC)@@ -157,11 +161,11 @@ cleanup() TCID=dhcpd TST_COUNT=0 - /sbin/ifconfig eth0:1 >$LTPTMP/tst_ip.err 2>&1 + /sbin/ifconfig $INF:1 >$LTPTMP/tst_ip.err 2>&1 RC=$? if [ $RC -eq 0 ] then - /sbin/ifconfig eth0:1 down >$LTPTMP/tst_ip.err 2>&1 + /sbin/ifconfig $INF:1 down >$LTPTMP/tst_ip.err 2>&1 fi rm -fr $LTPTMP@@ -189,11 +193,11 @@ test01() tst_resm TINFO \ "Test #1: ip link set DEVICE mtu MTU changes the device mtu size" - tst_resm TINFO "Test #1: changing mtu size of eth0:1 device." + tst_resm TINFO "Test #1: changing mtu size of $INF:1 device." MTUSZ_BAK=`ifconfig eth0:1 | grep -i MTU | sed "s/^.*MTU://" \ | awk '{print $1}'` - ip link set eth0:1 mtu 300 >$LTPTMP/tst_ip.err 2>&1 + ip link set $INF:1 mtu 300 >$LTPTMP/tst_ip.err 2>&1 if [ $RC -ne 0 ] then tst_res TFAIL $LTPTMP/tst_ip.err \@@ -204,7 +208,7 @@ test01() if [ $MTUSZ -eq 300 ] then tst_resm TPASS "Test #1: changing mtu size success" - ip link set eth0:1 mtu $MTUSZ_BAK \ + ip link set $INF:1 mtu $MTUSZ_BAK \ >$LTPTMP/tst_ip.err 2>&1 else tst_resm FAIL NULL \@@ -256,7 +260,7 @@ test02() return $RC else tst_resm TPASS \ - "Test #2: Listed eth0:1 and returned correct attributes" + "Test #2: Listed $INF:1 and returned correct attributes" fi return $RC }@@ -365,7 +369,7 @@ test04() return $RC else tst_resm TINFO \ - "Test #4: ip neigh show - shows all neighbour entries in arp tables." + "Test #4: ip neigh show - shows all neighbour entries in arp tables." cat > $LTPTMP/tst_ip.exp <<-EOF 127.0.0.1 dev lo lladdr 00:00:00:00:00:00 REACHABLE@@ -443,14 +447,14 @@ test05() tst_resm TINFO \ - "Test #5: create an interface with inet 10.6.6.6 alias to eth0" + "Test #5: create an interface with inet 10.6.6.6 alias to $INF" - ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1 + ifconfig $INF:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1 RC=$? if [ $RC -ne 0 ] then tst_brk TBROK $LTPTMP/tst_ip.err NULL \ - "Test #5: unable to create interface eth0:1 inet 10.6.6.6. Reason:" + "Test #5: unable to create interface $INF:1 inet 10.6.6.6. Reason:" return $RC fi@@ -541,16 +545,16 @@ test06() tst_resm TINFO \ "Test #6: ip maddr add - adds a new multicast addr" - ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1 + ifconfig $INF:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1 RC=$? if [ $RC -ne 0 ] then tst_brk TBROK $LTPTMP/tst_ip.err NULL \ - "Test #6: unable to create interface eth0:1 inet 10.6.6.6. Reason:" + "Test #6: unable to create interface $INF:1 inet 10.6.6.6. Reason:" return $RC fi - ip maddr add 66:66:00:00:00:66 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1 + ip maddr add 66:66:00:00:00:66 dev $INF:1 >$LTPTMP/tst_ip.err 2>&1 RC=$? if [ $RC -ne 0 ] then@@ -579,7 +583,7 @@ test06() if [ $RC -ne 0 ] then tst_res FAIL $LTPTMP/tst_ip.err \ - "Test #6: multicast addr not added to eth0:1. Details:" + "Test #6: multicast addr not added to $INF:1. Details:" return $RC fi fi
testcases/network/iproute/ip_tests.sh test06() · line 597
Quoted 8 lines
testcases/network/iproute/ip_tests.sh +1
-1@@ -587,7 +591,7 @@ test06() tst_resm TINFO \ "Test #6: ip maddr del - deletes multicast addr." - ip maddr del 66:66:00:00:00:66 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1 + ip maddr del 66:66:00:00:00:66 dev $INF:1 >$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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Quoted 6 lines · Mike Frysinger
Quoted 2 lines · On Fri 28 Mar 2014 09:44:24 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.
why doesn't hardcoding "lo" work ?
-mike
I think we can't use the loopback interface because test06 fails if invoked with lo:
[root@kholmanskikh stas]# /sbin/ifconfig lo:1 1.2.3.4 netmask 255.255.255.0 up
[root@kholmanskikh stas]# /sbin/ip maddr add 66:66:00:00:00:66 dev lo:1
ioctl: Invalid argument
[root@kholmanskikh stas]# /sbin/ifconfig eth0:1 3.4.5.6 netmask 255.255.255.0 up
[root@kholmanskikh stas]# /sbin/ip maddr add 66:66:00:00:00:66 dev eth0:1 [root@kholmanskikh stas]#
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Quoted 31 lines · Simon Xu
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 <[email protected]>--- testcases/network/iproute/ip_tests.sh | 50 +++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 23 deletions(-)testcases/network/iproute/ip_tests.sh +2
-2@@ -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 ]
testcases/network/iproute/ip_tests.sh init() · line 111
Quoted 7 lines
testcases/network/iproute/ip_tests.sh +2
-2@@ -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?
testcases/network/iproute/ip_tests.sh init() · line 118
Quoted 7 lines
testcases/network/iproute/ip_tests.sh +4
-0+ 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list