And make use of it in the tests.

Signed-off-by: Alexey Kodanev <alexey.koda...@oracle.com>
---
 testcases/network/virt/virt_lib.sh |   34 ++++++++++++++++++++++++++++++++++
 testcases/network/virt/vlan01.sh   |   25 +++----------------------
 testcases/network/virt/vxlan01.sh  |   28 +++++-----------------------
 3 files changed, 42 insertions(+), 45 deletions(-)

diff --git a/testcases/network/virt/virt_lib.sh 
b/testcases/network/virt/virt_lib.sh
index 77fa788..b27bd6a 100644
--- a/testcases/network/virt/virt_lib.sh
+++ b/testcases/network/virt/virt_lib.sh
@@ -250,6 +250,40 @@ virt_compare_netperf()
        return $ret
 }
 
+# Check if we can create then delete virtual interface n times.
+# virt_test_01 [OPTIONS]
+# OPTIONS - different options separated by comma.
+virt_test_01()
+{
+       start_id=1
+       virt_count=500
+
+       local opts=${1:-""}
+       local n=0
+
+       while ((1)); do
+               n=$((n + 1))
+               p="$(echo $opts | cut -d',' -f$n)"
+               if [ -z "$p" -a $n -gt 1 ]; then
+                       break
+               fi
+
+               tst_resm TINFO "add $virt_type with '$p'"
+
+               virt_add ltp_v0 id 0 $p > /dev/null 2>&1
+               if [ $? -ne 0 ]; then
+                       tst_resm TCONF "iproute/kernel doesn't support '$p'"
+                       p=""
+               else
+                       ROD_SILENT "ip li delete ltp_v0"
+               fi
+
+               virt_multiple_add_test "$p"
+
+               start_id=$(($start_id + $virt_count))
+       done
+}
+
 tst_require_root
 
 case "$virt_type" in
diff --git a/testcases/network/virt/vlan01.sh b/testcases/network/virt/vlan01.sh
index ac74463..fb96562 100755
--- a/testcases/network/virt/vlan01.sh
+++ b/testcases/network/virt/vlan01.sh
@@ -16,7 +16,7 @@
 #
 # Author: Alexey Kodanev <alexey.koda...@oracle.com>
 #
-# Test-case 1: Local test, check if we can create 4095 VLAN interfaces.
+# Local test, check if we can create 4000 VLAN interfaces.
 #
 
 TCID=vlan01
@@ -34,28 +34,9 @@ lb1="loose_binding on"
 rh0="reorder_hdr off"
 rh1="reorder_hdr on"
 
-opts="$p0 $lb0 $rh0,$p0 $lb0 $rh1,$p0 $lb1 $rh0,$p0 $lb1 $rh1,\
+options="$p0 $lb0 $rh0,$p0 $lb0 $rh1,$p0 $lb1 $rh0,$p0 $lb1 $rh1,\
 $p1 $lb0 $rh0,$p1 $lb0 $rh1,$p1 $lb1 $rh0,$p1 $lb1 $rh1,"
 
-start_id=1
-virt_count=500
-
-for n in $(seq 1 8); do
-       params="$(echo $opts | cut -d',' -f$n)"
-
-       tst_resm TINFO "add $virt_type with '$params'"
-
-       virt_add ltp_v0 id 0 $params > /dev/null 2>&1
-       if [ $? -ne 0 ]; then
-               tst_resm TCONF "iproute or kernel doesn't support '$params'"
-               params=""
-       else
-               ROD_SILENT "ip li delete ltp_v0"
-       fi
-
-       virt_multiple_add_test "$params"
-
-       start_id=$(($start_id + $virt_count))
-done
+virt_test_01 "$options"
 
 tst_exit
diff --git a/testcases/network/virt/vxlan01.sh 
b/testcases/network/virt/vxlan01.sh
index 63a52d0..4dfe3d7 100755
--- a/testcases/network/virt/vxlan01.sh
+++ b/testcases/network/virt/vxlan01.sh
@@ -16,11 +16,11 @@
 #
 # Author: Alexey Kodanev <alexey.koda...@oracle.com>
 #
-# Test-case 1: Local test, check if we can create 5000 VXLAN interfaces.
+# Local test, check if we can create 2500 VXLAN interfaces.
 #
 
 TCID=vxlan01
-TST_TOTAL=1
+TST_TOTAL=5
 
 virt_type="vxlan"
 start_id=16700000
@@ -28,27 +28,9 @@ start_id=16700000
 . test_net.sh
 . virt_lib.sh
 
-opts="l2miss l3miss,norsc nolearning noproxy,ttl 0x01 tos 0x01,ttl 0xff tos 
0xff,gbp"
+options="l2miss l3miss,norsc nolearning noproxy,\
+ttl 0x01 tos 0x01,ttl 0xff tos 0xff,gbp"
 
-start_id=1
-virt_count=1000
-
-for n in $(seq 1 5); do
-       params="$(echo $opts | cut -d',' -f$n)"
-
-       tst_resm TINFO "add $virt_type with '$params'"
-
-       virt_add ltp_v0 id 0 $params > /dev/null 2>&1
-       if [ $? -ne 0 ]; then
-               tst_resm TCONF "iproute or kernel doesn't support '$params'"
-               params=""
-       else
-               ROD_SILENT "ip li delete ltp_v0"
-       fi
-
-       virt_multiple_add_test "$params"
-
-       start_id=$(($start_id + $virt_count))
-done
+virt_test_01 "$options"
 
 tst_exit
-- 
1.7.1


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to