[asterisk-commits] mnicholson: testsuite/asterisk/trunk r819 - in /asterisk/trunk/asttest: lib/l...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Nov 2 13:12:35 CDT 2010


Author: mnicholson
Date: Tue Nov  2 13:12:31 2010
New Revision: 819

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=819
Log:
Updated asterisk:cli() to return nil and and error if asterisk -rx does not return 0.  Also updated self test to test for this.

Modified:
    asterisk/trunk/asttest/lib/lua/astlib.lua
    asterisk/trunk/asttest/self-tests/asterisk_cli/test.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=819&r1=818&r2=819
==============================================================================
--- asterisk/trunk/asttest/lib/lua/astlib.lua (original)
+++ asterisk/trunk/asttest/lib/lua/astlib.lua Tue Nov  2 13:12:31 2010
@@ -109,6 +109,14 @@
 	local res, err = p:wait(300000)
 	if not res then
 		return res, err
+	end
+
+	if res ~= 0 then
+		local output = p.stdout:read("*a")
+		if not output then
+			return nil, "error connecting to asterisk cli"
+		end
+		return nil, output
 	end
 
 	return p.stdout:read("*a")
@@ -125,26 +133,24 @@
 	for _=1,10 do
 		local err
 		booted, err = self:cli("core waitfullybooted")
-		if not booted then
-			if err then
-				error("error waiting for asterisk to fully boot: " .. err)
-			else
-				error("error waiting for asterisk to fully boot")
-			end
-		end
-
+		
 		if #output ~= 0 then
 			output = output .. "=====\n"
 		end
 
-		output = output .. booted
-
-		if booted:find("fully booted") then
-			break
-		end
+		if booted then
+			output = output .. booted
+
+			if booted:find("fully booted") then
+				break
+			end
+		else
+			output = output .. err
+		end
+
 		posix.usleep(500000)
 	end
-	if not booted:find("fully booted") then
+	if booted and not booted:find("fully booted") then
 		print("error waiting for asterisk to fully boot: " .. booted)
 		print("checking to see if asterisk is still running")
 		local res, err = proc.perror(self:wait(1000))

Modified: 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=diff&rev=819&r1=818&r2=819
==============================================================================
--- asterisk/trunk/asttest/self-tests/asterisk_cli/test.lua (original)
+++ asterisk/trunk/asttest/self-tests/asterisk_cli/test.lua Tue Nov  2 13:12:31 2010
@@ -5,8 +5,8 @@
 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'")
+version, err = a:cli("core show version")
+fail_if(not version, "error running asterisk -rx 'core show version': " .. tostring(err))
 print(version)
 
 res, err = proc.perror(a:term_or_kill())
@@ -17,5 +17,7 @@
 	fail("error, asterisk exited with status " .. res)
 end
 
+fail_if(a:cli("core show version"), "some how 'core show version' succeeded when asterisk was not running")
+
 pass("asterisk exited with status " .. res)
 




More information about the asterisk-commits mailing list