2 Copyright (C) 2012 Modelon AB
\r
4 This program is free software: you can redistribute it and/or modify
\r
5 it under the terms of the BSD style license.
\r
7 This program is distributed in the hope that it will be useful,
\r
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
10 FMILIB_License.txt file for more details.
\r
12 You should have received a copy of the FMILIB_License.txt file
\r
13 along with this program. If not, contact Modelon AB <http://www.modelon.com>.
\r
20 #include <config_test.h>
\r
25 extern int fmi1_test(fmi_import_context_t* context, const char* dirPath);
\r
26 extern int fmi2_test(fmi_import_context_t* context, const char* dirPath);
\r
28 void importlogger(jm_callbacks* c, jm_string module, jm_log_level_enu_t log_level, jm_string message)
\r
30 printf("module = %s, log level = %d: %s\n", module, log_level, message);
\r
33 void do_exit(int code)
\r
35 printf("Press 'Enter' to exit\n");
\r
40 int main(int argc, char *argv[])
\r
42 const char* FMUPath;
\r
43 const char* tmpPath;
\r
44 jm_callbacks callbacks;
\r
45 fmi_import_context_t* context;
\r
46 fmi_version_enu_t version;
\r
50 printf("Usage: %s <fmu_file> <temporary_dir>\n", argv[0]);
\r
51 do_exit(CTEST_RETURN_FAIL);
\r
58 callbacks.malloc = malloc;
\r
59 callbacks.calloc = calloc;
\r
60 callbacks.realloc = realloc;
\r
61 callbacks.free = free;
\r
62 callbacks.logger = importlogger;
\r
63 callbacks.log_level = jm_log_level_all;
\r
64 callbacks.context = 0;
\r
66 #ifdef FMILIB_GENERATE_BUILD_STAMP
\r
67 printf("Library build stamp:\n%s\n", fmilib_get_build_stamp());
\r
70 context = fmi_import_allocate_context(&callbacks);
\r
72 version = fmi_import_get_fmi_version(context, FMUPath, tmpPath);
\r
74 if(version == fmi_version_1_enu) {
\r
75 ret = fmi1_test(context, tmpPath);
\r
77 else if(version == fmi_version_2_0_enu) {
\r
78 ret = fmi2_test(context, tmpPath);
\r
81 fmi_import_free_context(context);
\r
82 printf("Only versions 1.0 and 2.0 are supported so far\n");
\r
83 do_exit(CTEST_RETURN_FAIL);
\r
86 fmi_import_free_context(context);
\r
88 if(ret == CTEST_RETURN_SUCCESS)
\r
89 printf("Everything seems to be OK since you got this far=)!\n");
\r