From: Ilho Kim Date: Fri, 21 Aug 2020 01:29:07 +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=cc9113cbda363f64aa2355d8b4ee7bdbf41dfb5a;p=platform%2Fcore%2Fappfw%2Ftpk-backend.git Add try-catch statement Change-Id: I3708d06c0ddd27f421c0adfe8350f514c09468a5 Signed-off-by: Ilho Kim --- diff --git a/src/unit_tests/smoke_test_helper.cc b/src/unit_tests/smoke_test_helper.cc index e2706b4..d075906 100644 --- a/src/unit_tests/smoke_test_helper.cc +++ b/src/unit_tests/smoke_test_helper.cc @@ -37,48 +37,53 @@ static int RunTpkInstallerWithoutParserPlugins(ci::PkgMgrPtr pkgmgr) { // This version of backend will crash in the end // it is used for recovery testcase int main(const int argc, char* argv[]) { - int index = -1; - int backend_argc = argc; - std::string step_name; - bool remove_plugins = false; - smoke_test::CrashStepType type = smoke_test::CrashStepType::PROCESS; + try { + int index = -1; + int backend_argc = argc; + std::string step_name; + bool remove_plugins = false; + smoke_test::CrashStepType type = smoke_test::CrashStepType::PROCESS; - if (!strcmp(argv[backend_argc-2], "-idx")) { - index = atoi(argv[backend_argc-1]); - backend_argc -= 2; - LOG(DEBUG) << "Step crash after " << index << " step."; - } + if (!strcmp(argv[backend_argc-2], "-idx")) { + index = atoi(argv[backend_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-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], "-remove_plugin_steps")) { - backend_argc--; - remove_plugins = true; - LOG(DEBUG) << "Remove parser plugins steps"; - } + if (!strcmp(argv[backend_argc-1], "-remove_plugin_steps")) { + backend_argc--; + remove_plugins = true; + LOG(DEBUG) << "Remove parser plugins steps"; + } - if (!strcmp(argv[backend_argc-1], "-type_clean")) { - backend_argc--; - type = smoke_test::CrashStepType::CLEAN; - LOG(DEBUG) << "step will be crashed in clean operation"; - } + 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; - tpk::TpkAppQueryInterface interface; - ci::PkgMgrPtr pkgmgr = ci::PkgMgrInterface::Create(backend_argc, argv, - &pkgmgr_installer, - &interface); - if (!pkgmgr) { - LOG(ERROR) << "Failed to create pkgmgr interface"; - return -1; - } + ci::PkgmgrInstaller pkgmgr_installer; + tpk::TpkAppQueryInterface interface; + ci::PkgMgrPtr pkgmgr = ci::PkgMgrInterface::Create(backend_argc, argv, + &pkgmgr_installer, + &interface); + if (!pkgmgr) { + LOG(ERROR) << "Failed to create pkgmgr interface"; + return -1; + } - if (remove_plugins) - return RunTpkInstallerWithoutParserPlugins(pkgmgr); - else - return RunCrashTpkInstaller(pkgmgr, index, step_name, type); + if (remove_plugins) + return RunTpkInstallerWithoutParserPlugins(pkgmgr); + else + return RunCrashTpkInstaller(pkgmgr, index, step_name, type); + } catch (...) { + std::cout << "Exception occurred during testing" << std::endl; + return 1; + } }