From: Junghyun Yeon Date: Fri, 21 Aug 2020 01:23:35 +0000 (+0900) Subject: Add try-catch statement X-Git-Tag: submit/tizen/20200821.072757~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=25c1139b75e23f291916d8484fa69b709d64cb3d;p=platform%2Fcore%2Fappfw%2Fwgt-backend.git Add try-catch statement Change-Id: I13bf668f13fabc277a94012a7217b48c46b158f7 Signed-off-by: Junghyun Yeon --- diff --git a/src/unit_tests/smoke_test_helper.cc b/src/unit_tests/smoke_test_helper.cc index 0c0e6f4..44ab422 100644 --- a/src/unit_tests/smoke_test_helper.cc +++ b/src/unit_tests/smoke_test_helper.cc @@ -13,39 +13,44 @@ namespace ci = common_installer; // this main of test binay in done purely for recovery smoke test. int main(int argc, char** argv) { - int index = -1; - int backend_argc = argc; - std::string step_name; - smoke_test::CrashStepType type = smoke_test::CrashStepType::PROCESS; - - if (!strcmp(argv[backend_argc - 2], "-idx")) { - index = atoi(argv[argc - 1]); - backend_argc -= 2; - LOG(DEBUG) << "Step crash after " << index << " step."; + try { + int index = -1; + int backend_argc = argc; + std::string step_name; + smoke_test::CrashStepType type = smoke_test::CrashStepType::PROCESS; + + if (!strcmp(argv[backend_argc - 2], "-idx")) { + index = atoi(argv[argc - 1]); + backend_argc -= 2; + LOG(DEBUG) << "Step crash after " << index << " step."; + } + + if (!strcmp(argv[backend_argc - 2], "-step_name")) { + step_name = argv[backend_argc - 1]; + backend_argc -= 2; + LOG(DEBUG) << "Step crash after " << step_name << " step."; + } + + if (!strcmp(argv[backend_argc - 1], "-type_clean")) { + backend_argc--; + type = smoke_test::CrashStepType::CLEAN; + LOG(DEBUG) << "step will be crashed in clean operation"; + } + + ci::PkgmgrInstaller pkgmgr_installer; + wgt::WgtAppQueryInterface query_interface; + auto pkgmgr = ci::PkgMgrInterface::Create(backend_argc, argv, + &pkgmgr_installer, &query_interface); + if (!pkgmgr) { + LOG(ERROR) << "Options of pkgmgr installer cannot be parsed"; + return EINVAL; + } + + smoke_test::CrashWgtInstaller installer(pkgmgr, index, step_name, type); + return (installer.Run() == ci::AppInstaller::Result::OK) ? 0 : 1; + } catch (...) { + std::cout << "Exception occurred during testing" << std::endl; + return 1; } - - if (!strcmp(argv[backend_argc - 2], "-step_name")) { - step_name = argv[backend_argc - 1]; - backend_argc -= 2; - LOG(DEBUG) << "Step crash after " << step_name << " step."; - } - - if (!strcmp(argv[backend_argc - 1], "-type_clean")) { - backend_argc--; - type = smoke_test::CrashStepType::CLEAN; - LOG(DEBUG) << "step will be crashed in clean operation"; - } - - ci::PkgmgrInstaller pkgmgr_installer; - wgt::WgtAppQueryInterface query_interface; - auto pkgmgr = ci::PkgMgrInterface::Create(backend_argc, argv, - &pkgmgr_installer, &query_interface); - if (!pkgmgr) { - LOG(ERROR) << "Options of pkgmgr installer cannot be parsed"; - return EINVAL; - } - - smoke_test::CrashWgtInstaller installer(pkgmgr, index, step_name, type); - return (installer.Run() == ci::AppInstaller::Result::OK) ? 0 : 1; }