Fix smoke test helper 45/204345/5
authorSangyoon Jang <jeremy.jang@samsung.com>
Tue, 23 Apr 2019 07:39:37 +0000 (16:39 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Tue, 4 Jun 2019 05:40:29 +0000 (05:40 +0000)
To use custom step, we need to derive a new class.
(refer: https://review.tizen.org/gerrit/c/platform/core/appfw/app-installers/+/203760)

Change-Id: I8eadd437e8a1a2b20a34fa0a3d7f0cd8b75d0f96
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/unit_tests/smoke_test_helper.cc

index 24c4f0a1af4cdaacb4824da12ea4874ab4a81bd7..d826c9d62ad779f8af7fa24a7f80579563ab2731 100644 (file)
@@ -30,6 +30,45 @@ class StepCrash : public ci::Step {
   STEP_NAME(Crash)
 };
 
+#define OVERRIDE_STEPS_BLOCK(STEPS)                                            \
+  void STEPS() override {                                                      \
+    tpk::TpkInstaller::STEPS();                                                \
+    if (crash_at_ > -1)                                                        \
+      AddStepAtIndex<StepCrash>(crash_at_);                                    \
+    else                                                                       \
+      AddStep<StepCrash>();                                                    \
+  }                                                                            \
+
+class CrashTpkInstaller : public tpk::TpkInstaller {
+ public:
+  explicit CrashTpkInstaller(ci::PkgMgrPtr pkgmgr, int crash_at)
+      : tpk::TpkInstaller(pkgmgr), crash_at_(crash_at) { }
+
+ private:
+  OVERRIDE_STEPS_BLOCK(InstallSteps)
+  OVERRIDE_STEPS_BLOCK(UpdateSteps)
+  OVERRIDE_STEPS_BLOCK(UninstallSteps)
+  OVERRIDE_STEPS_BLOCK(ReinstallSteps)
+  OVERRIDE_STEPS_BLOCK(DeltaSteps)
+  OVERRIDE_STEPS_BLOCK(MoveSteps)
+  OVERRIDE_STEPS_BLOCK(RecoverySteps)
+  OVERRIDE_STEPS_BLOCK(MountInstallSteps)
+  OVERRIDE_STEPS_BLOCK(MountUpdateSteps)
+  OVERRIDE_STEPS_BLOCK(ManifestDirectInstallSteps)
+  OVERRIDE_STEPS_BLOCK(ManifestDirectUpdateSteps)
+  OVERRIDE_STEPS_BLOCK(ManifestPartialInstallSteps)
+  OVERRIDE_STEPS_BLOCK(ManifestPartialUpdateSteps)
+  OVERRIDE_STEPS_BLOCK(PartialUninstallSteps)
+  OVERRIDE_STEPS_BLOCK(ReadonlyUpdateInstallSteps)
+  OVERRIDE_STEPS_BLOCK(ReadonlyUpdateUninstallSteps)
+  OVERRIDE_STEPS_BLOCK(DisablePkgSteps)
+  OVERRIDE_STEPS_BLOCK(EnablePkgSteps)
+  OVERRIDE_STEPS_BLOCK(MigrateExtImgSteps)
+  OVERRIDE_STEPS_BLOCK(RecoverDBSteps)
+
+  int crash_at_;
+};
+
 }  // namespace
 
 // This version of backend will crash in the end
@@ -53,15 +92,10 @@ int main(const int argc, char* argv[]) {
     return -1;
   }
 
-  tpk::TpkInstaller t(pkgmgr);
-  if (index != -1) {
-      t.AddStepAtIndex<StepCrash>(index);
-  } else {
-      t.AddStep<StepCrash>();
-  }
+  ::CrashTpkInstaller t(pkgmgr, index);
 
   if (t.Run() != ci::AppInstaller::Result::OK) {
-    LOG(ERROR) << "TpkInstaller run failure";
+    LOG(ERROR) << "CrashTpkInstaller run failure";
     return -1;
   }
   return 0;