[asterisk-commits] pabelanger: branch pabelanger/testClass r1192 - in /asterisk/team/pabelanger/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 15 23:48:45 UTC 2010


Author: pabelanger
Date: Wed Dec 15 17:48:42 2010
New Revision: 1192

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1192
Log:
Add option to run Asterisk under valgrind

Modified:
    asterisk/team/pabelanger/testClass/lib/python/asterisk/TestCase.py
    asterisk/team/pabelanger/testClass/lib/python/asterisk/asterisk.py
    asterisk/team/pabelanger/testClass/runtests.py

Modified: asterisk/team/pabelanger/testClass/lib/python/asterisk/TestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/testClass/lib/python/asterisk/TestCase.py?view=diff&rev=1192&r1=1191&r2=1192
==============================================================================
--- asterisk/team/pabelanger/testClass/lib/python/asterisk/TestCase.py (original)
+++ asterisk/team/pabelanger/testClass/lib/python/asterisk/TestCase.py Wed Dec 15 17:48:42 2010
@@ -32,6 +32,9 @@
                 help="Asterisk version string")
         parser.add_option("--test-name", dest="test_name",
                 help="Test name")
+        parser.add_option("--valgrind", action="store_true",
+                dest="valgrind", default=False,
+                help="Run Asterisk under valgrind.")
 
         (self.options, args) = parser.parse_args(argv)
         self.options.base = self.options.test_name.lstrip("tests/")
@@ -48,6 +51,7 @@
         for c in range(count):
             print "Creating Asterisk instance %d ..." % (c + 1)
             self.ast.append(Asterisk(base=self.options.base))
+            self.ast[c].valgrind = self.options.valgrind
             # Copy shared config files
             self.ast[c].install_configs("%s/configs" %
                     (self.options.test_name))

Modified: asterisk/team/pabelanger/testClass/lib/python/asterisk/asterisk.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/testClass/lib/python/asterisk/asterisk.py?view=diff&rev=1192&r1=1191&r2=1192
==============================================================================
--- asterisk/team/pabelanger/testClass/lib/python/asterisk/asterisk.py (original)
+++ asterisk/team/pabelanger/testClass/lib/python/asterisk/asterisk.py Wed Dec 15 17:48:42 2010
@@ -61,6 +61,7 @@
         self.astetcdir = "/etc/asterisk"
         self.ast_binary = utils.which("asterisk") or "/usr/sbin/asterisk"
         self.host = host
+        self.valgrind = False
 
         # Find the system installed asterisk.conf
         ast_confs = [
@@ -113,6 +114,8 @@
             "-f", "-g", "-q", "-m", "-n",
             "-C", "%s" % os.path.join(self.astetcdir, "asterisk.conf")
         ]
+        if self.valgrind:
+            cmd.insert(0, "valgrind")
         try:
             self.process = subprocess.Popen(cmd)
         except OSError:

Modified: asterisk/team/pabelanger/testClass/runtests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/testClass/runtests.py?view=diff&rev=1192&r1=1191&r2=1192
==============================================================================
--- asterisk/team/pabelanger/testClass/runtests.py (original)
+++ asterisk/team/pabelanger/testClass/runtests.py Wed Dec 15 17:48:42 2010
@@ -99,12 +99,13 @@
         return False
 
 class TestConfig:
-    def __init__(self, test_name, ast_version):
+    def __init__(self, test_name, ast_version, options):
         self.can_run = True
         self.did_run = False
         self.time = 0.0
         self.test_name = test_name
         self.ast_version = ast_version
+        self.options = options
         self.skip = None
         self.config = None
         self.summary = None
@@ -126,6 +127,8 @@
             "-v", str(self.ast_version),
             "--test-name", str(self.test_name)
         ]
+        if self.options.valgrind:
+            cmd.append("--valgrind")
         if os.path.exists(cmd[0]) and os.access(cmd[0], os.X_OK):
             print "Running %s ..." % cmd
             try:
@@ -260,7 +263,7 @@
             for val in t:
                 path = "%s/%s" % (test_dir, t[val])
                 if val == "test":
-                    tests.append(TestConfig(path, ast_version))
+                    tests.append(TestConfig(path, ast_version, self.options))
                 elif val == "dir":
                     tests += self._parse_test_yaml(path, ast_version)
 
@@ -375,6 +378,9 @@
     parser.add_option("-t", "--test",
             dest="test",
             help="Run a single specified test instead of all tests.")
+    parser.add_option("--valgrind", action="store_true",
+            dest="valgrind", default=False,
+            help="Run Asterisk under valgrind.")
     (options, args) = parser.parse_args(argv)
 
     # Check to see if this has been executed within a sub directory of an




More information about the asterisk-commits mailing list