[svn-commits] mnicholson: testsuite/asterisk/trunk r356 - in /asterisk/trunk/asttest: lib/l...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Jun 7 10:24:04 CDT 2010
Author: mnicholson
Date: Mon Jun 7 10:24:01 2010
New Revision: 356
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=356
Log:
Added the asterisk.cli() function for executing CLI commands via asterisk -rx on a running asterisk instance.
Added:
asterisk/trunk/asttest/self-tests/asterisk_cli/
asterisk/trunk/asttest/self-tests/asterisk_cli/test.lua (with props)
Modified:
asterisk/trunk/asttest/lib/lua/astlib.lua
Modified: asterisk/trunk/asttest/lib/lua/astlib.lua
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/asttest/lib/lua/astlib.lua?view=diff&rev=356&r1=355&r2=356
==============================================================================
--- asterisk/trunk/asttest/lib/lua/astlib.lua (original)
+++ asterisk/trunk/asttest/lib/lua/astlib.lua Mon Jun 7 10:24:01 2010
@@ -50,6 +50,15 @@
"-C", self.asterisk_conf
)
rawset(self, "proc", p)
+end
+
+function asterisk:cli(command)
+ local p = proc.exec_io(self.asterisk_binary,
+ "-r", "-x", command,
+ "-C", self.asterisk_conf
+ )
+
+ return p.stdout:read("*a")
end
function asterisk:spawn()
Added: asterisk/trunk/asttest/self-tests/asterisk_cli/test.lua
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/asttest/self-tests/asterisk_cli/test.lua?view=auto&rev=356
==============================================================================
--- asterisk/trunk/asttest/self-tests/asterisk_cli/test.lua (added)
+++ asterisk/trunk/asttest/self-tests/asterisk_cli/test.lua Mon Jun 7 10:24:01 2010
@@ -1,0 +1,21 @@
+-- test spawning asterisk
+
+skip_if(not ast.exists(), "asterisk not found")
+
+a = ast.new()
+a:spawn()
+
+version = a:cli("core show version")
+fail_if(not version, "error running asterisk -rx 'core show version' or error reading the output of asterisk -rx 'core show version'")
+print(version)
+
+res, err = proc.perror(a:term_or_kill())
+
+if res == nil then
+ fail("error running asterisk")
+elseif res ~= 0 then
+ fail("error, asterisk exited with status " .. res)
+end
+
+pass("asterisk exited with status " .. res)
+
Propchange: asterisk/trunk/asttest/self-tests/asterisk_cli/test.lua
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/trunk/asttest/self-tests/asterisk_cli/test.lua
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/trunk/asttest/self-tests/asterisk_cli/test.lua
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the svn-commits
mailing list