[asterisk-commits] rmudgett: trunk r399208 - in /trunk: ./ tests/test_ari_model.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 16 13:36:24 CDT 2013


Author: rmudgett
Date: Mon Sep 16 13:36:22 2013
New Revision: 399208

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399208
Log:
Fix module load errors for test_ari_model.so.

You cannot use a function pointer variable with an external function from
another dynamically loaded module because data variables are always
resolved even with RTLD_LAZY.

* Added wrapper functions for ast_ari_validate_int() and
ast_ari_validate_string() to use instead for the function pointer
variable.

(closes issue ASTERISK-22457)
Reported by: David M. Lee
........

Merged revisions 399207 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/tests/test_ari_model.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Mon Sep 16 13:36:22 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399100,399136,399146,399160,399197
+/branches/12:1-398558,398560-398577,398579-399100,399136,399146,399160,399197,399207

Modified: trunk/tests/test_ari_model.c
URL: http://svnview.digium.com/svn/asterisk/trunk/tests/test_ari_model.c?view=diff&rev=399208&r1=399207&r2=399208
==============================================================================
--- trunk/tests/test_ari_model.c (original)
+++ trunk/tests/test_ari_model.c Mon Sep 16 13:36:22 2013
@@ -37,6 +37,32 @@
 #include "asterisk/module.h"
 #include "asterisk/test.h"
 #include "../res/ari/ari_model_validators.h"
+
+#if defined(TEST_FRAMEWORK)
+/*!
+ * Wrapper of ast_test_validate_int() so an external function pointer is not used.
+ *
+ * \note Must do this because using an external function pointer
+ * does not play nicely when loading with RTLD_LAZY.
+ */
+static int wrap_ast_ari_validate_int(struct ast_json *json)
+{
+	return ast_ari_validate_int(json);
+}
+#endif	/* defined(TEST_FRAMEWORK) */
+
+#if defined(TEST_FRAMEWORK)
+/*!
+ * Wrapper of ast_ari_validate_string() so an external function pointer is not used.
+ *
+ * \note Must do this because using an external function pointer
+ * does not play nicely when loading with RTLD_LAZY.
+ */
+static int wrap_ast_ari_validate_string(struct ast_json *json)
+{
+	return ast_ari_validate_string(json);
+}
+#endif	/* defined(TEST_FRAMEWORK) */
 
 AST_TEST_DEFINE(validate_byte)
 {
@@ -385,21 +411,21 @@
 
 	uut = ast_json_array_create();
 	ast_test_validate(test, NULL != uut);
-	ast_test_validate(test, ast_ari_validate_list(uut, ast_ari_validate_string));
-	ast_test_validate(test, ast_ari_validate_list(uut, ast_ari_validate_int));
+	ast_test_validate(test, ast_ari_validate_list(uut, wrap_ast_ari_validate_string));
+	ast_test_validate(test, ast_ari_validate_list(uut, wrap_ast_ari_validate_int));
 
 	res = ast_json_array_append(uut, ast_json_string_create(""));
 	ast_test_validate(test, 0 == res);
-	ast_test_validate(test, ast_ari_validate_list(uut, ast_ari_validate_string));
-	ast_test_validate(test, !ast_ari_validate_list(uut, ast_ari_validate_int));
+	ast_test_validate(test, ast_ari_validate_list(uut, wrap_ast_ari_validate_string));
+	ast_test_validate(test, !ast_ari_validate_list(uut, wrap_ast_ari_validate_int));
 
 	res = ast_json_array_append(uut, ast_json_integer_create(0));
 	ast_test_validate(test, 0 == res);
-	ast_test_validate(test, !ast_ari_validate_list(uut, ast_ari_validate_string));
-	ast_test_validate(test, !ast_ari_validate_list(uut, ast_ari_validate_int));
+	ast_test_validate(test, !ast_ari_validate_list(uut, wrap_ast_ari_validate_string));
+	ast_test_validate(test, !ast_ari_validate_list(uut, wrap_ast_ari_validate_int));
 
 	ast_test_validate(test,
-		!ast_ari_validate_list(ast_json_null(), ast_ari_validate_string));
+		!ast_ari_validate_list(ast_json_null(), wrap_ast_ari_validate_string));
 
 	return AST_TEST_PASS;
 }




More information about the asterisk-commits mailing list