1 // Copyright (c) 2023 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"
11 namespace ci = common_installer;
13 static int RunCrashHybridInstaller(ci::PkgMgrPtr pkgmgr,
15 std::string step_name,
16 smoke_test::CrashStepType type) {
17 smoke_test::CrashHybridInstaller t(pkgmgr, index, step_name, type);
19 if (t.Run() != ci::AppInstaller::Result::OK) {
20 LOG(ERROR) << "CrashHybridInstaller run failure";
26 static int RunHybridInstallerWithoutParserPlugins(ci::PkgMgrPtr pkgmgr) {
27 smoke_test::HybridInstallerWithoutPasrserPlugins t(pkgmgr);
29 if (t.Run() != ci::AppInstaller::Result::OK) {
30 LOG(ERROR) << "HybridInstallerWithoutPasrserPlugins run failure";
36 // this main of test binay in done purely for recovery smoke test.
37 int main(int argc, char** argv) {
40 int backend_argc = argc;
41 std::string step_name;
42 bool remove_plugins = false;
43 smoke_test::CrashStepType type = smoke_test::CrashStepType::PROCESS;
45 if (!strcmp(argv[backend_argc - 1], "-type_clean")) {
47 type = smoke_test::CrashStepType::CLEAN;
48 LOG(DEBUG) << "step will be crashed in clean operation";
51 if (!strcmp(argv[backend_argc - 2], "-idx")) {
52 index = atoi(argv[backend_argc - 1]);
54 LOG(DEBUG) << "Step crash after " << index << " step.";
57 if (!strcmp(argv[backend_argc - 2], "-step_name")) {
58 step_name = argv[backend_argc - 1];
60 LOG(DEBUG) << "Step crash after " << step_name << " step.";
63 if (!strcmp(argv[backend_argc-1], "-remove_plugin_steps")) {
65 remove_plugins = true;
66 LOG(DEBUG) << "Remove parser plugins steps";
69 ci::PkgmgrInstaller pkgmgr_installer;
70 std::shared_ptr<wgt::WgtAppQueryInterface> query_interface(
71 new wgt::WgtAppQueryInterface());
72 auto pkgmgr = ci::PkgMgrInterface::Create(backend_argc, argv,
73 &pkgmgr_installer, query_interface);
75 LOG(ERROR) << "Options of pkgmgr installer cannot be parsed";
80 return RunHybridInstallerWithoutParserPlugins(pkgmgr);
82 return RunCrashHybridInstaller(pkgmgr, index, step_name, type);
84 std::cout << "Exception occurred during testing" << std::endl;