[svn-commits] mmichelson: testsuite/asterisk/trunk r5150 - in /asterisk/trunk: ./ lib/pytho...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jun 19 17:22:53 CDT 2014


Author: mmichelson
Date: Thu Jun 19 17:22:47 2014
New Revision: 5150

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=5150
Log:
Add memory usage pre- and post-conditions to the testsuite.

This allows for memory usage of a test to be checked before
and after execution. If a configured delta is exceeded, then
the test will fail due to a perceived memory leak.

Patch contributed by Ben Ford (License #6580)
Review: https://reviewboard.asterisk.org/r/3476


Modified:
    asterisk/trunk/lib/python/asterisk/test_case.py
    asterisk/trunk/lib/python/asterisk/test_conditions.py
    asterisk/trunk/test-config.yaml

Modified: asterisk/trunk/lib/python/asterisk/test_case.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/test_case.py?view=diff&rev=5150&r1=5149&r2=5150
==============================================================================
--- asterisk/trunk/lib/python/asterisk/test_case.py (original)
+++ asterisk/trunk/lib/python/asterisk/test_case.py Thu Jun 19 17:22:47 2014
@@ -197,24 +197,14 @@
         for cond in conditions:
             # cond is a 3-tuple of object, pre-post type, and related name
             obj, pre_post_type, related_name = cond
-            if (related_name == ""):
-                if (pre_post_type == "PRE"):
-                    self.condition_controller.register_pre_test_condition(obj)
-                elif (pre_post_type == "POST"):
-                    self.condition_controller.register_post_test_condition(obj)
-                else:
-                    msg = "Unknown condition type [%s]" % pre_post_type
-                    LOGGER.warning(msg)
-        for cond in conditions:
-            if (related_name != ""):
-                if (pre_post_type == "POST"):
-                    self.condition_controller.register_post_test_condition(
-                                                obj,
-                                                related_name)
-                else:
-                    msg = ("Unsupported type [%s] with related condition %s" %
-                           (pre_post_type, related_name))
-                    LOGGER.warning(msg)
+            if (pre_post_type == "PRE"):
+               self.condition_controller.register_pre_test_condition(obj)
+            elif (pre_post_type == "POST"):
+                self.condition_controller.register_post_test_condition(obj,
+                                                                       related_name)
+            else:
+                msg = "Unknown condition type [%s]" % pre_post_type
+                LOGGER.warning(msg)
         self.condition_controller.register_observer(
                                     self.handle_condition_failure,
                                     'Failed')

Modified: asterisk/trunk/lib/python/asterisk/test_conditions.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/test_conditions.py?view=diff&rev=5150&r1=5149&r2=5150
==============================================================================
--- asterisk/trunk/lib/python/asterisk/test_conditions.py (original)
+++ asterisk/trunk/lib/python/asterisk/test_conditions.py Thu Jun 19 17:22:47 2014
@@ -91,6 +91,7 @@
         Keyword arguments:
         pre_test_condition The pre-test condition to check
         """
+        LOGGER.info('Registered pre test condition %s' % str(pre_test_condition))
         self._prechecks.append((pre_test_condition, None))
 
     def register_post_test_condition(self, post_test_condition,
@@ -118,7 +119,9 @@
             if (matching_pre_condition == None):
                 err_msg = ("No pre condition found matching %s" %
                            matching_pre_condition_name)
-                raise ValueError(err_msg)
+                LOGGER.error(err_msg)
+                return
+        LOGGER.info('Registered post test condition %s' % str(post_test_condition))
         self._postchecks.append((post_test_condition, matching_pre_condition))
 
     def register_observer(self, callback_method, test_filter=""):

Modified: asterisk/trunk/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/test-config.yaml?view=diff&rev=5150&r1=5149&r2=5150
==============================================================================
--- asterisk/trunk/test-config.yaml (original)
+++ asterisk/trunk/test-config.yaml Thu Jun 19 17:22:47 2014
@@ -51,6 +51,13 @@
                     typename: 'sip_channel_test_condition.SipChannelTestCondition'
                 post:
                     typename: 'sip_channel_test_condition.SipChannelTestCondition'
+            -
+                name: 'memory'
+                pre:
+                    typename: 'memory_test_condition.MemoryPreTestCondition'
+                post:
+                    typename: 'memory_test_condition.MemoryPostTestCondition'
+                    related-type: 'memory_test_condition.MemoryPreTestCondition'
 
 # Exclude all long-running tests (greater than one minute)
 config-fast:
@@ -96,6 +103,7 @@
             - name: 'file-descriptors'
             - name: 'channels'
             - name: 'sip-channels'
+            - name: 'memory'
 
 config-specific-version:
     properties:




More information about the svn-commits mailing list