1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
5 #include <common/pkgmgr_interface.h>
6 #include <manifest_parser/utils/logging.h>
8 #include "smoke_tests/wgt_smoke_utils.h"
9 #include "wgt/utils/wgt_app_query_interface.h"
10 #include "wgt/wgt_installer.h"
12 namespace ci = common_installer;
14 static int RunCrashWgtInstaller(ci::PkgMgrPtr pkgmgr,
16 std::string step_name,
17 smoke_test::CrashStepType type) {
18 smoke_test::CrashWgtInstaller t(pkgmgr, index, step_name, type);
20 if (t.Run() != ci::AppInstaller::Result::OK) {
21 LOG(ERROR) << "CrashWgtInstaller run failure";
27 static int RunWgtInstallerWithoutParserPlugins(ci::PkgMgrPtr pkgmgr) {
28 smoke_test::WgtInstallerWithoutPasrserPlugins t(pkgmgr);
30 if (t.Run() != ci::AppInstaller::Result::OK) {
31 LOG(ERROR) << "WgtInstallerWithoutPasrserPlugins run failure";
37 // this main of test binay in done purely for recovery smoke test.
38 int main(int argc, char** argv) {
41 int backend_argc = argc;
42 std::string step_name;
43 bool remove_plugins = false;
44 smoke_test::CrashStepType type = smoke_test::CrashStepType::PROCESS;
46 if (!strcmp(argv[backend_argc - 1], "-type_clean")) {
48 type = smoke_test::CrashStepType::CLEAN;
49 LOG(DEBUG) << "step will be crashed in clean operation";
52 if (!strcmp(argv[backend_argc - 2], "-idx")) {
53 index = atoi(argv[backend_argc - 1]);
55 LOG(DEBUG) << "Step crash after " << index << " step.";
58 if (!strcmp(argv[backend_argc - 2], "-step_name")) {
59 step_name = argv[backend_argc - 1];
61 LOG(DEBUG) << "Step crash after " << step_name << " step.";
64 if (!strcmp(argv[backend_argc-1], "-remove_plugin_steps")) {
66 remove_plugins = true;
67 LOG(DEBUG) << "Remove parser plugins steps";
70 ci::PkgmgrInstaller pkgmgr_installer;
71 std::shared_ptr<wgt::WgtAppQueryInterface> query_interface(
72 new wgt::WgtAppQueryInterface());
73 auto pkgmgr = ci::PkgMgrInterface::Create(backend_argc, argv,
74 &pkgmgr_installer, query_interface);
76 LOG(ERROR) << "Options of pkgmgr installer cannot be parsed";
81 return RunWgtInstallerWithoutParserPlugins(pkgmgr);
83 return RunCrashWgtInstaller(pkgmgr, index, step_name, type);
85 std::cout << "Exception occurred during testing" << std::endl;