SET(DESTINATION_DIR wgt-backend-ut)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../)
-
# Executables
ADD_EXECUTABLE(${TARGET_SMOKE_TEST}
smoke_test.cc
)
+ADD_EXECUTABLE(${TARGET_SMOKE_TEST_HELPER}
+ smoke_test_helper.cc
+)
+
+TARGET_INCLUDE_DIRECTORIES(${TARGET_SMOKE_TEST} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../)
+TARGET_INCLUDE_DIRECTORIES(${TARGET_SMOKE_TEST_HELPER} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../)
INSTALL(DIRECTORY test_samples/ DESTINATION ${SHAREDIR}/${DESTINATION_DIR}/test_samples)
-APPLY_PKG_CONFIG(smoke_test PUBLIC
+APPLY_PKG_CONFIG(${TARGET_SMOKE_TEST} PUBLIC
Boost
GTEST
)
# FindGTest module do not sets all needed libraries in GTEST_LIBRARIES and
# GTest main libraries is still missing, so additional linking of
# GTEST_MAIN_LIBRARIES is needed.
-target_link_libraries(smoke_test PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_LIBNAME_HYBRID} ${GTEST_MAIN_LIBRARIES})
+target_link_libraries(${TARGET_SMOKE_TEST} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_LIBNAME_HYBRID} ${GTEST_MAIN_LIBRARIES})
+target_link_libraries(${TARGET_SMOKE_TEST_HELPER} PRIVATE ${TARGET_LIBNAME_WGT})
-INSTALL(TARGETS smoke_test DESTINATION ${BINDIR}/${DESTINATION_DIR})
+INSTALL(TARGETS ${TARGET_SMOKE_TEST} DESTINATION ${BINDIR}/${DESTINATION_DIR})
+INSTALL(TARGETS ${TARGET_SMOKE_TEST_HELPER} DESTINATION ${BINDIR}/${DESTINATION_DIR})
#include <common/pkgmgr_registration.h>
#include <common/request.h>
#include <common/step/step_fail.h>
+#include <common/utils/subprocess.h>
#include <gtest/gtest.h>
#include <gtest/gtest-death-test.h>
#include <pkgmgr-info.h>
enum class RequestResult {
NORMAL,
- FAIL,
- CRASH
+ FAIL
};
class TestPkgmgrInstaller : public ci::PkgmgrInstallerInterface {
public:
bool CreatePkgMgrInstaller(pkgmgr_installer** installer,
ci::InstallationMode* mode) {
- *installer = pkgmgr_installer_new();
+ *installer = pkgmgr_installer_offline_new();
if (!*installer)
return false;
*mode = ci::InstallationMode::ONLINE;
HYBRID
};
-class StepCrash : public ci::Step {
- public:
- using Step::Step;
-
- ci::Step::Status process() override {
- raise(SIGSEGV);
- return Status::OK;
- }
- ci::Step::Status clean() override { return ci::Step::Status::OK; }
- ci::Step::Status undo() override { return ci::Step::Status::OK; }
- ci::Step::Status precheck() override { return ci::Step::Status::OK; }
-};
-
void RemoveAllRecoveryFiles() {
bf::path root_path = ci::GetRootAppPath(false);
if (!bf::exists(root_path))
case RequestResult::FAIL:
installer->AddStep<ci::configuration::StepFail>();
break;
- case RequestResult::CRASH:
- installer->AddStep<StepCrash>();
default:
break;
}
TEST_F(SmokeTest, RecoveryMode_ForInstallation) {
bf::path path = kSmokePackagesDirectory / "RecoveryMode_ForInstallation.wgt";
- ASSERT_DEATH(Install(path, PackageType::WGT, RequestResult::CRASH), ".*");
+ Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
+ backend_crash.Run("-i", path.string());
+ ASSERT_NE(backend_crash.Wait(), 0);
std::string pkgid = "smokeapp09";
std::string appid = "smokeapp09.RecoveryModeForInstallation";
bf::path path_old = kSmokePackagesDirectory / "RecoveryMode_ForUpdate.wgt";
bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForUpdate_2.wgt";
RemoveAllRecoveryFiles();
- ASSERT_DEATH(Update(path_old, path_new, PackageType::WGT,
- RequestResult::CRASH), ".*");
+ Subprocess backend_test("/usr/bin/wgt-backend");
+ backend_test.Run("-i", path_old.string());
+ ASSERT_EQ(backend_test.Wait(), 0);
+ Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
+ backend_crash.Run("-i", path_new.string());
+ ASSERT_NE(backend_crash.Wait(), 0);
std::string pkgid = "smokeapp10";
std::string appid = "smokeapp10.RecoveryModeForUpdate";
--- /dev/null
+// Copyright (c) 2015 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 <cerrno>
+
+#include "wgt/wgt_app_query_interface.h"
+#include "wgt/wgt_installer.h"
+
+namespace ci = common_installer;
+
+namespace {
+
+class StepCrash : public ci::Step {
+ public:
+ using Step::Step;
+
+ ci::Step::Status process() override {
+ raise(SIGSEGV);
+ return Status::OK;
+ }
+ ci::Step::Status clean() override { return ci::Step::Status::OK; }
+ ci::Step::Status undo() override { return ci::Step::Status::OK; }
+ ci::Step::Status precheck() override { return ci::Step::Status::OK; }
+};
+
+} // namespace
+
+// this main of test binay in done purely for recovery smoke test.
+int main(int argc, char** argv) {
+ ci::PkgmgrInstaller pkgmgr_installer;
+ wgt::WgtAppQueryInterface query_interface;
+ auto pkgmgr = ci::PkgMgrInterface::Create(argc, argv, &pkgmgr_installer,
+ &query_interface);
+ if (!pkgmgr) {
+ LOG(ERROR) << "Options of pkgmgr installer cannot be parsed";
+ return EINVAL;
+ }
+
+ wgt::WgtInstaller installer(pkgmgr);
+ installer.AddStep<StepCrash>();
+ return (installer.Run() == ci::AppInstaller::Result::OK) ? 0 : 1;
+}
+