ADD_EXECUTABLE(${TARGET_SMOKE_TEST_HELPER}
smoke_test_helper.cc
)
+ADD_EXECUTABLE(${TARGET_HYBRID_SMOKE_TEST_HELPER}
+ hybrid_smoke_test_helper.cc
+)
ADD_EXECUTABLE(${TARGET_MANIFEST_TEST}
manifest_test.cc
)
TARGET_INCLUDE_DIRECTORIES(${TARGET_SMOKE_TEST} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../)
TARGET_INCLUDE_DIRECTORIES(${TARGET_SMOKE_TEST_EXTENSIVE} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../)
TARGET_INCLUDE_DIRECTORIES(${TARGET_SMOKE_TEST_HELPER} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../)
+TARGET_INCLUDE_DIRECTORIES(${TARGET_HYBRID_SMOKE_TEST_HELPER} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../)
TARGET_INCLUDE_DIRECTORIES(${TARGET_MANIFEST_TEST} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../)
TARGET_INCLUDE_DIRECTORIES(${TARGET_WGT_SMOKE_UTILS} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../)
TARGET_LINK_LIBRARIES(${TARGET_SMOKE_TEST} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_LIBNAME_HYBRID} ${GTEST_MAIN_LIBRARIES} ${TARGET_SMOKE_UTILS} ${TARGET_WGT_SMOKE_UTILS})
TARGET_LINK_LIBRARIES(${TARGET_SMOKE_TEST_EXTENSIVE} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_LIBNAME_HYBRID} ${GTEST_MAIN_LIBRARIES} ${TARGET_SMOKE_UTILS} ${TARGET_WGT_SMOKE_UTILS})
TARGET_LINK_LIBRARIES(${TARGET_SMOKE_TEST_HELPER} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_WGT_SMOKE_UTILS})
+TARGET_LINK_LIBRARIES(${TARGET_HYBRID_SMOKE_TEST_HELPER} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_WGT_SMOKE_UTILS} ${TARGET_LIBNAME_HYBRID})
TARGET_LINK_LIBRARIES(${TARGET_MANIFEST_TEST} PRIVATE ${TARGET_LIBNAME_WGT} ${GTEST_MAIN_LIBRARIES})
TARGET_LINK_LIBRARIES(${TARGET_WGT_SMOKE_UTILS} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_LIBNAME_HYBRID} ${TARGET_SMOKE_UTILS})
INSTALL(TARGETS ${TARGET_SMOKE_TEST} DESTINATION ${BINDIR}/${DESTINATION_DIR})
INSTALL(TARGETS ${TARGET_SMOKE_TEST_EXTENSIVE} DESTINATION ${BINDIR}/${DESTINATION_DIR})
INSTALL(TARGETS ${TARGET_SMOKE_TEST_HELPER} DESTINATION ${BINDIR}/${DESTINATION_DIR})
+INSTALL(TARGETS ${TARGET_HYBRID_SMOKE_TEST_HELPER} DESTINATION ${BINDIR}/${DESTINATION_DIR})
INSTALL(TARGETS ${TARGET_MANIFEST_TEST} DESTINATION ${BINDIR}/${DESTINATION_DIR})
INSTALL(TARGETS ${TARGET_WGT_SMOKE_UTILS} DESTINATION ${LIB_INSTALL_DIR})
INSTALL(FILES wgt_smoke_utils.h DESTINATION ${INCLUDEDIR}/app-installers/smoke_tests/)
--- /dev/null
+// Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache-2.0 license that can be
+// found in the LICENSE file.
+
+#include <common/pkgmgr_interface.h>
+#include <manifest_parser/utils/logging.h>
+
+#include "smoke_tests/wgt_smoke_utils.h"
+#include "wgt/utils/wgt_app_query_interface.h"
+
+namespace ci = common_installer;
+
+static int RunCrashHybridInstaller(ci::PkgMgrPtr pkgmgr,
+ int index,
+ std::string step_name,
+ smoke_test::CrashStepType type) {
+ smoke_test::CrashHybridInstaller t(pkgmgr, index, step_name, type);
+
+ if (t.Run() != ci::AppInstaller::Result::OK) {
+ LOG(ERROR) << "CrashHybridInstaller run failure";
+ return 1;
+ }
+ return 0;
+}
+
+static int RunHybridInstallerWithoutParserPlugins(ci::PkgMgrPtr pkgmgr) {
+ smoke_test::HybridInstallerWithoutPasrserPlugins t(pkgmgr);
+
+ if (t.Run() != ci::AppInstaller::Result::OK) {
+ LOG(ERROR) << "HybridInstallerWithoutPasrserPlugins run failure";
+ return 1;
+ }
+ return 0;
+}
+
+// this main of test binay in done purely for recovery smoke test.
+int main(int argc, char** argv) {
+ 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 - 1], "-type_clean")) {
+ backend_argc--;
+ type = smoke_test::CrashStepType::CLEAN;
+ LOG(DEBUG) << "step will be crashed in clean operation";
+ }
+
+ 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-1], "-remove_plugin_steps")) {
+ backend_argc--;
+ remove_plugins = true;
+ LOG(DEBUG) << "Remove parser plugins steps";
+ }
+
+ ci::PkgmgrInstaller pkgmgr_installer;
+ std::shared_ptr<wgt::WgtAppQueryInterface> query_interface(
+ new wgt::WgtAppQueryInterface());
+ auto pkgmgr = ci::PkgMgrInterface::Create(backend_argc, argv,
+ &pkgmgr_installer, query_interface);
+ if (!pkgmgr) {
+ LOG(ERROR) << "Options of pkgmgr installer cannot be parsed";
+ return EINVAL;
+ }
+
+ if (remove_plugins)
+ return RunHybridInstallerWithoutParserPlugins(pkgmgr);
+ else
+ return RunCrashHybridInstaller(pkgmgr, index, step_name, type);
+ } catch (...) {
+ std::cout << "Exception occurred during testing" << std::endl;
+ return 1;
+ }
+}
+
common_installer::PkgMgrPtr pkgmgr) const override;
AppInstallerPtr CreateFailExpectedInstaller(
common_installer::PkgMgrPtr pkgmgr, int fail_at) const override;
+ common_installer::Subprocess CreateSubprocess() const override;
};
#ifdef OVERRIDE_STEPS_BLOCK
#ifdef OVERRIDE_STEPS_BLOCK
#undef OVERRIDE_STEPS_BLOCK
#endif
-#define OVERRIDE_STEPS_BLOCK(STEPS) \
+#define OVERRIDE_STEPS_BLOCK(TYPE, STEPS) \
void STEPS() override { \
- wgt::WgtInstaller::STEPS(); \
+ TYPE::STEPS(); \
if (crash_at_ > -1) \
AddStepAtIndex<StepCrash>(crash_at_, type_); \
else if (step_name_.size()) \
step_name_(step_name), type_(type) { }
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)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, InstallSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, UpdateSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, UninstallSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ReinstallSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, DeltaSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, MoveSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, RecoverySteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, MountInstallSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, MountUpdateSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ManifestDirectInstallSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ManifestDirectUpdateSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ManifestPartialInstallSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ManifestPartialUpdateSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, PartialUninstallSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ReadonlyUpdateInstallSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, ReadonlyUpdateUninstallSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, DisablePkgSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, EnablePkgSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, MigrateExtImgSteps)
+ OVERRIDE_STEPS_BLOCK(wgt::WgtInstaller, RecoverDBSteps)
+
+ int crash_at_;
+ std::string step_name_;
+ CrashStepType type_;
+};
+
+class CrashHybridInstaller : public hybrid::HybridInstaller {
+ public:
+ explicit CrashHybridInstaller(common_installer::PkgMgrPtr pkgmgr,
+ int crash_at, std::string step_name, CrashStepType type) :
+ hybrid::HybridInstaller(pkgmgr), crash_at_(crash_at),
+ step_name_(step_name), type_(type) { }
+
+ private:
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, InstallSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, UpdateSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, UninstallSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ReinstallSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, DeltaSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, MoveSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, RecoverySteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, MountInstallSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, MountUpdateSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ManifestDirectInstallSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ManifestDirectUpdateSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ManifestPartialInstallSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ManifestPartialUpdateSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, PartialUninstallSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ReadonlyUpdateInstallSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, ReadonlyUpdateUninstallSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, DisablePkgSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, EnablePkgSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, MigrateExtImgSteps)
+ OVERRIDE_STEPS_BLOCK(hybrid::HybridInstaller, RecoverDBSteps)
int crash_at_;
std::string step_name_;