diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index a038678e92..7c5f144d8b 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Tue Mar 24 10:45:18 CDT 2009 +Tue Mar 24 10:46:04 CDT 2009 diff --git a/libs/sofia-sip/tests/Makefile.am b/libs/sofia-sip/tests/Makefile.am index c44732ed0f..45773d70b7 100644 --- a/libs/sofia-sip/tests/Makefile.am +++ b/libs/sofia-sip/tests/Makefile.am @@ -33,8 +33,8 @@ libtestproxy_a_SOURCES = test_proxy.h test_proxy.c libtestnat_a_SOURCES = test_nat.h test_nat.c test_nat_tags.c if HAVE_CHECK -TESTS += check_sofia -check_PROGRAMS += check_sofia +TESTS += check_dlopen_sofia check_sofia +check_PROGRAMS += check_dlopen_sofia check_sofia endif check_sofia_CFLAGS = @CHECK_CFLAGS@ @@ -46,6 +46,9 @@ check_sofia_LDADD = $(check_LIBRARIES) \ ${sofiabuilddir}/libsofia-sip-ua.la \ @CHECK_LIBS@ +check_dlopen_sofia_CFLAGS = -I$(top_srcdir)/s2check @CHECK_CFLAGS@ +check_dlopen_sofia_LDADD = ${top_builddir}/s2check/libs2.a @CHECK_LIBS@ + CLEANFILES = tmp_sippasswd.?????? # ---------------------------------------------------------------------- diff --git a/libs/sofia-sip/tests/check_dlopen_sofia.c b/libs/sofia-sip/tests/check_dlopen_sofia.c new file mode 100644 index 0000000000..6002f8da79 --- /dev/null +++ b/libs/sofia-sip/tests/check_dlopen_sofia.c @@ -0,0 +1,124 @@ +/* + * This file is part of the Sofia-SIP package + * + * Copyright (C) 2009 Nokia Corporation. + * + * Contact: Pekka Pessi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +/**@CFILE check_dlopen_sofia.c + * + * @brief Check dlopen()ing and dlclose() with libsofia-sip-ua + * + * @author Pekka Pessi + * + * @copyright (C) 2009 Nokia Corporation. + */ + +#include "config.h" + +#include +#include +#include + +#include + +#if HAVE_CHECK && HAVE_LIBDL + +#include +#include + +#include +#include + +static uint64_t (*su_random64)(void); + +START_TEST(load_su_uniqueid) +{ + void *sofia; + uint64_t rnd; + + sofia = dlopen("../libsofia-sip-ua/.libs/libsofia-sip-ua.so", RTLD_NOW); + su_random64 = dlsym(sofia, "su_random64"); + fail_unless(su_random64 != NULL); + rnd = su_random64(); + fail_unless(sofia != NULL); + fail_unless(dlclose(sofia) == 0); +} +END_TEST + +TCase *dl_tcase(void) +{ + TCase *tc = tcase_create("1 - dlopen/dlclose"); + + tcase_add_test(tc, load_su_uniqueid); + + return tc; +} + +/* ---------------------------------------------------------------------- */ + +static void usage(int exitcode) +{ + fprintf(exitcode ? stderr : stdout, + "usage: check_dlopen_sofia [--xml=logfile] case,...\n"); + exit(exitcode); +} + +int main(int argc, char *argv[]) +{ + int i, failed = 0; + + Suite *suite = suite_create("dlopen()ing and dlclose() with libsofia-sip-ua"); + SRunner *runner; + char const *xml = NULL; + + s2_select_tests(getenv("CHECK_CASES")); + + for (i = 1; argv[i]; i++) { + if (strncmp(argv[i], "--xml=", strlen("--xml=")) == 0) { + xml = argv[i] + strlen("--xml="); + } + else if (strcmp(argv[i], "--xml") == 0) { + if (!(xml = argv[++i])) + usage(2); + } + else if (strcmp(argv[i], "-?") == 0 || + strcmp(argv[i], "-h") == 0 || + strcmp(argv[i], "--help") == 0) + usage(0); + else + s2_select_tests(argv[i]); + } + + suite_add_tcase(suite, dl_tcase()); + + runner = srunner_create(suite); + if (xml) + srunner_set_xml(runner, xml); + srunner_run_all(runner, CK_ENV); + failed = srunner_ntests_failed(runner); + srunner_free(runner); + + exit(failed ? EXIT_FAILURE : EXIT_SUCCESS); +} + +#else +int main(void) { return 77; } +#endif