From: daiyoung777.kim Date: Wed, 5 Dec 2012 06:10:07 +0000 (+0900) Subject: emulator-test : separated scripts for the compliance check X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fa7915d6c362e696c66c045111bc9351c2488b7c;p=sdk%2Femulator%2Femulator-test.git emulator-test : separated scripts for the compliance check Signed-off-by : DaiYoung Kim --- diff --git a/vts/script/compliance_main.lua b/vts/script/compliance_main.lua new file mode 100644 index 0000000..9539287 --- /dev/null +++ b/vts/script/compliance_main.lua @@ -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 index 0000000..6cb6337 --- /dev/null +++ b/vts/script/config.lua @@ -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" + diff --git a/vts/script/main.lua b/vts/script/main.lua index f322bc8..926febf 100644 --- a/vts/script/main.lua +++ b/vts/script/main.lua @@ -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(); -- diff --git a/vts/script/tc_av.lua b/vts/script/tc_av.lua index c00e350..6f1738a 100644 --- a/vts/script/tc_av.lua +++ b/vts/script/tc_av.lua @@ -27,8 +27,6 @@ function test_audio_video() av_suite:AddTest(av_play); - print("av test added"); - av_suite:runTest(); return true; diff --git a/vts/script/tclib.lua b/vts/script/tclib.lua index 7c5b8d8..c55e57d 100644 --- a/vts/script/tclib.lua +++ b/vts/script/tclib.lua @@ -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 + + diff --git a/vts/src/main.cpp b/vts/src/main.cpp index 4108587..e8a9aef 100644 --- a/vts/src/main.cpp +++ b/vts/src/main.cpp @@ -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") diff --git a/vts/src/tccmd.h b/vts/src/tccmd.h index ccb2002..b5288e6 100644 --- a/vts/src/tccmd.h +++ b/vts/src/tccmd.h @@ -17,22 +17,30 @@ public: void Finish(); void AddParam1(std::string name) - { + { cmdtest::AddParam(name); - } - void AddParam2(std::string name, std::string value) - { + } + void AddParam2(std::string name, std::string value) + { cmdtest::AddParam(name, value); - } + } - void AddParamEX1(std::string name) - { + void AddParamEX1(std::string name) + { cmdtest::AddParamEX(name); } void AddParamEX2(std::string name, std::string value) - { + { cmdtest::AddParamEX(name, value); - } + } + + std::string runCmd(const char* cmd) + { + SetCommand(cmd); + if (!Exec()) + return ""; + return m_resultstr; + } };