55 #include <sys/resource.h>
56 #include <sys/types.h>
72 #include <amxc/amxc.h>
73 #include <amxp/amxp_signal.h>
74 #include <amxd/amxd_dm.h>
75 #include <amxd/amxd_object.h>
76 #include <amxd/amxd_parameter.h>
82 #include <amxc/amxc_macros.h>
87 amxd_object_t* root = amxd_dm_get_root(dm);
88 amxd_object_t*
object = amxd_object_get_child(root,
"TestObject");
92 amxc_var_set_type(&args, AMXC_VAR_ID_HTABLE);
94 assert_ptr_not_equal(
object, NULL);
96 assert_int_equal(amxd_object_invoke_function(
object,
"TestFunc1", &args, &ret), amxd_status_ok);
97 assert_int_equal(amxd_object_invoke_function(
object,
"TestFunc2", &args, &ret), amxd_status_ok);
98 assert_int_equal(amxd_object_invoke_function(
object,
"TestFunc3", &args, &ret), amxd_status_ok);
99 assert_int_equal(amxd_object_invoke_function(
object,
"TestFunc4", &args, &ret), amxd_status_ok);
101 amxc_var_clean(&args);
102 amxc_var_clean(&ret);
125 const char* odls[] = {
126 "%define { object Test { void testa()<!import::_test_func!>;} }",
127 "%define { object Test { void testb()<!import:test:_test_func:toomuch!>;} }",
136 for(
int i = 0; odls[i] != NULL; i++) {
150 const char* odls[] = {
151 "import \"../test_plugin/test_plugin.so\" RTLD_NOW RTLD_GLOBAL RTLD_NODELETE; %define { object TestObject { void TestFunc1(); } }",
158 for(
int i = 0; odls[i] != NULL; i++) {
174 const char* odls[] = {
175 "import \"../test_plugin/test_plugin.so\" as test; %define { object TestObject { void TestFunc1(); } }",
176 "import \"../test_plugin/test_plugin.so\" as test2; %define { object TestObject { void TestFunc1(); } }",
177 "import \"../test_plugin/test_plugin.so\" as test3; %define { object TestObject { void TestFunc1(); } }",
178 "import \"../test_plugin/test_plugin.so\" as test; %define { object TestObject { void TestFunc1(); } }",
179 "%config { silent = false; import-dbg = true; } import \"../test_plugin/test_plugin.so\" as test; %define { object TestObject { void TestFunc1(); } }",
180 "%config { dir = \"test_plugin\"; myalias = \"test\"; } import \"../${dir}/test_plugin.so\" as \"${myalias}\"; %define { object TestObject { void TestFunc1(); } }",
181 "%config { thelib = \"test\"; } import \"../test_plugin/test_plugin.so\" as test; %define { object TestObject { void TestFunc1()<!import:${thelib}:data!>; } }",
182 "%config { odl-import = false; } import \"../test_plugin/test_plugin.so\" as test; %define { object TestObject { void TestFunc1(); } }",
191 for(
int i = 0; odls[i] != NULL; i++) {
207 const char* odls[] = {
208 "import \"./fake.so\" as test; %define { object TestObject { void TestFunc1(); } }",
209 "%config { silent = false; import-dbg = true; } import \"./fake.so\" as test; %define { object TestObject { void TestFunc1(); } }",
216 for(
int i = 0; odls[i] != NULL; i++) {
233 const char*
odl =
"%define { entry-point test.test_entry_point; }";
238 amxc_var_init(&counter);
239 amxc_var_set(uint32_t, &counter, 0);
261 const char*
odl =
"%define { entry-point test.test_failing_entry_point; entry-point test.test_entry_point; }";
266 amxc_var_init(&counter);
267 amxc_var_set(uint32_t, &counter, 0);
289 const char*
odl =
"%define { entry-point test.test_entry_point; entry-point test.test_entry_point; }";
294 amxc_var_init(&counter);
295 amxc_var_set(uint32_t, &counter, 0);
316 const char*
odl =
"%define { entry-point test.not_existing; }";
351 const char*
odl =
"%config { import-dbg = true; } import \"NONE-EXISTING.so\" as fake;";
372 const char* odls[] = {
373 "%config { silent = false; import-dbg = true; } import \"../test_plugin/test_plugin.so\" as test; %define { object TestObject { void FakeFunc(); } }",
380 for(
int i = 0; odls[i] != NULL; i++) {
Ambiorix ODL parser header file.
amxc_var_t * amxo_parser_get_config(amxo_parser_t *parser, const char *path)
Gets a configuration option.
int amxo_parser_set_config(amxo_parser_t *parser, const char *path, amxc_var_t *value)
Sets a configuration option.
int amxo_parser_parse_string(amxo_parser_t *parser, const char *text, amxd_object_t *object)
Parses a string containing a valid ODL part.
void amxo_parser_clean(amxo_parser_t *parser)
Cleans up the odl parser instance.
int amxo_parser_parse_file(amxo_parser_t *parser, const char *file_path, amxd_object_t *object)
Parses an odl file.
static amxd_status_t amxo_parser_get_status(amxo_parser_t *parser)
Get the status of the odl parser.
int amxo_parser_init(amxo_parser_t *parser)
Initializes a new odl parser instance.
int amxo_parser_rinvoke_entry_points(amxo_parser_t *parser, amxd_dm_t *dm, int reason)
Invokes all registered entry points in reversed order.
int amxo_parser_invoke_entry_points(amxo_parser_t *parser, amxd_dm_t *dm, int reason)
Invokes all registered entry points.
int amxo_resolver_import_open(amxo_parser_t *parser, const char *so_name, const char *alias, int flags)
Opens a shared object file (.so file)
void amxo_resolver_import_close_all(void)
Unloads all loaded shared objects.
The ODL parser structure.
void test_entry_point_only_added_once(UNUSED void **state)
void test_open_non_existing_file(UNUSED void **state)
void test_parsing_fails_when_entry_point_can_not_be_resolved(UNUSED void **state)
void test_import_resolver_import_dlopen_fails(UNUSED void **state)
void test_entry_point_invocation_continues_after_failing_entry_point(UNUSED void **state)
void test_import_resolver_resolves(UNUSED void **state)
static void check_can_invoke_functions(amxd_dm_t *dm)
void test_can_call_entry_point(UNUSED void **state)
void test_import_resolver_invalid_data(UNUSED void **state)
void test_import_resolver_can_specify_flags(UNUSED void **state)
void test_resolve_non_existing_function(UNUSED void **state)
void test_import_resolver_multiple_import(UNUSED void **state)
void test_entry_point_invoke_does_not_crash_with_invalid_args(UNUSED void **state)