5 // *** Testing Stuff !!
6 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
7 "Messages specific for this msg example");
9 int master_lua(int argc, char *argv[]);
10 int slave_lua(int argc, char *argv[]);
11 int load_lua(char * file);
12 //int forwarder(int argc, char *argv[]); LUA
13 MSG_error_t test_all(const char *platform_file, const char *application_file);
24 //***************************** LOAD LUA *************************************************
25 int load_lua(char * luaFile) {
35 if (luaL_loadfile(L, luaFile) || lua_pcall(L, 0, 0, 0)) {
36 printf("error while parsing %s: %s", luaFile, lua_tostring(L, -1));
44 int lua_wrapper(int argc, char *argv[]) {
45 // Table that Lua will read to read Arguments
48 // Seek the right lua function
49 lua_getglobal(L,argv[0]);
50 if(!lua_isfunction(L,-1)) {
52 ERROR1("The lua function %s does not seem to exist",argv[0]);
56 // push arguments onto the stack
59 lua_pushstring(L,argv[i]);
62 lua_call(L,argc-1,0); // takes argc-1 argument, returns nothing
64 // User process terminated
71 //*****************************************************************************
73 int main(int argc,char * argv[])
77 MSG_error_t res = MSG_OK;
79 MSG_global_init(&argc, argv);
83 printf("Usage: %s platform_file deployment_file lua_script\n", argv[0]);
84 printf("example: %s msg_platform.xml msg_deployment.xml script_lua.lua\n", argv[0]);
91 /* MSG_config("surf_workstation_model","KCCFLN05"); */
92 MSG_create_environment(argv[1]);
93 MSG_function_register_default(&lua_wrapper);
94 MSG_launch_application(argv[2]);
95 MSG_set_channel_number(10);
98 INFO1("Simulation time %g", MSG_get_clock());