Added skip message support
Emit message to stderr when skipping a test depending on verbosity
level. Report number of tests skipped at end of test run.
diff --git a/tests/oft b/tests/oft
index c4b1491..f7b72f0 100755
--- a/tests/oft
+++ b/tests/oft
@@ -124,6 +124,8 @@
import time
import os
+import testutils
+
try:
import scapy.all as scapy
except:
@@ -496,5 +498,11 @@
if __name__ == "__main__":
logging.info("*** TEST RUN START: " + time.asctime())
unittest.TextTestRunner(verbosity=_verb).run(suite)
+ if testutils.skipped_test_count > 0:
+ ts = " tests"
+ if testutils.skipped_test_count == 1: ts = " test"
+ logging.info("Skipped " + str(testutils.skipped_test_count) + ts)
+ print("Skipped " + str(testutils.skipped_test_count) + ts)
logging.info("*** TEST RUN END : " + time.asctime())
+
diff --git a/tests/pktact.py b/tests/pktact.py
index 7c3fcbb..c2d4a68 100644
--- a/tests/pktact.py
+++ b/tests/pktact.py
@@ -718,6 +718,7 @@
flow_match_test(self, pa_port_map, wildcards=ofp.OFPFW_ALL,
dl_vlan=vid)
+
class AddVLANTag(BaseMatchCase):
"""
Add a VLAN tag to an untagged packet
@@ -726,7 +727,7 @@
new_vid = 2
sup_acts = supported_actions_get(self)
if not(sup_acts & 1<<ofp.OFPAT_SET_VLAN_VID):
- pa_logger.info("Skipping add VLAN tag test")
+ skip_message_emit(self, "Add VLAN tag test")
return
len = 100
@@ -779,7 +780,7 @@
new_vid = 3
sup_acts = supported_actions_get(self)
if not (sup_acts & 1 << ofp.OFPAT_SET_VLAN_VID):
- pa_logger.info("Skipping modify VLAN tag test")
+ skip_message_emit(self, "Modify VLAN tag test")
return
pkt = simple_tcp_packet(dl_vlan_enable=True, dl_vlan=old_vid)
@@ -798,7 +799,7 @@
old_vid = 2
sup_acts = supported_actions_get(self)
if not (sup_acts & 1 << ofp.OFPAT_STRIP_VLAN):
- pa_logger.info("Skipping strip VLAN tag test")
+ skip_message_emit(self, "Strip VLAN tag test")
return
len_w_vid = 104
@@ -835,7 +836,7 @@
def runTest(self):
sup_acts = supported_actions_get(self)
if not (sup_acts & 1 << ofp.OFPAT_SET_DL_SRC):
- pa_logger.info("Skipping ModifyL2Src test")
+ skip_message_emit(self, "ModifyL2Src test")
return
(pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['dl_src'],
@@ -850,7 +851,7 @@
def runTest(self):
sup_acts = supported_actions_get(self)
if not (sup_acts & 1 << ofp.OFPAT_SET_DL_DST):
- pa_logger.info("Skipping ModifyL2Dst test")
+ skip_message_emit(self, "ModifyL2dst test")
return
(pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['dl_dst'],
@@ -865,7 +866,7 @@
def runTest(self):
sup_acts = supported_actions_get(self)
if not (sup_acts & 1 << ofp.OFPAT_SET_NW_SRC):
- pa_logger.info("Skipping ModifyL3Src test")
+ skip_message_emit(self, "ModifyL3Src test")
return
(pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['ip_src'],
@@ -880,7 +881,7 @@
def runTest(self):
sup_acts = supported_actions_get(self)
if not (sup_acts & 1 << ofp.OFPAT_SET_NW_DST):
- pa_logger.info("Skipping ModifyL3Dst test")
+ skip_message_emit(self, "ModifyL3Dst test")
return
(pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['ip_dst'],
@@ -895,7 +896,7 @@
def runTest(self):
sup_acts = supported_actions_get(self)
if not (sup_acts & 1 << ofp.OFPAT_SET_TP_SRC):
- pa_logger.info("Skipping ModifyL4Src test")
+ skip_message_emit(self, "ModifyL4Src test")
return
(pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['tcp_sport'],
@@ -910,7 +911,7 @@
def runTest(self):
sup_acts = supported_actions_get(self)
if not (sup_acts & 1 << ofp.OFPAT_SET_TP_DST):
- pa_logger.info("Skipping ModifyL4Dst test")
+ skip_message_emit(self, "ModifyL4Dst test")
return
(pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['tcp_dport'],
@@ -925,7 +926,7 @@
def runTest(self):
sup_acts = supported_actions_get(self)
if not (sup_acts & 1 << ofp.OFPAT_SET_NW_TOS):
- pa_logger.info("Skipping ModifyTOS test")
+ skip_message_emit(self, "ModifyTOS test")
return
(pkt, exp_pkt, acts) = pkt_action_setup(self, mod_fields=['ip_tos'],
diff --git a/tests/testutils.py b/tests/testutils.py
index 5e57aba..7c14537 100644
--- a/tests/testutils.py
+++ b/tests/testutils.py
@@ -19,6 +19,9 @@
import logging
import types
+global skipped_test_count
+skipped_test_count = 0
+
# Some useful defines
IP_ETHERTYPE = 0x800
TCP_PROTOCOL = 0x6
@@ -665,3 +668,19 @@
return (ingress_pkt, expected_pkt, new_actions)
+
+def skip_message_emit(parent, s):
+ """
+ Print out a 'skipped' message to stderr
+
+ @param s The string to print out to the log file
+ @param parent Must implement config and logger objects
+ """
+ global skipped_test_count
+
+ skipped_test_count += 1
+ parent.logger.info("Skipping: " + s)
+ if parent.config["dbg_level"] < logging.WARNING:
+ sys.stderr.write("(skipped) ")
+ else:
+ sys.stderr.write("(S)")