8 #include "msg/datatypes.h"
9 #include "xbt/sysdep.h"
11 #include "xbt/asserts.h"
15 // *** Testing Stuff !!
16 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
17 "Messages specific for this msg example");
19 int master_lua(int argc, char *argv[]);
20 int slave_lua(int argc, char *argv[]);
21 //int load_lua(char * file);
22 //int forwarder(int argc, char *argv[]); LUA
23 MSG_error_t test_all(const char *platform_file, const char *application_file);
33 //***************************** LOAD LUA *************************************************
34 static int load_lua(char * luaFile, lua_State *L) {
42 if (luaL_loadfile(L, luaFile) || lua_pcall(L, 0, 0, 0)) {
43 printf("error while parsing %s: %s", luaFile, lua_tostring(L, -1));
51 int lua_wrapper(int argc, char *argv[]) {
52 lua_State *L = lua_open();
53 load_lua(lua_file, L);
55 // Seek the right lua function
56 lua_getglobal(L,argv[0]);
57 if(!lua_isfunction(L,-1)) {
59 ERROR1("The lua function %s does not seem to exist",argv[0]);
63 // push arguments onto the stack
66 lua_pushstring(L,argv[i]);
69 lua_call(L,argc-1,0); // takes argc-1 argument, returns nothing
71 // User process terminated
79 //*****************************************************************************
81 int main(int argc,char * argv[])
85 MSG_error_t res = MSG_OK;
87 MSG_global_init(&argc, argv);
91 printf("Usage: %s platform_file deployment_file lua_script\n", argv[0]);
92 printf("example: %s msg_platform.xml msg_deployment.xml script_lua.lua\n", argv[0]);
100 /* MSG_config("surf_workstation_model","KCCFLN05"); */
101 MSG_create_environment(argv[1]);
102 MSG_function_register_default(&lua_wrapper);
103 MSG_launch_application(argv[2]);
107 INFO1("Simulation time %g", MSG_get_clock());