Fix wgt lib to extract manifest and icon only
[platform/core/appfw/wgt-backend.git] / src / unit_tests / smoke_test_helper.cc
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.
4
5 #include <common/pkgmgr_interface.h>
6 #include <cerrno>
7
8 #include "wgt/wgt_app_query_interface.h"
9 #include "wgt/wgt_installer.h"
10
11 namespace ci = common_installer;
12
13 namespace {
14
15 class StepCrash : public ci::Step {
16  public:
17   using Step::Step;
18
19   ci::Step::Status process() override {
20     raise(SIGSEGV);
21     return Status::OK;
22   }
23   ci::Step::Status clean() override { return ci::Step::Status::OK; }
24   ci::Step::Status undo() override { return ci::Step::Status::OK; }
25   ci::Step::Status precheck() override { return ci::Step::Status::OK; }
26
27   STEP_NAME(Crash)
28 };
29
30 }  // namespace
31
32 // this main of test binay in done purely for recovery smoke test.
33 int main(int argc, char** argv) {
34   ci::PkgmgrInstaller pkgmgr_installer;
35   wgt::WgtAppQueryInterface query_interface;
36   auto pkgmgr = ci::PkgMgrInterface::Create(argc, argv, &pkgmgr_installer,
37                                             &query_interface);
38   if (!pkgmgr) {
39     LOG(ERROR) << "Options of pkgmgr installer cannot be parsed";
40     return EINVAL;
41   }
42
43   wgt::WgtInstaller installer(pkgmgr);
44   installer.AddStep<StepCrash>();
45   return (installer.Run() == ci::AppInstaller::Result::OK) ? 0 : 1;
46 }
47