From 8a40ba20bd77a612c29e2f152367ddc73b0c03aa Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Wed, 11 Aug 2021 17:34:46 +0300 Subject: [PATCH] [mod_sofia] Add a unit-test checking that sofia-sip does not leak when a profile fails to start. --- src/mod/endpoints/mod_sofia/.gitignore | 1 + src/mod/endpoints/mod_sofia/Makefile.am | 13 ++- .../test/conf-nuafail/freeswitch.xml | 103 ++++++++++++++++++ .../endpoints/mod_sofia/test/test_nuafail.c | 58 ++++++++++ 4 files changed, 173 insertions(+), 2 deletions(-) create mode 100644 src/mod/endpoints/mod_sofia/test/conf-nuafail/freeswitch.xml create mode 100644 src/mod/endpoints/mod_sofia/test/test_nuafail.c diff --git a/src/mod/endpoints/mod_sofia/.gitignore b/src/mod/endpoints/mod_sofia/.gitignore index 3aa385f7c1..e729425084 100644 --- a/src/mod/endpoints/mod_sofia/.gitignore +++ b/src/mod/endpoints/mod_sofia/.gitignore @@ -2,3 +2,4 @@ test/Makefile test/Makefile.in test/freeswitch.xml.fsxml.tmp test/test_sofia_funcs +test/test_nuafail diff --git a/src/mod/endpoints/mod_sofia/Makefile.am b/src/mod/endpoints/mod_sofia/Makefile.am index 4bd1749175..69343c455a 100644 --- a/src/mod/endpoints/mod_sofia/Makefile.am +++ b/src/mod/endpoints/mod_sofia/Makefile.am @@ -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 diff --git a/src/mod/endpoints/mod_sofia/test/conf-nuafail/freeswitch.xml b/src/mod/endpoints/mod_sofia/test/conf-nuafail/freeswitch.xml new file mode 100644 index 0000000000..324d74b2de --- /dev/null +++ b/src/mod/endpoints/mod_sofia/test/conf-nuafail/freeswitch.xml @@ -0,0 +1,103 @@ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + +
+
diff --git a/src/mod/endpoints/mod_sofia/test/test_nuafail.c b/src/mod/endpoints/mod_sofia/test/test_nuafail.c new file mode 100644 index 0000000000..ce3a5735fe --- /dev/null +++ b/src/mod/endpoints/mod_sofia/test/test_nuafail.c @@ -0,0 +1,58 @@ + +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005-2021, Anthony Minessale II + * + * 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 + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Andrey Volk + * + * + * test_nuafail.c - Checks if sofia-sip leaks on profile start fail + * + */ + +#include +#include + +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()