[mod_sofia] Add a unit-test checking that sofia-sip does not leak when a profile fails to start.

This commit is contained in:
Andrey Volk 2021-08-11 17:34:46 +03:00
parent 16370ddd7c
commit 8a40ba20bd
4 changed files with 173 additions and 2 deletions

View File

@ -2,3 +2,4 @@ test/Makefile
test/Makefile.in
test/freeswitch.xml.fsxml.tmp
test/test_sofia_funcs
test/test_nuafail

View File

@ -15,7 +15,7 @@ mod_sofia_la_SOURCES =
mod_sofia_la_LIBADD = $(switch_builddir)/libfreeswitch.la libsofiamod.la
mod_sofia_la_LDFLAGS = -avoid-version -module -no-undefined -shared $(SOFIA_SIP_LIBS) $(STIRSHAKEN_LIBS)
noinst_PROGRAMS = test/test_sofia_funcs
noinst_PROGRAMS = test/test_sofia_funcs test/test_nuafail
test_test_sofia_funcs_SOURCES = test/test_sofia_funcs.c
test_test_sofia_funcs_CFLAGS = $(AM_CFLAGS) $(SOFIA_SIP_CFLAGS) $(STIRSHAKEN_CFLAGS) -DSWITCH_TEST_BASE_DIR_FOR_CONF=\"${abs_builddir}/test\" -DSWITCH_TEST_BASE_DIR_OVERRIDE=\"${abs_builddir}/test\"
@ -25,10 +25,19 @@ endif
test_test_sofia_funcs_LDFLAGS = $(AM_LDFLAGS) -avoid-version -no-undefined $(freeswitch_LDFLAGS) $(switch_builddir)/libfreeswitch.la $(CORE_LIBS) $(APR_LIBS) $(STIRSHAKEN_LIBS)
test_test_sofia_funcs_LDADD = libsofiamod.la $(SOFIA_SIP_LIBS)
TESTS = test/test_sofia_funcs.sh
test_test_nuafail_SOURCES = test/test_nuafail.c
test_test_nuafail_CFLAGS = $(AM_CFLAGS) $(SOFIA_SIP_CFLAGS) $(STIRSHAKEN_CFLAGS) -DSWITCH_TEST_BASE_DIR_FOR_CONF=\"${abs_builddir}/test\" -DSWITCH_TEST_BASE_DIR_OVERRIDE=\"${abs_builddir}/test\"
if HAVE_STIRSHAKEN
test_test_nuafail_CFLAGS += -DHAVE_STIRSHAKEN
endif
test_test_nuafail_LDFLAGS = $(AM_LDFLAGS) -avoid-version -no-undefined $(freeswitch_LDFLAGS) $(switch_builddir)/libfreeswitch.la $(CORE_LIBS) $(APR_LIBS) $(STIRSHAKEN_LIBS)
test_test_nuafail_LDADD = libsofiamod.la $(SOFIA_SIP_LIBS)
TESTS = test/test_sofia_funcs.sh test/test_nuafail
if ISMAC
mod_sofia_la_LDFLAGS += -framework CoreFoundation -framework SystemConfiguration
test_test_sofia_funcs_LDFLAGS += -framework CoreFoundation -framework SystemConfiguration
test_test_nuafail_LDFLAGS += -framework CoreFoundation -framework SystemConfiguration
endif

View File

@ -0,0 +1,103 @@
<?xml version="1.0"?>
<document type="freeswitch/xml">
<X-PRE-PROCESS cmd="exec-set" data="test=echo 1234"/>
<X-PRE-PROCESS cmd="set" data="default_password=$${test}"/>
<X-PRE-PROCESS cmd="set" data="core_video_blank_image=$${conf_dir}/freeswitch-logo.png"/>
<section name="configuration" description="Various Configuration">
<configuration name="modules.conf" description="Modules">
<modules>
<load module="mod_sofia"/>
<load module="mod_console"/>
<load module="mod_loopback"/>
<load module="mod_commands"/>
<load module="mod_dptools"/>
<load module="mod_dialplan_xml"/>
<load module="mod_tone_stream"/>
<load module="mod_commands"/>
<load module="mod_sndfile"/>
</modules>
</configuration>
<configuration name="console.conf" description="Console Logger">
<mappings>
<map name="all" value="console,debug,info,notice,warning,err,crit,alert"/>
</mappings>
<settings>
<param name="colorize" value="true"/>
<param name="loglevel" value="debug"/>
</settings>
</configuration>
<configuration name="timezones.conf" description="Timezones">
<timezones>
<zone name="GMT" value="GMT0" />
</timezones>
</configuration>
<configuration name="sofia.conf" description="SofiaSIP">
<profiles>
<profile name="internal">
<gateways>
</gateways>
<domains>
<domain name="all" alias="false" parse="true"/>
</domains>
<settings>
<param name="debug" value="1"/>
<param name="shutdown-on-fail" value="true"/>
<param name="p-asserted-id-parse" value="verbatim"/>
<param name="username" value="SignalWire-STACK"/>
<param name="user-agent-string" value="SignalWire STACK Unit Test"/>
<param name="sip-trace" value="yes"/>
<param name="sip-capture" value="no"/>
<param name="rfc2833-pt" value="101"/>
<param name="sip-port" value="61069"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="dtmf-duration" value="2000"/>
<param name="inbound-codec-prefs" value="PCMU"/>
<param name="outbound-codec-prefs" value="PCMU"/>
<param name="rtp-timer-name" value="soft"/>
<param name="local-network-acl" value="localnet.auto"/>
<param name="manage-presence" value="false"/>
<param name="inbound-codec-negotiation" value="generous"/>
<param name="nonce-ttl" value="60"/>
<param name="inbound-late-negotiation" value="true"/>
<param name="inbound-zrtp-passthru" value="false"/>
<param name="rtp-ip" value="170.0.0.1"/>
<param name="sip-ip" value="170.0.0.1"/>
<param name="ext-rtp-ip" value="170.0.0.1"/>
<param name="ext-sip-ip" value="170.0.0.1"/>
<param name="rtp-timeout-sec" value="300"/>
<param name="rtp-hold-timeout-sec" value="1800"/>
<param name="session-timeout" value="600"/>
<param name="minimum-session-expires" value="90"/>
<param name="tls" value="false"/>
</settings>
</profile>
</profiles>
</configuration>
<configuration name="switch.conf" description="Switch">
<param name="rtp-start-port" value="20000"/>
<param name="rtp-end-port" value="30000"/>
<param name="threaded-system-exec" value="true"/>
</configuration>
</section>
<section name="dialplan" description="Regex/XML Dialplan">
<context name="default">
<extension name="one">
<condition field="destination_number" expression="^\+15553332900$">
<action application="set" data="absolute_codec_string=PCMU@20i"/>
<action application="info"/>
<action application="answer"/>
<action application="park""/>
</condition>
</extension>
</context>
</section>
</document>

View File

@ -0,0 +1,58 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2021, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Andrey Volk <andrey@signalwire.com>
*
*
* test_nuafail.c - Checks if sofia-sip leaks on profile start fail
*
*/
#include <switch.h>
#include <test/switch_test.h>
FST_CORE_EX_BEGIN("./conf-nuafail", SCF_VG | SCF_USE_SQL)
{
FST_MODULE_BEGIN(mod_sofia, nuafail)
{
FST_SETUP_BEGIN()
{
fst_requires_module("mod_sofia");
}
FST_SETUP_END()
FST_TEARDOWN_BEGIN()
{
}
FST_TEARDOWN_END()
FST_TEST_BEGIN(do_nothing)
{
}
FST_TEST_END()
}
FST_MODULE_END()
}
FST_CORE_END()