[asterisk-commits] pabelanger: testsuite/asterisk/trunk r3203 - in /asterisk/trunk: ./ lib/pytho...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 24 13:31:09 CDT 2012


Author: pabelanger
Date: Tue Apr 24 13:31:03 2012
New Revision: 3203

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3203
Log:
Add support for -digiumphones

Additionally, we have added a new 'skip' property for the test-config.yaml file.
This allow you to skip specific asterisk branches.

Modified:
    asterisk/trunk/lib/python/asterisk/TestConfig.py
    asterisk/trunk/lib/python/asterisk/version.py
    asterisk/trunk/runtests.py
    asterisk/trunk/tests/channels/SIP/message_auth/test-config.yaml
    asterisk/trunk/tests/channels/SIP/message_unauth/test-config.yaml

Modified: asterisk/trunk/lib/python/asterisk/TestConfig.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/TestConfig.py?view=diff&rev=3203&r1=3202&r2=3203
==============================================================================
--- asterisk/trunk/lib/python/asterisk/TestConfig.py (original)
+++ asterisk/trunk/lib/python/asterisk/TestConfig.py Tue Apr 24 13:31:03 2012
@@ -82,6 +82,19 @@
             obj = m(self)
             return obj
         return None
+
+
+class SkipTest:
+    def __init__(self, skip):
+        self.name = ""
+        self.met = True
+        if "branch" in skip:
+            self.name = skip["branch"]
+            tmp = "%s-%s-%s" % ("SVN-branch", skip["branch"], "r12345")
+            ast_version = AsteriskVersion()
+            version = AsteriskVersion(tmp)
+            if ast_version.is_same_branch(version):
+                self.met = False
 
 
 class Dependency:
@@ -245,6 +258,7 @@
         self.minversion = None
         self.minversion_check = False
         self.deps = []
+        self.skips = []
         self.tags = []
         self.expectPass = True
         self.excludedTests = []
@@ -322,6 +336,8 @@
                         properties["expectedResult"]
         if "tags" in properties:
             self.tags = properties["tags"]
+        if "skip" in properties:
+            self.skip = properties["skip"]
 
     def __parse_config(self):
         test_config = "%s/test-config.yaml" % self.test_name
@@ -410,6 +426,18 @@
             if d.met is False:
                 self.can_run = False
                 break
+        return self.can_run
+
+    def check_skip(self, ast_version):
+        if not self.config:
+            return False
+
+        self.skips = [
+            SkipTest(s)
+                for s in self.config["properties"].get("skip") or []
+        ]
+
+        self.can_run = all([s.met for s in self.skips if s.met is False])
         return self.can_run
 
     def check_tags(self, requested_tags):

Modified: asterisk/trunk/lib/python/asterisk/version.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/version.py?view=diff&rev=3203&r1=3202&r2=3203
==============================================================================
--- asterisk/trunk/lib/python/asterisk/version.py (original)
+++ asterisk/trunk/lib/python/asterisk/version.py Tue Apr 24 13:31:03 2012
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+
 """Asterisk Version String Handling
 
 This module implements an Asterisk version string parser.  It can also compare
@@ -32,6 +33,7 @@
         version -- The Asterisk version string to parse.
         """
         self.svn = False
+        self.phone = None
 
         if version is not None:
             self.version_str = version
@@ -82,7 +84,8 @@
         self.major = None
         self.minor = None
         self.patch = None
-        self.branch = "branch-%s" % self.concept
+        self.branch = self.__parse_version_branch("branch-%s" % self.concept)
+
         if len(parts) >= 2:
             self.major = parts[1]
         if len(parts) >= 3:
@@ -105,9 +108,13 @@
                 self.version_str
         )
         if match is not None:
-            self.branch = match.group("branch")
+            self.branch = self.__parse_version_branch(match.group("branch"))
             self.revision = match.group("revision")
             self.parent = match.group("parent")
+
+    def __parse_version_branch(self, branch):
+        self.phone = '-digiumphones' in branch
+        return branch.replace("-digiumphones", "")
 
     def __parse_version_patch(self, patch):
         parts = patch.split("-")
@@ -130,6 +137,10 @@
 
         return ret
 
+    def is_same_branch(self, version):
+        if (version.branch == self.branch) and (version.phone == self.phone):
+            return True
+
     @classmethod
     def get_asterisk_version_from_binary(cls):
         """
@@ -244,6 +255,23 @@
         self.assertEqual(str(v), "SVN-branch-10-r12345")
         self.assertEqual(v.branch, "branch-10")
         self.assertEqual(v.revision, "12345")
+        self.assertFalse(v.phone)
+
+    def test_svn_version6(self):
+        v = AsteriskVersion("SVN-branch-1.8-digiumphones-r357808-/branches/1.8")
+        self.assertTrue(v.svn)
+        self.assertEqual(v.branch, "branch-1.8")
+        self.assertEqual(v.revision, "357808")
+        self.assertEqual(v.parent, "/branches/1.8")
+        self.assertTrue(v.phone)
+
+    def test_svn_version7(self):
+        v = AsteriskVersion("SVN-branch-10-digiumphones-r365402-/branches/10")
+        self.assertTrue(v.svn)
+        self.assertEqual(v.branch, "branch-10")
+        self.assertEqual(v.revision, "365402")
+        self.assertEqual(v.parent, "/branches/10")
+        self.assertTrue(v.phone)
 
     def test_cmp(self):
         v1 = AsteriskVersion("1.4")
@@ -355,6 +383,7 @@
         v2 = AsteriskVersion("SVN-branch-1.8-r360138M")
         self.assertTrue(v1 < v2)
 
+
 def main():
     unittest.main()
 

Modified: asterisk/trunk/runtests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/runtests.py?view=diff&rev=3203&r1=3202&r2=3203
==============================================================================
--- asterisk/trunk/runtests.py (original)
+++ asterisk/trunk/runtests.py Tue Apr 24 13:31:03 2012
@@ -140,7 +140,8 @@
     def __check_can_run(self, ast_version):
         """Check tags and dependencies in the test config."""
         if self.test_config.check_deps(ast_version) and \
-                self.test_config.check_tags(self.options.tags):
+                self.test_config.check_tags(self.options.tags) and \
+                self.test_config.check_skip(ast_version):
             self.can_run = True
 
     def __parse_run_output(self, output):
@@ -230,6 +231,9 @@
                 else:
                     print "      --> Dependency: %s -- Met: %s" % (d.name,
                              str(d.met))
+            for s in t.test_config.skips:
+                    print "      --> Skip: %s -- Met: %s" % (s.name, str(s.met))
+
             i += 1
 
     def run(self):
@@ -240,7 +244,6 @@
                 if t.test_config.skip is not None:
                     print "--> %s ... skipped '%s'" % (t.test_name, t.test_config.skip)
                     continue
-
                 print "--> Cannot run test '%s'" % t.test_name
                 print "--- --> Minimum Version: %s (%s)" % \
                     (str(t.test_config.minversion), str(t.test_config.minversion_check))
@@ -250,6 +253,8 @@
                 print "--- --> Tags: %s" % (t.test_config.tags)
                 for d in t.test_config.deps:
                     print "--- --> Dependency: %s - %s" % (d.name, str(d.met))
+                for s in t.test_config.skips:
+                    print "--- --> Skip: %s - %s" % (s.name, str(s.met))
                 print
                 continue
             if self.global_config != None:

Modified: asterisk/trunk/tests/channels/SIP/message_auth/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/message_auth/test-config.yaml?view=diff&rev=3203&r1=3202&r2=3203
==============================================================================
--- asterisk/trunk/tests/channels/SIP/message_auth/test-config.yaml (original)
+++ asterisk/trunk/tests/channels/SIP/message_auth/test-config.yaml Tue Apr 24 13:31:03 2012
@@ -4,7 +4,9 @@
         'Send Asterisk a MESSAGE and wait for Asterisk to send it back with authentication.'
 
 properties:
-    minversion: '10'
+    minversion : '1.8'
+    skip:
+        - branch : '1.8'
     dependencies:
         - sipp :
             version : 'v3.0'

Modified: asterisk/trunk/tests/channels/SIP/message_unauth/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/SIP/message_unauth/test-config.yaml?view=diff&rev=3203&r1=3202&r2=3203
==============================================================================
--- asterisk/trunk/tests/channels/SIP/message_unauth/test-config.yaml (original)
+++ asterisk/trunk/tests/channels/SIP/message_unauth/test-config.yaml Tue Apr 24 13:31:03 2012
@@ -4,8 +4,10 @@
         'Send Asterisk a MESSAGE and wait for Asterisk to send it back.'
 
 properties:
-    minversion: '10'
+    minversion: '1.8'
+    skip:
+        - branch : '1.8'
     dependencies:
         - app : 'sipp'
     tags:
-        - SIP
+        - SIP




More information about the asterisk-commits mailing list