[asterisk-commits] rmudgett: branch 12 r399207 - /branches/12/tests/test_ari_model.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Sep 16 13:34:57 CDT 2013
Author: rmudgett
Date: Mon Sep 16 13:34:55 2013
New Revision: 399207
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399207
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
Modified:
branches/12/tests/test_ari_model.c
Modified: branches/12/tests/test_ari_model.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/tests/test_ari_model.c?view=diff&rev=399207&r1=399206&r2=399207
==============================================================================
--- branches/12/tests/test_ari_model.c (original)
+++ branches/12/tests/test_ari_model.c Mon Sep 16 13:34:55 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