4 #include "config_test.h" 15 size_t len1 = strlen(s1);
16 size_t len2 = strlen(s2);
18 char *result = (
char *) malloc((len1 + len2 + 1) *
sizeof(
char));
20 exit(CTEST_RETURN_FAIL);
22 memcpy(result, s1, len1);
23 memcpy(result + len1, s2, len2 + 1);
30 printf(
"module = %s, log level = %d: %s\n", module, log_level, message);
61 if (configuration != 0) {
71 exit(CTEST_RETURN_FAIL);
74 exit(CTEST_RETURN_FAIL);
116 if (!fmu_test(fmu)) {
117 exit(CTEST_RETURN_FAIL);
149 pass_name_check(
"naming_conventions_xmls/standard/vehicle.engine.speed");
152 pass_name_check(
"naming_conventions_xmls/standard/robot.axis.motor234");
176 fail_name_check(
"naming_conventions_xmls/der/dera-no-closing-parenthesis");
296 expected_message =
"Alias set with vr=0 (type=Real) do not have a 'noAlias' variable.";
301 expected_message =
"Alias set with vr=0 (type=Real) do not have a 'noAlias' variable.";
306 expected_message =
"Alias set with vr=0 (type=Real) do not have a 'noAlias' variable.";
311 expected_message =
"Variables v1 and v2 reference the same vr 0. Marking 'v2' as alias.";
314 expected_message =
"Variables v1 and v2 reference the same vr 0. Marking 'v2' as alias.";
317 expected_message =
"Variables v1 and v2 reference the same vr 0. Marking 'v2' as alias.";
320 expected_message =
"Alias set with vr=0 (type=Real) do not have a 'noAlias' variable.";
322 expected_message =
"Alias set with vr=1 (type=Real) do not have a 'noAlias' variable.";
325 expected_message =
"Variables v1 and v2 reference the same vr 0. Marking 'v2' as alias.";
349 "start value '1' of 'v1' does not match " 350 "start value '3' of 'v2'.";
355 "start value '1' of 'v1' does not match " 356 "start value '2' of 'v2'.";
361 "start value 'true' of 'v1' does not match " 362 "start value 'false' of 'v2'.";
367 "start value 'a' of 'v1' does not match " 368 "start value 'b' of 'v2'.";
378 "start value '1' of 'v1' does not match " 379 "start value '1' of 'v2'(negated alias).";
384 "start value '1' of 'v1' does not match " 385 "start value '1' of 'v2'(negated alias).";
390 "start value 'true' of 'v1' does not match " 391 "start value 'true' of 'v2'(negated alias).";
396 "start value 'a' of 'v1' does not match " 397 "start value 'a' of 'v2'(negated alias).";
405 "start value '1' of 'v2' does not match " 406 "start value '3' of 'v3'.";
423 "deprecated as it fills no function";
427 int main(
int argc,
char *argv[])
432 printf(
"Usage: %s <path to folder naming_conventions_xmls>\n", argv[0]);
433 exit(CTEST_RETURN_FAIL);
jm_calloc_f calloc
Allocate zero initialized memory.
void test_parser_with_cleanup(char *xml_dir, int should_log_expected_msg, int configuration)
static char * name_check_test_directory
static const int DO_LOG_EXPECTED_MSG
int should_have_size_3_alias_group(fmi1_import_t *fmu)
struct fmi1_import_variable_list_t fmi1_import_variable_list_t
List of variables.
int main(int argc, char *argv[])
char * concat(char *s1, char *s2)
void test_parsing_pass_and_fmu(char *xml_dir, fmu_test_f fmu_test)
void importlogger(jm_callbacks *c, jm_string module, jm_log_level_enu_t log_level, jm_string message)
jm_log_level_enu_t
Log levels supported via the logger functions in jm_callbacks.
void parser_log_expected_message(char *xml_dir)
Debug messages. Only enabled if library is configured with FMILIB_ENABLE_LOG_LEVEL_DEBUG.
struct fmi1_xml_variable_t fmi1_import_variable_t
General variable type.
int should_have_size_2_no_alis(fmi1_import_t *fmu)
FMILIB_EXPORT fmi1_variable_alias_kind_enu_t fmi1_import_get_variable_alias_kind(fmi1_import_variable_t *)
Get the variable alias kind.
void parser_no_log_expected_message(char *xml_dir)
jm_log_level_enu_t log_level
Logging level.
FMILIB_EXPORT fmi1_import_variable_list_t * fmi1_import_get_variable_list(fmi1_import_t *fmu)
Get the list of all the variables in the model.
fmi1_import_t * test_parser(jm_callbacks *cb, char *xml_dir, int should_log_expected_msg, int configuration)
void pass_name_check(char *xml_dir)
static const int NO_LOG_EXPECTED_MSG
void test_parsing_fail_and_fmu(char *xml_dir, fmu_test_f fmu_test)
FMILIB_EXPORT fmi1_import_t * fmi1_import_parse_xml(fmi_import_context_t *c, const char *dirName)
Parse FMI 1.0 XML file found in the directory dirName.
Include file to be used in client applications of the FMI Library.
static char * expected_message
jm_malloc_f malloc
Allocate non-initialized memory.
jm_voidp context
Arbitrary context pointer passed to the logger function.
int should_have_1_no_alias_var(fmi1_import_t *fmu)
const char * jm_string
A constant string.
void test_alias_set_error_handling(void)
FMILIB_EXPORT void fmi_import_set_configuration(fmi_import_context_t *c, int conf)
Sets advanced configuration, if zero is passed default configuration is set. Currently only one non d...
The callbacks struct is sent to all the modules in the library.
int should_have_size_2_alias_group(fmi1_import_t *fmu)
struct fmi_xml_context_t fmi_import_context_t
FMI version independent library context. Opaque struct returned from fmi_import_allocate_context() ...
FMILIB_EXPORT fmi_import_context_t * fmi_import_allocate_context(jm_callbacks *callbacks)
Create fmi_import_context_t structure.
void test_variable_naming_conventions(void)
int should_have_no_vars(fmi1_import_t *fmu)
struct fmi1_import_t fmi1_import_t
FMU version 1.0 object.
FMILIB_EXPORT size_t fmi1_import_get_variable_list_size(fmi1_import_variable_list_t *vl)
Get number of variables in a list.
jm_callbacks * create_parse_test_callbacks(void)
static int did_log_expected_msg
void test_parsing_and_fmu(char *xml_dir, fmu_test_f fmu_test, int should_log_expected_msg)
FMILIB_EXPORT void fmi_import_free_context(fmi_import_context_t *c)
Free memory allocated for the library context.
jm_realloc_f realloc
Re-allocate memory.
int(* fmu_test_f)(fmi1_import_t *fmu)
FMILIB_EXPORT fmi1_import_variable_t * fmi1_import_get_variable(fmi1_import_variable_list_t *vl, unsigned int index)
Get a single variable from the list.
#define FMI_IMPORT_NAME_CHECK
If this configuration option is set, the model description will be checked to follow the variable nam...
FMILIB_EXPORT void fmi1_import_free(fmi1_import_t *fmu)
Release the memory allocated.
void destroy_parse_test_callbacks(jm_callbacks *cb)
void test_deprecation_errors(void)
jm_free_f free
Free-allocated memory.
jm_logger_f logger
Logging callback.
void fail_name_check(char *xml_dir)