[Freeswitch-svn] [commit] r12752 - in freeswitch/trunk/libs/sofia-sip: . tests

FreeSWITCH SVN mikej at freeswitch.org
Tue Mar 24 08:46:59 PDT 2009


Author: mikej
Date: Tue Mar 24 10:46:59 2009
New Revision: 12752

Log:
Mon Mar 23 10:41:08 CDT 2009  Pekka Pessi <first.last at nokia.com>
  * tests: added check_dlopen_sofia.c
  Ignore-this: 1f3a1a6dc3e9099c6488a637e5f06e9a


Added:
   freeswitch/trunk/libs/sofia-sip/tests/check_dlopen_sofia.c
Modified:
   freeswitch/trunk/libs/sofia-sip/.update
   freeswitch/trunk/libs/sofia-sip/tests/Makefile.am

Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update	(original)
+++ freeswitch/trunk/libs/sofia-sip/.update	Tue Mar 24 10:46:59 2009
@@ -1 +1 @@
-Tue Mar 24 10:45:18 CDT 2009
+Tue Mar 24 10:46:04 CDT 2009

Modified: freeswitch/trunk/libs/sofia-sip/tests/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/tests/Makefile.am	(original)
+++ freeswitch/trunk/libs/sofia-sip/tests/Makefile.am	Tue Mar 24 10:46:59 2009
@@ -33,8 +33,8 @@
 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 @@
 			${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.??????
 
 # ----------------------------------------------------------------------

Added: freeswitch/trunk/libs/sofia-sip/tests/check_dlopen_sofia.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/libs/sofia-sip/tests/check_dlopen_sofia.c	Tue Mar 24 10:46:59 2009
@@ -0,0 +1,124 @@
+/*
+ * This file is part of the Sofia-SIP package
+ *
+ * Copyright (C) 2009 Nokia Corporation.
+ *
+ * Contact: Pekka Pessi <pekka.pessi at nokia.com>
+ *
+ * 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 <Pekka.Pessi at nokia.com>
+ *
+ * @copyright (C) 2009 Nokia Corporation.
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <assert.h>
+
+#if HAVE_CHECK && HAVE_LIBDL
+
+#include <check.h>
+#include <s2check.h>
+
+#include <sofia-sip/su_types.h>
+#include <dlfcn.h>
+
+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



More information about the Freeswitch-svn mailing list