[asterisk-commits] russell: testsuite/asterisk/trunk r573 - in /asterisk/trunk: ./ lib/python/as...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jul 24 14:35:19 CDT 2010


Author: russell
Date: Sat Jul 24 14:35:13 2010
New Revision: 573

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=573
Log:
Change test output handling in runtests.  Make Asterisk.cli_exec() return command output.

Modified:
    asterisk/trunk/lib/python/asterisk/asterisk.py
    asterisk/trunk/runtests.py

Modified: asterisk/trunk/lib/python/asterisk/asterisk.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/asterisk.py?view=diff&rev=573&r1=572&r2=573
==============================================================================
--- asterisk/trunk/lib/python/asterisk/asterisk.py (original)
+++ asterisk/trunk/lib/python/asterisk/asterisk.py Sat Jul 24 14:35:13 2010
@@ -171,12 +171,24 @@
         Example Usage:
         asterisk.cli_exec("core set verbose 10")
         """
-        cmd = 'asterisk -C %s -rx "%s"' % \
-                (os.path.join(self.astetcdir, "asterisk.conf"), cli_cmd)
+        cmd = [
+            "asterisk",
+            "-C", "%s" % os.path.join(self.astetcdir, "asterisk.conf"),
+            "-rx", "%s" % cli_cmd
+        ]
         print "Executing %s ..." % cmd
-        process = subprocess.Popen(cmd, shell=True)
-        if blocking:
-            process.wait()
+
+        if not blocking:
+            process = subprocess.Popen(cmd)
+            return ""
+
+        process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+        output = ""
+        for l in process.stdout.readlines():
+            print l,
+            output += l
+        process.wait()
+        return output
 
     def __gen_ast_conf(self, ast_conf, dir_cat):
         for (var, val) in dir_cat.options:

Modified: asterisk/trunk/runtests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/runtests.py?view=diff&rev=573&r1=572&r2=573
==============================================================================
--- asterisk/trunk/runtests.py (original)
+++ asterisk/trunk/runtests.py Sat Jul 24 14:35:13 2010
@@ -141,11 +141,16 @@
         ]
         if os.path.exists(cmd[0]) and os.access(cmd[0], os.X_OK):
             print "Running %s ..." % cmd
+            try:
+                f = open("tests/%s/test-output.txt" % self.test_name, "w")
+            except IOError:
+                print "FAILURE: Failed to open file for test output"
+                return
             p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
-            p2 = subprocess.Popen(["tee", "tests/%s/test-output.txt" %
-                                   self.test_name], stdin=p.stdout)
+            for l in p.stdout.readlines():
+                f.write(l)
+                print l,
             p.wait()
-            p2.wait()
             self.passed = p.returncode == 0
         else:
             print "FAILED TO EXECUTE %s, it must exist and be executable" % cmd




More information about the asterisk-commits mailing list