[dts] [PATCH v2] mtu update: add invalid values test case

Owen Hilyard ohilyard at iol.unh.edu
Mon Jun 29 17:59:02 CEST 2020


add a test case which tries to set the mtu to several invalid values
add documented for aformentioned test case.

Signed-off-by: Owen Hilyard <ohilyard at iol.unh.edu>
---
 test_plans/mtu_update_test_plan.rst |  6 ++++
 tests/TestSuite_mtu_update.py       | 43 ++++++++++++++++++++---------
 2 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/test_plans/mtu_update_test_plan.rst b/test_plans/mtu_update_test_plan.rst
index b62ec15..70e5c04 100644
--- a/test_plans/mtu_update_test_plan.rst
+++ b/test_plans/mtu_update_test_plan.rst
@@ -152,3 +152,9 @@ Send a packet with size 1600 bytes ::
     ############################################################################
 
 Verify that TX-bytes on port 0 and RX-bytes on port 1 are 1500
+
+Test Case: MTU Checks Invalid Values
+=====================================
+This test case consists of attempting to set the MTU of ports to invalid
+values through TestPmd. Values include the range [0, 63], -1, 2 ^ 128,
+strings_should't_work, 1.2, a null character and 10000.
diff --git a/tests/TestSuite_mtu_update.py b/tests/TestSuite_mtu_update.py
index 6e425dc..0547494 100644
--- a/tests/TestSuite_mtu_update.py
+++ b/tests/TestSuite_mtu_update.py
@@ -34,25 +34,14 @@
 DPDK Test suite.
 MTU Checks example.
 """
-import os
-import subprocess
 from time import sleep
-from typing import List, Tuple
+from typing import Tuple
 
-import utils
 from pmd_output import PmdOutput
-from test_case import TestCase
-
-from pktgen_base import TRANSMIT_S_BURST
 
 import utils
-import re
 import time
 from test_case import TestCase
-from pktgen import TRANSMIT_CONT
-
-from framework.packet import Packet
-from framework.settings import HEADER_SIZE
 
 ETHER_HEADER_LEN = 18
 IP_HEADER_LEN = 20
@@ -112,7 +101,6 @@ class TestMtuUpdate(TestCase):
                                      f'Ether(dst=dutmac, src="52:00:00:00:00:00")/IP()/Raw(load="\x50"*{padding})')
         return out
 
-
     def send_packet_of_size_to_tx_port(self, pktsize, received=True):
         """
         Send 1 packet to portid
@@ -185,6 +173,12 @@ class TestMtuUpdate(TestCase):
         clear up.
         """
         self.dut.kill_all()
+        self.pmdout.start_testpmd("Default")
+        self.exec("port stop all")
+        for port in self.dut_ports:
+            self.exec(f"port config mtu {port} 1500")
+        self.exec("port start all")
+        self.pmdout.quit()
 
     def admin_tester_port(self, local_port, status):
         """
@@ -208,6 +202,7 @@ class TestMtuUpdate(TestCase):
         @return: None
         """
         self.admin_tester_port(self.tester.get_local_port(self.tx_port), f"mtu {mtu:d}")
+
     #
     #
     #
@@ -264,3 +259,25 @@ class TestMtuUpdate(TestCase):
          then being sent packets of size 8999 and 9000.
         """
         self.helper_test_mut_checks(9000)
+
+    def test_mtu_checks_invalid_values(self):
+        """
+        Checks that invalid arguments are rejected.
+        """
+        self.pmdout.start_testpmd("Default")
+        self.exec("port stop all")
+        for port in self.dut_ports:
+            self.exec(f"port config mtu {port} 1500")
+            for invalid_arg in -1, 2 ** 128, "strings_should't_work", 1.2, '\0':
+                self.verify("Bad arguments" in self.exec(f"port config mtu {port :d} {invalid_arg}"),
+                            f"MTU {invalid_arg} was accepted when it shouldn't have been.")
+                mtu: int = int(self.pmdout.get_detail_from_port_info("MTU: ", "\d+", port))
+            for to_low_arg in range(0, 64):
+                self.verify("mtu cannot be less than 64" in self.exec(f"port config mtu {port :d} {to_low_arg}"),
+                            f"MTU {to_low_arg} was accepted when it shouldn't have been.")
+            # Check 10000, which should barely be to high for most NICS
+            self.verify("is not in valid range" in self.exec(f"port config mtu {port :d} 10000"),
+                        f"MTU 10000 was accepted when it shouldn't have been.")
+
+        self.exec("port start all")
+        self.pmdout.quit()
-- 
2.25.1



More information about the dts mailing list