55 #include <sys/resource.h>
56 #include <sys/types.h>
71 #include <amxc/amxc.h>
72 #include <amxp/amxp_signal.h>
73 #include <amxd/amxd_dm.h>
74 #include <amxd/amxd_object.h>
75 #include <amxd/amxd_parameter.h>
80 #include <amxc/amxc_macros.h>
82 UNUSED amxd_param_t*
const param,
83 UNUSED amxd_action_t reason,
84 UNUSED const amxc_var_t*
const args,
85 UNUSED amxc_var_t*
const retval,
87 return amxd_status_ok;
91 UNUSED const amxc_var_t*
const data,
94 printf(
"Event received %s\n", sig_name);
100 const char* odls[] = {
101 "%define { %in object Test; }",
102 "%define { %out object Test; }",
103 "%define { %mandatory object Test; }",
104 "%define { %strict object Test; }",
105 "%define { %volatile object Test; }",
106 "%define { %template object Test; }",
107 "%define { %instance object Test; }",
114 for(
int i = 0; odls[i] != NULL; i++) {
127 const char* odls[] = {
128 "%define { object Test { %in string Param; } }",
129 "%define { object Test { %out string Param; } }",
130 "%define { object Test { %mandatory string Param; } }",
131 "%define { object Test { %strict string Param; } }",
138 for(
int i = 0; odls[i] != NULL; i++) {
151 const char* odls[] = {
152 "%define { object Test { %read-only void Func(); } }",
153 "%define { object Test { %persistent void Func(); } }",
154 "%define { object Test { %in void Func(); } }",
155 "%define { object Test { %out void Func(); } }",
156 "%define { object Test { %mandatory void Func(); } }",
157 "%define { object Test { %strict void Func(); } }",
158 "%define { object Test { %volatile void Func(); } }",
165 for(
int i = 0; odls[i] != NULL; i++) {
179 "%define { object Test; }" \
180 "%populate { object Test { instance add(0,\"\"); } }";
196 "%define { object Test[]; }" \
197 "%populate { object Test { instance add(1,\"\"); instance add(1,\"\"); } }";
213 "%define { object Test[]; }" \
214 "%populate { object Test { instance add(0,\"AB\"); instance add(0,\"AB\"); } }";
230 "%define { object Test[]; }" \
231 "%populate { object Test { instance add(0,\"%Text$\"); instance add(0,\"AB\"); } }";
247 "%define { object Test; }" \
248 "%populate { object Test { instance add(0,\"Text\"); instance add(0,\"AB\"); } }";
263 const char*
odl =
"%define { object Test1; object Test2; object Test1; }";
278 const char*
odl =
"%define { object \"23&Test1\"; }";
293 const char*
odl =
"%define { object Test { string P1; string P2; string P1; } }";
308 const char*
odl =
"%define { object Test { string P1; object TT[] { counted with P1; } } }";
323 const char*
odl =
"%define { object Test { string \"12$P1\"; } }";
338 const char*
odl =
"%define { object Test { void \"F$1\"(); } }";
353 const char*
odl =
"%define { object Test { void F1(bool a1, bool a2, bool a1); } }";
368 const char*
odl =
"%define { object Test; } %populate { object NoneExisting; }";
383 const char*
odl =
"%define { object Test { string P1;} } %populate { object Test { parameter P2 = \"text\"; } }";
398 const char*
odl =
"%define { object Test { bool P1;} } %populate { object Test { parameter P1 = \"text\"; } }";
399 const char* odl2 =
"%define { object Test { string P1;} } %populate { object Test { parameter P1 = [ 1, 2, 3 ]; } }";
423 " on action validate call check_maximum 10;"
446 " on action reset call dummy;"
469 " on action reset call dummy;"
488 const char* odls[] = {
489 "%define { object Test { void test()<!!>;} }",
490 "%define { object Test { void test()<!:!>;} }",
491 "%define { object Test { void test()<!:echo!>;} }",
492 "%define { object Test { void test()<!invalid:echo!>;} }",
493 "%define { object Test { void test()<!more!>;} }",
500 for(
int i = 0; odls[i] != NULL; i++) {
513 const char* odls[] = {
514 " import \"../test_plugin/test_plugin.so\" as test_plugin; %define { entry-point test_plugin.not_existing; }",
521 for(
int i = 0; odls[i] != NULL; i++) {
534 const char* odls[] = {
535 "%define { object Test { string Text { on action \"list\" call dummy; } } }",
536 "%define { object Test { string Text { on action add-inst call dummy; } } }",
537 "%define { object Test { string Text { on action del-inst call dummy; } } }",
546 for(
int i = 0; odls[i] != NULL; i++) {
559 const char* odls[] = {
560 "%define { object Test { on action \"list\" call not_existing; } }",
561 "%define { object Test { string Text { on action read call no_existing; } } }",
562 "%define { object Test { on action write call not_existing; } }",
569 for(
int i = 0; odls[i] != NULL; i++) {
582 const char* odls[] = {
583 "%define { object Test { extend with mib FakeMib; } }",
590 for(
int i = 0; odls[i] != NULL; i++) {
603 const char* odls[] = {
604 "%define { mib TestMib { string Text; } object Test { string Text; extend with mib TestMib; } }",
605 "%define { mib TestMib { string Text; } object Test { extend with mib TestMib; string Text; } }",
612 for(
int i = 0; odls[i] != NULL; i++) {
628 " object Test { string text = \"Hallo\"; }\n"
631 " on event \".*\" call print_event \n"
632 " filter \'object matches \"[(adsads[\"';\n"
652 " object TestRoot {\n"
654 " %key string text;\n"
659 " object TestRoot.Test {\n"
666 " object TestRoot {\n"
668 " %key string text;\n"
673 " object TestRoot.Test {\n"
674 " instance add() {\n"
675 " parameter text = \"KeyValue\";\n"
682 " object TestRoot {\n"
684 " %key string text;\n"
689 " object TestRoot.Test {\n"
690 " instance add(text = \"key1\");\n"
691 " instance add(text = \"key1\");\n"
697 " object TestRoot {\n"
699 " %key string text = \"Hallo\";\n"
707 printf(
"%s\n", odl_1);
713 printf(
"%s\n", odl_2);
719 printf(
"%s\n", odl_3);
725 printf(
"%s\n", odl_4);
Ambiorix ODL parser header file.
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.
int amxo_parser_new(amxo_parser_t **parser)
Allocates memory for a new parser instance on the heap and initializes the odl parser.
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.
void amxo_parser_delete(amxo_parser_t **parser)
Cleans the odl parser content and frees the allocated memory.
int amxo_resolver_ftab_add(amxo_parser_t *parser, const char *fn_name, amxo_fn_ptr_t fn)
Adds a C function to the function table.
void amxo_resolver_import_close_all(void)
Unloads all loaded shared objects.
#define AMXO_FUNC(x)
Function ponter caster macro.
The ODL parser structure.
void test_duplicate_param_name_with_counter(UNUSED void **state)
void test_add_mib_with_duplicates(UNUSED void **state)
void test_add_not_existing_mib(UNUSED void **state)
void test_invalid_parameter_actions(UNUSED void **state)
void test_invalid_action_name(UNUSED void **state)
void test_add_inst_on_singelton(UNUSED void **state)
void test_invalid_param_value(UNUSED void **state)
void test_invalid_param_attrs(UNUSED void **state)
void test_invalid_key_params(UNUSED void **state)
void test_invalid_object_attrs(UNUSED void **state)
void test_duplicate_func_arg_name(UNUSED void **state)
void test_invalid_param_value_validate(UNUSED void **state)
void test_not_resolved_action(UNUSED void **state)
void test_select_none_existing_obj(UNUSED void **state)
void test_invalid_resolvers(UNUSED void **state)
void test_invalid_obj_name(UNUSED void **state)
void test_duplicate_param_name(UNUSED void **state)
static amxd_status_t test_dummy_action(UNUSED amxd_object_t *const object, UNUSED amxd_param_t *const param, UNUSED amxd_action_t reason, UNUSED const amxc_var_t *const args, UNUSED amxc_var_t *const retval, UNUSED void *priv)
void test_invalid_func_attrs(UNUSED void **state)
void test_invalid_param_name(UNUSED void **state)
void test_duplicate_obj_name(UNUSED void **state)
void test_duplicate_inst_name(UNUSED void **state)
void test_select_none_existing_param(UNUSED void **state)
void test_duplicate_inst_index(UNUSED void **state)
void test_not_existing_entry_point(UNUSED void **state)
void test_invalid_inst_name(UNUSED void **state)
static void _print_event(const char *const sig_name, UNUSED const amxc_var_t *const data, UNUSED void *const priv)
void test_invalid_regexp_in_filter(UNUSED void **state)
void test_instance_of_singleton(UNUSED void **state)
void test_empty_file_name(UNUSED void **state)
void test_invalid_object_action_name(UNUSED void **state)
void test_invalid_func_name(UNUSED void **state)
void test_parse_non_existing_file(UNUSED void **state)