[svn-commits] mmichelson: branch mmichelson/srv_sip_outbound r204 - /asterisk/team/mmichels...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Apr 6 10:52:35 CDT 2010


Author: mmichelson
Date: Tue Apr  6 10:52:33 2010
New Revision: 204

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=204
Log:
Add test.lua file.

Currently, this has a bunch of copied and pasted code from
the RFC2833 DTMF detection test. It has been modified slightly.

Next step is to start adding some sip.conf files.


Added:
    asterisk/team/mmichelson/srv_sip_outbound/tests/sip_outbound_address/test.lua   (with props)

Added: asterisk/team/mmichelson/srv_sip_outbound/tests/sip_outbound_address/test.lua
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mmichelson/srv_sip_outbound/tests/sip_outbound_address/test.lua?view=auto&rev=204
==============================================================================
--- asterisk/team/mmichelson/srv_sip_outbound/tests/sip_outbound_address/test.lua (added)
+++ asterisk/team/mmichelson/srv_sip_outbound/tests/sip_outbound_address/test.lua Tue Apr  6 10:52:33 2010
@@ -1,0 +1,77 @@
+function sipp_exec(scenario, name, local_port)
+	return proc.exec_io("sipp",
+	"127.0.0.1",
+	"-m", "1",
+	"-sf", scenario,
+	"-i", "127.0.0.1",
+	"-p", local_port,
+	"-timeout", "30",
+	"-trace_err"
+	)
+end
+
+function sipp_exec_and_wait(scenario, name, local_port)
+	return sipp_check_error(sipp_exec(scenario, name, local_port), scenario)
+end
+
+function sipp_check_error(p, scenario)
+	local res, err = p:wait()
+
+	if not res then error(err) end
+	if res ~= 0 then
+		error("error while executing " .. scenario .. " sipp scenario (sipp exited with status " .. res .. ")\n" .. p.stderr:read("*a"))
+	end
+
+	return res, err
+end
+
+function varset_event_one(event)
+	if (event["Variable"] == "READRESULT") then
+		if (event["Value"] ~= "1") then
+			fail("DTMF not detected properly. Expected '1' but received " .. event["Value"])
+		end
+	end
+end
+
+function varset_event_two(event)
+	if (event["Variable"] == "READRESULT") then
+		if (event["Value"] ~= "2") then
+			fail("DTMF not detected properly. Expected '2' but received " .. event["Value"])
+		end
+	end
+end
+
+function manager_setup(a)
+	m,err = a:manager_connect()
+	if not m then
+		fail("error connecting to asterisk: " .. err)
+	end
+
+	login = ast.manager.action:new("login")
+	login["Username"] = "asttest"
+	login["Secret"] = "asttest"
+
+	local r = m(login)
+	if not r then
+		fail("error logging in to the manager: " .. err)
+	end
+
+	if r["Response"] ~= "Success" then
+		fail("error authenticating: " .. r["Message"])
+	end
+end
+
+function test_call(scenario, handler, name, local_port)
+	m:register_event("VarSet", handler)
+	local t1 = sipp_exec(scenario, name, local_port)
+
+	--wait for everything to finish
+	sipp_check_error(t1, scenario)
+	posix.sleep(1)
+	local res, err = m:pump_messages()
+	if not res then
+		fail("error pumping manager messages: " .. err)
+	end
+	m:process_events()
+	m:unregister_event("VarSet", handler)
+end

Propchange: asterisk/team/mmichelson/srv_sip_outbound/tests/sip_outbound_address/test.lua
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/mmichelson/srv_sip_outbound/tests/sip_outbound_address/test.lua
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/mmichelson/srv_sip_outbound/tests/sip_outbound_address/test.lua
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the svn-commits mailing list