emulator-test : separated scripts for the compliance check
authordaiyoung777.kim <daiyoung777.kim@samsung.com>
Wed, 5 Dec 2012 06:10:07 +0000 (15:10 +0900)
committerdaiyoung777.kim <daiyoung777.kim@samsung.com>
Wed, 5 Dec 2012 06:10:07 +0000 (15:10 +0900)
Signed-off-by : DaiYoung Kim <daiyoung777.kim@samsung.com>

vts/script/compliance_main.lua [new file with mode: 0644]
vts/script/config.lua [new file with mode: 0644]
vts/script/main.lua
vts/script/tc_av.lua
vts/script/tclib.lua
vts/src/main.cpp
vts/src/tccmd.h

diff --git a/vts/script/compliance_main.lua b/vts/script/compliance_main.lua
new file mode 100644 (file)
index 0000000..9539287
--- /dev/null
@@ -0,0 +1,50 @@
+
+--------------------------------------------------------------------------
+-- compliance_main.lua
+--------------------------------------------------------------------------
+
+package.path = package.path .. ";./../script/?.lua"
+package.path = package.path .. "~/tizen-sdk/test/script/?.lua"
+
+require "tclib"
+require "config"
+
+env = Env();
+env.modulepath = "~/tizen-sdk/tools/emulator/bin";
+env.emulator_manager_module = "emulator-manager.jar";
+env.vmname = config.emulatorinfo.vmname;
+
+env.report_dir = "../report/";         -- assume that has been created.
+
+-- add image path to here
+global_img_path = config.emulatorinfo.tizen_img_path;
+
+
+-- set test model object
+SetEnv(env);
+
+local script_path = "..//script//"
+
+-- test case lua file import
+
+dofile(script_path .. "tc_emulator_manager.lua") 
+dofile(script_path .. "tc_compliance_web_ide.lua")
+dofile(script_path .. "tc_compliance_native_ide.lua")
+dofile(script_path .. "tc_compliance_da.lua")
+
+
+tclib.kill_emulator();
+
+-- call test case in each lua file's function
+prepare_compliance_check(env);
+
+test_compliance_web_ide(env);
+test_compliance_native_ide(env);
+test_compliance_da(env);
+
+tclib.kill_emulator();
+
+print("All test was completed");
+-- 
+--
diff --git a/vts/script/config.lua b/vts/script/config.lua
new file mode 100644 (file)
index 0000000..6cb6337
--- /dev/null
@@ -0,0 +1,10 @@
+
+--------------------------------------------------------------------------
+-- config.lua
+--------------------------------------------------------------------------
+config={}
+
+config.emulatorinfo={}
+config.emulatorinfo.vmname = "created_from_lua";    -- set vm
+config.emulatorinfo.tizen_img_path= "~/tizen-sdk-data/emulator-vms/emulimg-created_from_lua.x86"
+
index f322bc8..926febf 100644 (file)
@@ -4,6 +4,7 @@
 --------------------------------------------------------------------------
 
 package.path = package.path .. ";./../script/?.lua"
+package.path = package.path .. "~/tizen-sdk/test/script/?.lua"
 
 require "tclib"
 
@@ -31,6 +32,7 @@ SetEnv(env);
 local script_path = "..//script//"
 
 -- test case lua file import
+
 dofile(script_path .. "tc_emulator_manager.lua") 
 dofile(script_path .. "tc_network.lua")
 dofile(script_path .. "tc_av.lua")
@@ -41,20 +43,21 @@ dofile(script_path .. "tc_compliance_web_ide.lua")
 dofile(script_path .. "tc_compliance_native_ide.lua")
 dofile(script_path .. "tc_compliance_da.lua")
 
+
 tclib.kill_emulator();
 
 -- call test case in each lua file's function
 --test_emulator_manager(env);
-prepare_compliance_check(env);
+--prepare_compliance_check(env);
 --test_network_check();
 --test_audio_video();
 --test_camera();
 --test_event_injector();
-test_compliance_web_ide(env);
-test_compliance_native_ide(env);
-test_compliance_da(env);
+--test_compliance_web_ide(env);
+--test_compliance_native_ide(env);
+--test_compliance_da(env);
 
-tclib.kill_emulator();
+--tclib.kill_emulator();
 
 --test_skinserver();
 --
index c00e350..6f1738a 100644 (file)
@@ -27,8 +27,6 @@ function test_audio_video()
 
        av_suite:AddTest(av_play);
 
-       print("av test added");
-
        av_suite:runTest();
 
        return true;
index 7c5b8d8..c55e57d 100644 (file)
@@ -1,17 +1,73 @@
 --module(tclib, package.seeall)
 tclib={}
 
+tclib.config={}
+tclib.config.pskill='.\\..\\tools\\windows\\pskill.exe'
+--tclib.config.pskill='C:\\MinGW\\msys\\1.0\\home\\dykim\\project\\emulator-test\\vts\\tools\\windows\\pskill.exe'
 
 
+function tclib.cmdlog(log)
+       io.stdout:write(log)
+       io.stdout:write('\n')
+       io.stdout:flush()
+end
+
+-- Don't use this function, can make problem
+function tclib.getos()
+        local fd = io.popen("ls -al", "r")
+               local osname = fd:read("*a")
+        fd:close();
+               
+        if osname  == null then
+                       return "unknown"
+               end
+
+               if string.find(osname, "linux") ~= nil then
+                       return "linux"
+               elseif string.find(osname, "MINGW") ~= nil then
+                       return "windows"
+               else
+                       return "mac"
+               end
+
+        return "unknown"
+end
+
+function tclib.execute(cmd)
+       local ret
+       tclib.cmdlog('-------------------------------------------------------------------------------')
+       tclib.cmdlog('?='..cmd)
+       ret = os.execute(cmd)
+       tclib.cmdlog('ret='..ret)
+       return ret
+end
+
 function tclib.sleep(length)
        local start = os.clock()
 
        while os.clock() - start < length do end
 end
 
-function tclib.kill_emulator()
+function tclib.kill_emulator_for_window()
+       print("[LUA] kill_emulator_for_window ...\n");
+       tclib.execute(tclib.config.pskill..' emulator-x86.exe')
 
-       print("Killing the existing emulator process...\n");
+       local continue = true;
+       while continue == true do 
+               local fd = io.popen("ps -a | grep emulator-x86");
+               local result = fd:read("*a");
+               print(result..'\n')
+               if string.find(result, "emulator-x86") == nil then
+                       continue = false
+                       print("emulator process does not exist\n")      
+               end
+               fd:close();
+       end
+       print("Killed emulator\n");
+end
+
+function tclib.kill_emulator_for_linux()
+       print("[LUA] kill_emulator_for_linux ...\n");
        os.execute("pkill emulator-x86");
        local continue = true;
        
@@ -28,6 +84,17 @@ function tclib.kill_emulator()
        print("Killed emulator\n");
 end
 
+function tclib.kill_emulator()
+       -- check os
+       --os = tclib.getos()
+       --if os == "windows" then
+               tclib.kill_emulator_for_window();
+       --else
+       --      tclib.kill_emulator_for_linux();
+       --end;
+end
+
+
 
 
 
index 4108587..e8a9aef 100644 (file)
@@ -55,14 +55,14 @@ int main(int argc, char** argv)
     lua_State *L = luaL_newstate();
 
     // Provide the base libraries
-    /*luaopen_base(L);
+    luaopen_base(L);
     luaopen_table(L);
     luaopen_string(L);
     luaopen_math(L);
     luaopen_debug(L);
        luaopen_io(L);  
        luaopen_package(L);
-*/
+
        luaL_openlibs(L);
     // Provide user libraries
     register_lua_funcs(L);
@@ -158,7 +158,8 @@ void register_lua_funcs(lua_State *L)
                .method("AddParam2", &scmd::AddParam2)
                .method("AddParamEX2", &scmd::AddParamEX2)
                .method("SetTimeout", &scmd::SetTimeout)  
-               .method("SetSuccessToken", &scmd::SetSuccessToken);
+               .method("SetSuccessToken", &scmd::SetSuccessToken)
+               .method("runCmd", &scmd::runCmd);
 
 
        m.subclass<sjava, scmd>("sjava")
index ccb2002..b5288e6 100644 (file)
@@ -17,22 +17,30 @@ public:
        void Finish();
 
        void AddParam1(std::string name)                      
-       {                                                    
+       {   
                cmdtest<CommandResultHandler>::AddParam(name);
-       }                                                    
-       void AddParam2(std::string name, std::string value)   
-       {                                                    
+       }
+       void AddParam2(std::string name, std::string value)
+       {
                cmdtest<CommandResultHandler>::AddParam(name, value);
-       }                                                    
+       }
 
-       void AddParamEX1(std::string name)                      
-       {                                                    
+       void AddParamEX1(std::string name)
+       {       
                cmdtest<CommandResultHandler>::AddParamEX(name);
        }                                                    
        void AddParamEX2(std::string name, std::string value)   
-       {                                                    
+       {         
                cmdtest<CommandResultHandler>::AddParamEX(name, value);
-       }                                                    
+       }
+
+       std::string runCmd(const char* cmd)
+       {
+               SetCommand(cmd);
+               if (!Exec())
+                       return "";
+               return m_resultstr; 
+       }
 };