Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
tests: verify policer stats in punt tests
[vpp.git]
/
test
/
framework.py
diff --git
a/test/framework.py
b/test/framework.py
index
ba5f401
..
7ab5b45
100644
(file)
--- a/
test/framework.py
+++ b/
test/framework.py
@@
-7,6
+7,7
@@
import sys
import os
import select
import signal
import os
import select
import signal
+import subprocess
import unittest
import tempfile
import time
import unittest
import tempfile
import time
@@
-20,6
+21,7
@@
from threading import Thread, Event
from inspect import getdoc, isclass
from traceback import format_exception
from logging import FileHandler, DEBUG, Formatter
from inspect import getdoc, isclass
from traceback import format_exception
from logging import FileHandler, DEBUG, Formatter
+from enum import Enum
import scapy.compat
from scapy.packet import Raw
import scapy.compat
from scapy.packet import Raw
@@
-40,19
+42,6
@@
from scapy.layers.inet import IPerror, TCPerror, UDPerror, ICMPerror
from scapy.layers.inet6 import ICMPv6DestUnreach, ICMPv6EchoRequest
from scapy.layers.inet6 import ICMPv6EchoReply
from scapy.layers.inet6 import ICMPv6DestUnreach, ICMPv6EchoRequest
from scapy.layers.inet6 import ICMPv6EchoReply
-if os.name == 'posix' and sys.version_info[0] < 3:
- # using subprocess32 is recommended by python official documentation
- # @ https://docs.python.org/2/library/subprocess.html
- import subprocess32 as subprocess
-else:
- import subprocess
-
-# Python2/3 compatible
-try:
- input = raw_input
-except NameError:
- pass
-
logger = logging.getLogger(__name__)
# Set up an empty logger for the testcase that can be overridden as necessary
logger = logging.getLogger(__name__)
# Set up an empty logger for the testcase that can be overridden as necessary
@@
-231,14
+220,6
@@
def _running_gcov_tests():
running_gcov_tests = _running_gcov_tests()
running_gcov_tests = _running_gcov_tests()
-def _running_on_centos():
- os_id = os.getenv("OS_ID", "")
- return True if "centos" in os_id.lower() else False
-
-
-running_on_centos = _running_on_centos()
-
-
class KeepAliveReporter(object):
"""
Singleton object which reports test start to parent process
class KeepAliveReporter(object):
"""
Singleton object which reports test start to parent process
@@
-275,6
+256,22
@@
class KeepAliveReporter(object):
self.pipe.send((desc, test.vpp_bin, test.tempdir, test.vpp.pid))
self.pipe.send((desc, test.vpp_bin, test.tempdir, test.vpp.pid))
+class TestCaseTag(Enum):
+ RUN_SOLO = 1
+
+
+def create_tag_decorator(e):
+ def decorator(cls):
+ try:
+ cls.test_tags.append(e)
+ except AttributeError:
+ cls.test_tags = [e]
+ return cls
+ return decorator
+
+tag_run_solo = create_tag_decorator(TestCaseTag.RUN_SOLO)
+
+
class VppTestCase(unittest.TestCase):
"""This subclass is a base class for VPP test cases that are implemented as
classes. It provides methods to create and run test case.
class VppTestCase(unittest.TestCase):
"""This subclass is a base class for VPP test cases that are implemented as
classes. It provides methods to create and run test case.
@@
-299,10
+296,19
@@
class VppTestCase(unittest.TestCase):
return 0
@classmethod
return 0
@classmethod
- def force_solo(cls):
- """ if the test case class is timing-sensitive - return true """
+ def has_tag(cls, tag):
+ """ if the test case has a given tag - return true """
+ try:
+ return tag in cls.test_tags
+ except AttributeError:
+ pass
return False
return False
+ @classmethod
+ def is_tagged_run_solo(cls):
+ """ if the test case class is timing-sensitive - return true """
+ return cls.has_tag(TestCaseTag.RUN_SOLO)
+
@classmethod
def instance(cls):
"""Return the instance of this testcase"""
@classmethod
def instance(cls):
"""Return the instance of this testcase"""
@@
-419,6
+425,8
@@
class VppTestCase(unittest.TestCase):
"plugins",
"{", "plugin", "dpdk_plugin.so", "{", "disable",
"}", "plugin", "rdma_plugin.so", "{", "disable",
"plugins",
"{", "plugin", "dpdk_plugin.so", "{", "disable",
"}", "plugin", "rdma_plugin.so", "{", "disable",
+ "}", "plugin", "lisp_unittest_plugin.so", "{",
+ "enable",
"}", "plugin", "unittest_plugin.so", "{", "enable",
"}"] + cls.extra_vpp_plugin_config + ["}", ]
"}", "plugin", "unittest_plugin.so", "{", "enable",
"}"] + cls.extra_vpp_plugin_config + ["}", ]
@@
-1422,7
+1430,7
@@
class VppTestResult(unittest.TestResult):
raise Exception("No doc string for test '%s'" % test.id())
test_title = test_doc.splitlines()[0]
test_title_colored = colorize(test_title, GREEN)
raise Exception("No doc string for test '%s'" % test.id())
test_title = test_doc.splitlines()[0]
test_title_colored = colorize(test_title, GREEN)
- if test.
force
_solo():
+ if test.
is_tagged_run
_solo():
# long live PEP-8 and 80 char width limitation...
c = YELLOW
test_title_colored = colorize("SOLO RUN: " + test_title, c)
# long live PEP-8 and 80 char width limitation...
c = YELLOW
test_title_colored = colorize("SOLO RUN: " + test_title, c)