#include <boost/filesystem/path.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/system/error_code.hpp>
-#include <common/backup_paths.h>
+#include <common/paths.h>
#include <common/pkgmgr_interface.h>
-#include <common/pkgmgr_registration.h>
+#include <common/pkgmgr_query.h>
#include <common/request.h>
-#include <common/step/step_fail.h>
+#include <common/step/configuration/step_fail.h>
+#include <common/tzip_interface.h>
+#include <common/utils/subprocess.h>
#include <gtest/gtest.h>
#include <gtest/gtest-death-test.h>
#include <pkgmgr-info.h>
#include <array>
#include <cstdio>
#include <cstdlib>
+#include <vector>
+#include "hybrid/hybrid_installer.h"
#include "wgt/wgt_app_query_interface.h"
#include "wgt/wgt_installer.h"
namespace {
+const bf::path kSmokePackagesDirectory =
+ "/usr/share/wgt-backend-ut/test_samples/smoke/";
+
const char kApplicationDir[] = ".applications";
const char kApplicationDirBackup[] = ".applications.bck";
const char KUserAppsDir[] = "apps_rw";
const char KUserAppsDirBackup[] = "apps_rw.bck";
+const char kUserDataBaseDir[] = "/opt/dbspace/user";
enum class RequestResult {
NORMAL,
- FAIL,
- CRASH
+ FAIL
};
-class StepCrash : public ci::Step {
+class ScopedTzipInterface {
public:
- using Step::Step;
+ explicit ScopedTzipInterface(const std::string& pkgid)
+ : pkg_path_(bf::path(ci::GetRootAppPath(false)) / pkgid),
+ interface_(ci::GetMountLocation(pkg_path_)) {
+ interface_.MountZip(ci::GetZipPackageLocation(pkg_path_, pkgid));
+ }
- ci::Step::Status process() override {
- raise(SIGSEGV);
- return Status::OK;
+ ~ScopedTzipInterface() {
+ interface_.UnmountZip();
}
- 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; }
+
+ private:
+ bf::path pkg_path_;
+ ci::TzipInterface interface_;
+};
+
+class TestPkgmgrInstaller : public ci::PkgmgrInstallerInterface {
+ public:
+ bool CreatePkgMgrInstaller(pkgmgr_installer** installer,
+ ci::InstallationMode* mode) {
+ *installer = pkgmgr_installer_offline_new();
+ if (!*installer)
+ return false;
+ *mode = ci::InstallationMode::ONLINE;
+ return true;
+ }
+
+ bool ShouldCreateSignal() const {
+ return false;
+ }
+};
+
+enum class PackageType {
+ WGT,
+ HYBRID
};
+bool TouchFile(const bf::path& path) {
+ FILE* f = fopen(path.c_str(), "w+");
+ if (!f)
+ return false;
+ fclose(f);
+ return true;
+}
+
void RemoveAllRecoveryFiles() {
- bf::path root_path = ci::GetRootAppPath();
+ bf::path root_path = ci::GetRootAppPath(false);
+ if (!bf::exists(root_path))
+ return;
for (auto& dir_entry : boost::make_iterator_range(
bf::directory_iterator(root_path), bf::directory_iterator())) {
if (bf::is_regular_file(dir_entry)) {
}
bf::path FindRecoveryFile() {
- bf::path root_path = ci::GetRootAppPath();
+ bf::path root_path = ci::GetRootAppPath(false);
for (auto& dir_entry : boost::make_iterator_range(
bf::directory_iterator(root_path), bf::directory_iterator())) {
if (bf::is_regular_file(dir_entry)) {
bool ValidateFileContentInPackage(const std::string& pkgid,
const std::string& relative,
const std::string& expected) {
- bf::path root_path = ci::GetRootAppPath();
+ bf::path root_path = ci::GetRootAppPath(false);
bf::path file_path = root_path / pkgid / relative;
if (!bf::exists(file_path)) {
LOG(ERROR) << file_path << " doesn't exist";
return content == expected;
}
-void ValidatePackageFS(const std::string& pkgid, const std::string& appid) {
- bf::path root_path = ci::GetRootAppPath();
+void ValidatePackageFS(const std::string& pkgid,
+ const std::vector<std::string>& appids) {
+ bf::path root_path = ci::GetRootAppPath(false);
bf::path package_path = root_path / pkgid;
- bf::path binary_path = package_path / "bin" / appid;
bf::path data_path = package_path / "data";
bf::path shared_path = package_path / "shared";
bf::path cache_path = package_path / "cache";
ASSERT_TRUE(bf::exists(root_path));
ASSERT_TRUE(bf::exists(package_path));
- ASSERT_TRUE(bf::exists(binary_path));
ASSERT_TRUE(bf::exists(data_path));
ASSERT_TRUE(bf::exists(shared_path));
ASSERT_TRUE(bf::exists(cache_path));
bf::path manifest_path =
- bf::path(getUserManifestPath(getuid())) / (pkgid + ".xml");
- bf::path icon_path = bf::path(getIconPath(getuid())) / (appid + ".png");
+ bf::path(getUserManifestPath(getuid(), false)) / (pkgid + ".xml");
ASSERT_TRUE(bf::exists(manifest_path));
- ASSERT_TRUE(bf::exists(icon_path));
+
+ for (auto& appid : appids) {
+ bf::path binary_path = package_path / "bin" / appid;
+ ASSERT_TRUE(bf::exists(binary_path));
+ }
bf::path widget_root_path = package_path / "res" / "wgt";
bf::path config_path = widget_root_path / "config.xml";
// backups should not exist
bf::path package_backup = ci::GetBackupPathForPackagePath(package_path);
bf::path manifest_backup = ci::GetBackupPathForManifestFile(manifest_path);
- bf::path icon_backup = ci::GetBackupPathForIconFile(icon_path);
ASSERT_FALSE(bf::exists(package_backup));
ASSERT_FALSE(bf::exists(manifest_backup));
- ASSERT_FALSE(bf::exists(icon_backup));
}
-void PackageCheckCleanup(const std::string& pkgid, const std::string& appid) {
- bf::path root_path = ci::GetRootAppPath();
+void PackageCheckCleanup(const std::string& pkgid,
+ const std::vector<std::string>&) {
+ bf::path root_path = ci::GetRootAppPath(false);
bf::path package_path = root_path / pkgid;
ASSERT_FALSE(bf::exists(package_path));
bf::path manifest_path =
- bf::path(getUserManifestPath(getuid())) / (pkgid + ".xml");
- bf::path icon_path = bf::path(getIconPath(getuid())) / (appid + ".png");
+ bf::path(getUserManifestPath(getuid(), false)) / (pkgid + ".xml");
ASSERT_FALSE(bf::exists(manifest_path));
- ASSERT_FALSE(bf::exists(icon_path));
// backups should not exist
bf::path package_backup = ci::GetBackupPathForPackagePath(package_path);
bf::path manifest_backup = ci::GetBackupPathForManifestFile(manifest_path);
- bf::path icon_backup = ci::GetBackupPathForIconFile(icon_path);
ASSERT_FALSE(bf::exists(package_backup));
ASSERT_FALSE(bf::exists(manifest_backup));
- ASSERT_FALSE(bf::exists(icon_backup));
}
-void ValidatePackage(const std::string& pkgid, const std::string& appid) {
- ASSERT_TRUE(ci::IsPackageInstalled(pkgid, ci::GetRequestMode()));
- ValidatePackageFS(pkgid, appid);
+void ValidatePackage(const std::string& pkgid,
+ const std::vector<std::string>& appids) {
+ ASSERT_TRUE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode()));
+ ValidatePackageFS(pkgid, appids);
}
void CheckPackageNonExistance(const std::string& pkgid,
- const std::string& appid) {
- ASSERT_FALSE(ci::IsPackageInstalled(pkgid, ci::GetRequestMode()));
- PackageCheckCleanup(pkgid, appid);
+ const std::vector<std::string>& appids) {
+ ASSERT_FALSE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode()));
+ PackageCheckCleanup(pkgid, appids);
}
std::unique_ptr<ci::AppQueryInterface> CreateQueryInterface() {
return query_interface;
}
-std::unique_ptr<ci::AppInstaller> CreateInstaller(ci::PkgMgrPtr pkgmgr) {
- std::unique_ptr<ci::AppInstaller> installer(new wgt::WgtInstaller(pkgmgr));
- return installer;
+std::unique_ptr<ci::AppInstaller> CreateInstaller(ci::PkgMgrPtr pkgmgr,
+ PackageType type) {
+ switch (type) {
+ case PackageType::WGT:
+ return std::unique_ptr<ci::AppInstaller>(new wgt::WgtInstaller(pkgmgr));
+ case PackageType::HYBRID:
+ return std::unique_ptr<ci::AppInstaller>(
+ new hybrid::HybridInstaller(pkgmgr));
+ default:
+ LOG(ERROR) << "Unknown installer type";
+ return nullptr;
+ }
}
ci::AppInstaller::Result RunInstallerWithPkgrmgr(ci::PkgMgrPtr pkgmgr,
+ PackageType type,
RequestResult mode) {
- std::unique_ptr<ci::AppInstaller> installer = CreateInstaller(pkgmgr);
+ std::unique_ptr<ci::AppInstaller> installer = CreateInstaller(pkgmgr, type);
switch (mode) {
case RequestResult::FAIL:
installer->AddStep<ci::configuration::StepFail>();
break;
- case RequestResult::CRASH:
- installer->AddStep<StepCrash>();
default:
break;
}
return installer->Run();
}
-
-ci::AppInstaller::Result Install(const bf::path& path,
- RequestResult mode = RequestResult::NORMAL) {
- const char* argv[] = {"", "-i", path.c_str()};
+ci::AppInstaller::Result CallBackend(int argc,
+ const char* argv[],
+ PackageType type,
+ RequestResult mode = RequestResult::NORMAL
+ ) {
+ TestPkgmgrInstaller pkgmgr_installer;
std::unique_ptr<ci::AppQueryInterface> query_interface =
CreateQueryInterface();
auto pkgmgr =
- ci::PkgMgrInterface::Create(SIZEOFARRAY(argv), const_cast<char**>(argv),
- query_interface.get());
+ ci::PkgMgrInterface::Create(argc, const_cast<char**>(argv),
+ &pkgmgr_installer, query_interface.get());
if (!pkgmgr) {
LOG(ERROR) << "Failed to initialize pkgmgr interface";
return ci::AppInstaller::Result::UNKNOWN;
}
- return RunInstallerWithPkgrmgr(pkgmgr, mode);
+ return RunInstallerWithPkgrmgr(pkgmgr, type, mode);
+}
+
+ci::AppInstaller::Result Install(const bf::path& path,
+ PackageType type,
+ RequestResult mode = RequestResult::NORMAL) {
+ const char* argv[] = {"", "-i", path.c_str()};
+ return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
}
ci::AppInstaller::Result Update(const bf::path& path_old,
const bf::path& path_new,
+ PackageType type,
RequestResult mode = RequestResult::NORMAL) {
- if (Install(path_old) != ci::AppInstaller::Result::OK) {
+ if (Install(path_old, type) != ci::AppInstaller::Result::OK) {
LOG(ERROR) << "Failed to install application. Cannot update";
return ci::AppInstaller::Result::UNKNOWN;
}
- return Install(path_new, mode);
+ return Install(path_new, type, mode);
+}
+
+ci::AppInstaller::Result MountInstall(const bf::path& path,
+ PackageType type, RequestResult mode = RequestResult::NORMAL) {
+ const char* argv[] = {"", "-w", path.c_str()};
+ return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
+}
+
+ci::AppInstaller::Result MountUpdate(const bf::path& path_old,
+ const bf::path& path_new, PackageType type,
+ RequestResult mode = RequestResult::NORMAL) {
+ if (MountInstall(path_old, type) != ci::AppInstaller::Result::OK) {
+ LOG(ERROR) << "Failed to mount-install application. Cannot mount-update";
+ return ci::AppInstaller::Result::UNKNOWN;
+ }
+ return MountInstall(path_new, type, mode);
}
ci::AppInstaller::Result Uninstall(const std::string& pkgid,
+ PackageType type,
RequestResult mode = RequestResult::NORMAL) {
const char* argv[] = {"", "-d", pkgid.c_str()};
- std::unique_ptr<ci::AppQueryInterface> query_interface =
- CreateQueryInterface();
- auto pkgmgr =
- ci::PkgMgrInterface::Create(SIZEOFARRAY(argv), const_cast<char**>(argv),
- query_interface.get());
- if (!pkgmgr) {
- LOG(ERROR) << "Failed to initialize pkgmgr interface";
- return ci::AppInstaller::Result::UNKNOWN;
- }
- return RunInstallerWithPkgrmgr(pkgmgr, mode);
+ return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
}
ci::AppInstaller::Result Reinstall(const bf::path& path,
const bf::path& delta_dir,
+ PackageType type,
RequestResult mode = RequestResult::NORMAL) {
- if (Install(path) != ci::AppInstaller::Result::OK) {
+ if (Install(path, type) != ci::AppInstaller::Result::OK) {
LOG(ERROR) << "Failed to install application. Cannot perform RDS";
return ci::AppInstaller::Result::UNKNOWN;
}
const char* argv[] = {"", "-r", delta_dir.c_str()};
- std::unique_ptr<ci::AppQueryInterface> query_interface =
- CreateQueryInterface();
- auto pkgmgr =
- ci::PkgMgrInterface::Create(SIZEOFARRAY(argv), const_cast<char**>(argv),
- query_interface.get());
- if (!pkgmgr) {
- LOG(ERROR) << "Failed to initialize pkgmgr interface";
- return ci::AppInstaller::Result::UNKNOWN;
- }
- return RunInstallerWithPkgrmgr(pkgmgr, mode);
+ return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
}
ci::AppInstaller::Result DeltaInstall(const bf::path& path,
- const bf::path& delta_package) {
- if (Install(path) != ci::AppInstaller::Result::OK) {
- LOG(ERROR) << "Failed to install application. Cannot perform RDS";
+ const bf::path& delta_package, PackageType type) {
+ if (Install(path, type) != ci::AppInstaller::Result::OK) {
+ LOG(ERROR) << "Failed to install application. Cannot perform delta update";
return ci::AppInstaller::Result::UNKNOWN;
}
- return Install(delta_package);
+ return Install(delta_package, type);
+}
+
+ci::AppInstaller::Result Clear(const std::string& pkgid,
+ PackageType type,
+ RequestResult mode = RequestResult::NORMAL) {
+ const char* argv[] = {"", "-c", pkgid.c_str()};
+ return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
+}
+
+ci::AppInstaller::Result EnablePackage(const std::string& pkgid,
+ PackageType type,
+ RequestResult mode = RequestResult::NORMAL) {
+ const char* argv[] = {"", "-A", pkgid.c_str()};
+ return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
+}
+
+ci::AppInstaller::Result DisablePackage(const std::string& pkgid,
+ PackageType type,
+ RequestResult mode = RequestResult::NORMAL) {
+ const char* argv[] = {"", "-D", pkgid.c_str()};
+ return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
}
ci::AppInstaller::Result Recover(const bf::path& recovery_file,
+ PackageType type,
RequestResult mode = RequestResult::NORMAL) {
- const char* argv[] = {"", "-e", recovery_file.c_str()};
+ const char* argv[] = {"", "-b", recovery_file.c_str()};
+ TestPkgmgrInstaller pkgmgr_installer;
std::unique_ptr<ci::AppQueryInterface> query_interface =
CreateQueryInterface();
auto pkgmgr =
ci::PkgMgrInterface::Create(SIZEOFARRAY(argv), const_cast<char**>(argv),
- query_interface.get());
+ &pkgmgr_installer, query_interface.get());
if (!pkgmgr) {
LOG(ERROR) << "Failed to initialize pkgmgr interface";
return ci::AppInstaller::Result::UNKNOWN;
}
- return RunInstallerWithPkgrmgr(pkgmgr, mode);
+ return RunInstallerWithPkgrmgr(pkgmgr, type, mode);
}
} // namespace
explicit SmokeEnvironment(const bf::path& home) : home_(home) {
}
void SetUp() override {
+ bf::path UserDBDir = bf::path(kUserDataBaseDir) / std::to_string(getuid());
+ bf::path UserDBDirBackup = UserDBDir.string() + std::string(".bck");
+
bs::error_code error;
bf::remove_all(home_ / kApplicationDirBackup, error);
bf::remove_all(home_ / KUserAppsDirBackup, error);
+ bf::remove_all(UserDBDirBackup, error);
if (bf::exists(home_ / KUserAppsDir)) {
bf::rename(home_ / KUserAppsDir, home_ / KUserAppsDirBackup, error);
+ if (error)
+ LOG(ERROR) << "Failed to setup test environment. Does some previous"
+ << " test crashed? Directory: "
+ << (home_ / KUserAppsDirBackup) << " should not exist.";
assert(!error);
}
if (bf::exists(home_ / kApplicationDir)) {
bf::rename(home_ / kApplicationDir, home_ / kApplicationDirBackup, error);
+ if (error)
+ LOG(ERROR) << "Failed to setup test environment. Does some previous"
+ << " test crashed? Directory: "
+ << (home_ / kApplicationDirBackup) << " should not exist.";
+ assert(!error);
+ }
+ if (bf::exists(UserDBDir)) {
+ bf::rename(UserDBDir, UserDBDirBackup, error);
+ if (error)
+ LOG(ERROR) << "Failed to setup test environment. Does some previous"
+ << " test crashed? Directory: "
+ << UserDBDirBackup << " should not exist.";
assert(!error);
}
}
void TearDown() override {
+ bf::path UserDBDir = bf::path(kUserDataBaseDir) / std::to_string(getuid());
+ bf::path UserDBDirBackup = UserDBDir.string() + std::string(".bck");
+
bs::error_code error;
bf::remove_all(home_ / kApplicationDir, error);
bf::remove_all(home_ / KUserAppsDir, error);
+ bf::remove_all(UserDBDir, error);
if (bf::exists(home_ / KUserAppsDirBackup))
bf::rename(home_ / KUserAppsDirBackup, home_ / KUserAppsDir, error);
if (bf::exists(home_ / kApplicationDirBackup))
bf::rename(home_ / kApplicationDirBackup, home_ / kApplicationDir, error);
+ if (bf::exists(UserDBDirBackup))
+ bf::rename(UserDBDirBackup, UserDBDir, error);
}
private:
};
TEST_F(SmokeTest, InstallationMode) {
- bf::path path = "/usr/share/app-installers-ut/test_samples/smoke/InstallationMode.wgt"; // NOLINT
+ bf::path path = kSmokePackagesDirectory / "InstallationMode.wgt";
std::string pkgid = "smokeapp03";
std::string appid = "smokeapp03.InstallationMode";
- ASSERT_EQ(Install(path), ci::AppInstaller::Result::OK);
- ValidatePackage(pkgid, appid);
+ ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
+ ValidatePackage(pkgid, {appid});
}
TEST_F(SmokeTest, UpdateMode) {
- bf::path path_old = "/usr/share/app-installers-ut/test_samples/smoke/UpdateMode.wgt"; // NOLINT
- bf::path path_new = "/usr/share/app-installers-ut/test_samples/smoke/UpdateMode_2.wgt"; // NOLINT
+ bf::path path_old = kSmokePackagesDirectory / "UpdateMode.wgt";
+ bf::path path_new = kSmokePackagesDirectory / "UpdateMode_2.wgt";
std::string pkgid = "smokeapp04";
std::string appid = "smokeapp04.UpdateMode";
- ASSERT_EQ(Update(path_old, path_new), ci::AppInstaller::Result::OK);
- ValidatePackage(pkgid, appid);
+ ASSERT_EQ(Update(path_old, path_new, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ ValidatePackage(pkgid, {appid});
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
}
TEST_F(SmokeTest, DeinstallationMode) {
- bf::path path = "/usr/share/app-installers-ut/test_samples/smoke/DeinstallationMode.wgt"; // NOLINT
+ bf::path path = kSmokePackagesDirectory / "DeinstallationMode.wgt";
std::string pkgid = "smokeapp05";
std::string appid = "smokeapp05.DeinstallationMode";
- ASSERT_EQ(Install(path),
+ ASSERT_EQ(Install(path, PackageType::WGT),
ci::AppInstaller::Result::OK);
- ASSERT_EQ(Uninstall(pkgid), ci::AppInstaller::Result::OK);
- CheckPackageNonExistance(pkgid, appid);
+ ASSERT_EQ(Uninstall(pkgid, PackageType::WGT), ci::AppInstaller::Result::OK);
+ CheckPackageNonExistance(pkgid, {appid});
}
TEST_F(SmokeTest, RDSMode) {
- bf::path path = "/usr/share/app-installers-ut/test_samples/smoke/RDSMode.wgt"; // NOLINT
- std::string delta_directory = "/usr/share/app-installers-ut/test_samples/smoke/delta_dir/"; // NOLINT
+ bf::path path = kSmokePackagesDirectory / "RDSMode.wgt";
+ bf::path delta_directory = kSmokePackagesDirectory / "delta_dir/";
std::string pkgid = "smokeapp11";
std::string appid = "smokeapp11.RDSMode";
- ASSERT_EQ(Reinstall(path, delta_directory),
+ ASSERT_EQ(Reinstall(path, delta_directory, PackageType::WGT),
ci::AppInstaller::Result::OK);
- ValidatePackage(pkgid, appid);
+ ValidatePackage(pkgid, {appid});
// Check delta modifications
- bf::path root_path = ci::GetRootAppPath();
+ bf::path root_path = ci::GetRootAppPath(false);
ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "DELETED"));
ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "ADDED"));
ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "2\n");
}
+TEST_F(SmokeTest, EnablePkg) {
+ bf::path path = kSmokePackagesDirectory / "EnablePkg.wgt";
+ std::string pkgid = "smokeapp22";
+ ASSERT_EQ(Install(path, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ ASSERT_EQ(DisablePackage(pkgid, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ ASSERT_EQ(EnablePackage(pkgid, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+
+ ASSERT_TRUE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode()));
+}
+
+TEST_F(SmokeTest, DisablePkg) {
+ bf::path path = kSmokePackagesDirectory / "DisablePkg.wgt";
+ std::string pkgid = "smokeapp21";
+ std::string appid = "smokeapp21.DisablePkg";
+ ASSERT_EQ(Install(path, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ ASSERT_EQ(DisablePackage(pkgid, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ ASSERT_FALSE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode()));
+ ValidatePackageFS(pkgid, {appid});
+}
+
+TEST_F(SmokeTest, ClearMode) {
+ bf::path path = kSmokePackagesDirectory / "ClearMode.wgt";
+ std::string pkgid = "smokeapp20";
+ std::string appid = "smokeapp20.ClearMode";
+ ASSERT_EQ(Install(path, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ bf::path root_path = ci::GetRootAppPath(false);
+ bs::error_code error;
+ bf::create_directory(root_path / pkgid / "data" / "dir", error);
+ ASSERT_FALSE(error);
+ ASSERT_TRUE(TouchFile(root_path / pkgid / "data" / "dir" / "file"));
+ ASSERT_TRUE(TouchFile(root_path / pkgid / "data" / "file"));
+ ASSERT_EQ(Clear(pkgid, PackageType::WGT), ci::AppInstaller::Result::OK);
+ ValidatePackage(pkgid, {appid});
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "data" / "dir" / "file"));
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "file"));
+}
+
TEST_F(SmokeTest, DeltaMode) {
- bf::path path = "/usr/share/app-installers-ut/test_samples/smoke/DeltaMode.wgt"; // NOLINT
- std::string delta_package = "/usr/share/app-installers-ut/test_samples/smoke/DeltaMode.delta"; // NOLINT
+ bf::path path = kSmokePackagesDirectory / "DeltaMode.wgt";
+ bf::path delta_package = kSmokePackagesDirectory / "DeltaMode.delta";
std::string pkgid = "smokeapp17";
std::string appid = "smokeapp17.DeltaMode";
- ASSERT_EQ(DeltaInstall(path, delta_package),
+ ASSERT_EQ(DeltaInstall(path, delta_package, PackageType::WGT),
ci::AppInstaller::Result::OK);
- ValidatePackage(pkgid, appid);
+ ValidatePackage(pkgid, {appid});
// Check delta modifications
- bf::path root_path = ci::GetRootAppPath();
+ bf::path root_path = ci::GetRootAppPath(false);
ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "DELETED"));
ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "ADDED"));
ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "css" / "style.css")); // NOLINT
}
TEST_F(SmokeTest, RecoveryMode_ForInstallation) {
- bf::path path = "/usr/share/app-installers-ut/test_samples/smoke/RecoveryMode_ForInstallation.wgt"; // NOLINT
- ASSERT_DEATH(Install(path, RequestResult::CRASH), ".*");
+ bf::path path = kSmokePackagesDirectory / "RecoveryMode_ForInstallation.wgt";
+ 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 recovery_file = FindRecoveryFile();
ASSERT_FALSE(recovery_file.empty());
- ASSERT_EQ(Recover(recovery_file),
+ ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
ci::AppInstaller::Result::OK);
- CheckPackageNonExistance(pkgid, appid);
+ CheckPackageNonExistance(pkgid, {appid});
}
TEST_F(SmokeTest, RecoveryMode_ForUpdate) {
- bf::path path_old = "/usr/share/app-installers-ut/test_samples/smoke/RecoveryMode_ForUpdate.wgt"; // NOLINT
- bf::path path_new = "/usr/share/app-installers-ut/test_samples/smoke/RecoveryMode_ForUpdate_2.wgt"; // NOLINT
+ 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, 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";
bf::path recovery_file = FindRecoveryFile();
ASSERT_FALSE(recovery_file.empty());
- ASSERT_EQ(Recover(recovery_file),
+ ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
ci::AppInstaller::Result::OK);
- ValidatePackage(pkgid, appid);
+ ValidatePackage(pkgid, {appid});
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
}
TEST_F(SmokeTest, InstallationMode_GoodSignature) {
- bf::path path = "/usr/share/app-installers-ut/test_samples/smoke/InstallationMode_GoodSignature.wgt"; // NOLINT
- ASSERT_EQ(Install(path), ci::AppInstaller::Result::OK);
+ bf::path path = kSmokePackagesDirectory / "InstallationMode_GoodSignature.wgt"; // NOLINT
+ ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
}
TEST_F(SmokeTest, InstallationMode_WrongSignature) {
- bf::path path = "/usr/share/app-installers-ut/test_samples/smoke/InstallationMode_WrongSignature.wgt"; // NOLINT
- ASSERT_EQ(Install(path), ci::AppInstaller::Result::ERROR);
+ bf::path path = kSmokePackagesDirectory / "InstallationMode_WrongSignature.wgt"; // NOLINT
+ ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::ERROR);
}
TEST_F(SmokeTest, InstallationMode_Rollback) {
- bf::path path = "/usr/share/app-installers-ut/test_samples/smoke/InstallationMode_Rollback.wgt"; // NOLINT
+ bf::path path = kSmokePackagesDirectory / "InstallationMode_Rollback.wgt";
std::string pkgid = "smokeapp06";
std::string appid = "smokeapp06.InstallationModeRollback";
- ASSERT_EQ(Install(path, RequestResult::FAIL),
+ ASSERT_EQ(Install(path, PackageType::WGT, RequestResult::FAIL),
ci::AppInstaller::Result::ERROR);
- CheckPackageNonExistance(pkgid, appid);
+ CheckPackageNonExistance(pkgid, {appid});
}
TEST_F(SmokeTest, UpdateMode_Rollback) {
- bf::path path_old = "/usr/share/app-installers-ut/test_samples/smoke/UpdateMode_Rollback.wgt"; // NOLINT
- bf::path path_new = "/usr/share/app-installers-ut/test_samples/smoke/UpdateMode_Rollback_2.wgt"; // NOLINT
+ bf::path path_old = kSmokePackagesDirectory / "UpdateMode_Rollback.wgt";
+ bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Rollback_2.wgt";
std::string pkgid = "smokeapp07";
std::string appid = "smokeapp07.UpdateModeRollback";
- ASSERT_EQ(Update(path_old, path_new, RequestResult::FAIL),
+ ASSERT_EQ(Update(path_old, path_new, PackageType::WGT, RequestResult::FAIL),
ci::AppInstaller::Result::ERROR);
- ValidatePackage(pkgid, appid);
+ ValidatePackage(pkgid, {appid});
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
}
-TEST_F(SmokeTest, DeinstallationMode_Rollback) {
- bf::path path = "/usr/share/app-installers-ut/test_samples/smoke/DeinstallationMode_Rollback.wgt"; // NOLINT
- std::string pkgid = "smokeapp08";
- std::string appid = "smokeapp08.DeinstallationModeRollback";
- ASSERT_EQ(Install(path), ci::AppInstaller::Result::OK);
- ASSERT_EQ(Uninstall(pkgid, RequestResult::FAIL),
- ci::AppInstaller::Result::ERROR);
- ValidatePackage(pkgid, appid);
+TEST_F(SmokeTest, InstallationMode_Hybrid) {
+ bf::path path = kSmokePackagesDirectory / "InstallationMode_Hybrid.wgt";
+ std::string pkgid = "smokehyb01";
+ std::string appid1 = "smokehyb01.Web";
+ std::string appid2 = "smokehyb01.Native";
+ ASSERT_EQ(Install(path, PackageType::HYBRID), ci::AppInstaller::Result::OK);
+ ValidatePackage(pkgid, {appid1, appid2});
+}
+
+TEST_F(SmokeTest, UpdateMode_Hybrid) {
+ bf::path path_old = kSmokePackagesDirectory / "UpdateMode_Hybrid.wgt";
+ bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Hybrid_2.wgt";
+ std::string pkgid = "smokehyb02";
+ std::string appid1 = "smokehyb02.Web";
+ std::string appid2 = "smokehyb02.Native";
+ ASSERT_EQ(Update(path_old, path_new, PackageType::HYBRID),
+ ci::AppInstaller::Result::OK);
+ ValidatePackage(pkgid, {appid1, appid2});
+
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "VERSION", "2\n"));
+}
+
+TEST_F(SmokeTest, DeinstallationMode_Hybrid) {
+ bf::path path = kSmokePackagesDirectory / "DeinstallationMode_Hybrid.wgt";
+ std::string pkgid = "smokehyb03";
+ std::string appid1 = "smokehyb03.Web";
+ std::string appid2 = "smokehyb03.Native";
+ ASSERT_EQ(Install(path, PackageType::HYBRID),
+ ci::AppInstaller::Result::OK);
+ ASSERT_EQ(Uninstall(pkgid, PackageType::WGT), ci::AppInstaller::Result::OK);
+ CheckPackageNonExistance(pkgid, {appid1, appid2});
+}
+
+TEST_F(SmokeTest, DeltaMode_Hybrid) {
+ bf::path path = kSmokePackagesDirectory / "DeltaMode_Hybrid.wgt";
+ bf::path delta_package = kSmokePackagesDirectory / "DeltaMode_Hybrid.delta";
+ std::string pkgid = "smokehyb04";
+ std::string appid1 = "smokehyb04.Web";
+ std::string appid2 = "smokehyb04.Native";
+ ASSERT_EQ(DeltaInstall(path, delta_package, PackageType::HYBRID),
+ ci::AppInstaller::Result::OK);
+ ValidatePackage(pkgid, {appid1, appid2});
+
+ // Check delta modifications
+ bf::path root_path = ci::GetRootAppPath(false);
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "DELETED"));
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "ADDED"));
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "lib" / "DELETED"));
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "lib" / "ADDED"));
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "css" / "style.css")); // NOLINT
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "images" / "tizen_32.png")); // NOLINT
+ ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "js" / "main.js"));
+ ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "version 2\n");
+ ValidateFileContentInPackage(pkgid, "lib/MODIFIED", "version 2\n");
+}
+
+TEST_F(SmokeTest, MountInstallationMode) {
+ bf::path path = kSmokePackagesDirectory / "MountInstallationMode.wgt";
+ std::string pkgid = "smokeapp28";
+ std::string appid = "smokeapp28.InstallationMode";
+ ASSERT_EQ(MountInstall(path, PackageType::WGT), ci::AppInstaller::Result::OK);
+ ScopedTzipInterface interface(pkgid);
+ ValidatePackage(pkgid, {appid});
+}
+
+TEST_F(SmokeTest, MountUpdateMode) {
+ bf::path path_old = kSmokePackagesDirectory / "MountUpdateMode.wgt";
+ bf::path path_new = kSmokePackagesDirectory / "MountUpdateMode_2.wgt";
+ std::string pkgid = "smokeapp29";
+ std::string appid = "smokeapp29.UpdateMode";
+ ASSERT_EQ(MountUpdate(path_old, path_new, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ ScopedTzipInterface interface(pkgid);
+ ValidatePackage(pkgid, {appid});
+
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
}
} // namespace common_installer