SET(TARGET_LIBNAME_TPK "tpk-installer")
SET(TARGET_TPK_BACKEND "tpk-backend")
+SET(TARGET_SMOKE_TEST "smoke-test")
+SET(TARGET_SMOKE_TEST_HELPER "smoke-test-helper")
+
ADD_DEFINITIONS("-Wall")
ADD_DEFINITIONS("-Wextra")
ADD_DEFINITIONS("-fPIE")
<domain name="_" />
</request>
<assign>
- <filesystem path="/usr/bin/tpk-backend-ut/smoke_test" exec_label="User" />
+ <filesystem path="/usr/bin/tpk-backend-ut/smoke-test" exec_label="User" />
+ <filesystem path="/usr/bin/tpk-backend-ut/smoke-test-helper" exec_label="User" />
</assign>
</manifest>
SET(DESTINATION_DIR tpk-backend-ut)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../)
-
# Executables
-ADD_EXECUTABLE(smoke_test
+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_TPK} ${GTEST_MAIN_LIBRARIES})
+target_link_libraries(${TARGET_SMOKE_TEST} PRIVATE ${TARGET_LIBNAME_TPK} ${GTEST_MAIN_LIBRARIES})
+target_link_libraries(${TARGET_SMOKE_TEST_HELPER} PRIVATE ${TARGET_LIBNAME_TPK})
-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>
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;
}
};
-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_Tpk_Installation) {
bf::path path = kSmokePackagesDirectory / "RecoveryMode_Tpk_Installation.tpk";
- ASSERT_DEATH(Install(path, RequestResult::CRASH), ".*");
+ RemoveAllRecoveryFiles();
+ ci::Subprocess backend_crash("/usr/bin/tpk-backend-ut/smoke-test-helper");
+ backend_crash.Run("-i", path.string());
+ ASSERT_NE(backend_crash.Wait(), 0);
std::string pkgid = "smokeapp15";
std::string appid = "smokeapp15.RecoveryModeTpkInstallation";
bf::path path_old = kSmokePackagesDirectory / "RecoveryMode_Tpk_Update.tpk";
bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_Tpk_Update_2.tpk";
RemoveAllRecoveryFiles();
- ASSERT_DEATH(Update(path_old, path_new, RequestResult::CRASH), ".*");
+ ci::Subprocess backend("/usr/bin/tpk-backend");
+ backend.Run("-i", path_old.string());
+ ASSERT_EQ(backend.Wait(), 0);
+ ci::Subprocess backend_crash("/usr/bin/tpk-backend-ut/smoke-test-helper");
+ backend_crash.Run("-i", path_new.string());
+ ASSERT_NE(backend_crash.Wait(), 0);
std::string pkgid = "smokeapp16";
std::string appid = "smokeapp16.RecoveryModeTpkUpdate";
--- /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 <common/step/step.h>
+#include <manifest_parser/utils/logging.h>
+
+#include <iostream>
+
+#include "tpk/tpk_app_query_interface.h"
+#include "tpk/tpk_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 version of backend will crash in the end
+// it is used for recovery testcase
+int main(const int argc, char* argv[]) {
+ ci::PkgmgrInstaller pkgmgr_installer;
+ tpk::TpkAppQueryInterface interface;
+ ci::PkgMgrPtr pkgmgr = ci::PkgMgrInterface::Create(argc, argv,
+ &pkgmgr_installer,
+ &interface);
+ if (!pkgmgr) {
+ LOG(ERROR) << "Failed to create pkgmgr interface";
+ return -1;
+ }
+
+ tpk::TpkInstaller t(pkgmgr);
+ t.AddStep<StepCrash>();
+ if (t.Run() != ci::AppInstaller::Result::OK) {
+ LOG(ERROR) << "TpkInstaller run failure";
+ return -1;
+ }
+ return 0;
+}