// Use of this source code is governed by an apache-2.0 license that can be
// found in the LICENSE file.
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/range/iterator_range.hpp>
-#include <boost/system/error_code.hpp>
-
-#include <common/paths.h>
-#include <common/pkgmgr_interface.h>
-#include <common/pkgmgr_query.h>
-#include <common/request.h>
-#include <common/step/configuration/step_fail.h>
-#include <common/tzip_interface.h>
-#include <common/utils/file_util.h>
#include <common/utils/subprocess.h>
-#include <common/utils/user_util.h>
+#include <common/utils/file_util.h>
-#include <gtest/gtest.h>
#include <gtest/gtest-death-test.h>
-#include <pkgmgr-info.h>
-#include <signal.h>
-#include <unistd.h>
-#include <tzplatform_config.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"
-
-#define SIZEOFARRAY(ARR) \
- sizeof(ARR) / sizeof(ARR[0]) \
-
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
-namespace ci = common_installer;
-
-namespace {
-
-const uid_t kTestUserId = tzplatform_getuid(TZ_SYS_DEFAULT_USER);
-const gid_t kTestGroupId = tzplatform_getgid(TZ_SYS_DEFAULT_USER);
-const char kTestGroupName[] = "system_share";
-const std::string kTestUserIdStr =
- std::to_string(kTestUserId);
-
-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
-};
-
-class ScopedTzipInterface {
- public:
- explicit ScopedTzipInterface(const std::string& pkgid)
- : pkg_path_(bf::path(ci::GetRootAppPath(false,
- kTestUserId)) / pkgid),
- interface_(ci::GetMountLocation(pkg_path_)),
- mounted_(true) {
- interface_.MountZip(ci::GetZipPackageLocation(pkg_path_, pkgid));
- }
-
- void Release() {
- if (mounted_) {
- interface_.UnmountZip();
- mounted_ = false;
- }
- }
-
- ~ScopedTzipInterface() {
- Release();
- }
-
- private:
- bf::path pkg_path_;
- ci::TzipInterface interface_;
- bool mounted_;
-};
-
-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(false,
- kTestUserId);
- 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)) {
- if (dir_entry.path().string().find("/recovery") != std::string::npos) {
- bs::error_code error;
- bf::remove(dir_entry.path(), error);
- }
- }
- }
-}
-
-bf::path FindRecoveryFile() {
- bf::path root_path = ci::GetRootAppPath(false,
- kTestUserId);
- for (auto& dir_entry : boost::make_iterator_range(
- bf::directory_iterator(root_path), bf::directory_iterator())) {
- if (bf::is_regular_file(dir_entry)) {
- if (dir_entry.path().string().find("/recovery") != std::string::npos) {
- return dir_entry.path();
- }
- }
- }
- return {};
-}
-
-bf::path GetPackageRoot(const std::string& pkgid) {
- bf::path root_path = ci::GetRootAppPath(false, kTestUserId);
- return root_path / pkgid;
-}
-bool ValidateFileContentInPackage(const std::string& pkgid,
- const std::string& relative,
- const std::string& expected) {
- bf::path file_path = GetPackageRoot(pkgid) / relative;
- if (!bf::exists(file_path)) {
- LOG(ERROR) << file_path << " doesn't exist";
- return false;
- }
- FILE* handle = fopen(file_path.c_str(), "r");
- if (!handle) {
- LOG(ERROR) << file_path << " cannot be open";
- return false;
- }
- std::string content;
- std::array<char, 200> buffer;
- while (fgets(buffer.data(), buffer.size(), handle)) {
- content += buffer.data();
- }
- fclose(handle);
- return content == expected;
-}
-
-void AddDataFiles(const std::string& pkgid) {
- auto pkg_path = GetPackageRoot(pkgid);
- ASSERT_TRUE(TouchFile(pkg_path / "data" / "file1.txt"));
- ASSERT_TRUE(TouchFile(pkg_path / "data" / "file2.txt"));
-}
-
-void ValidateDataFiles(const std::string& pkgid) {
- auto pkg_path = GetPackageRoot(pkgid);
- ASSERT_TRUE(bf::exists(pkg_path / "data" / "file1.txt"));
- ASSERT_TRUE(bf::exists(pkg_path / "data" / "file2.txt"));
-}
-
-void ValidatePackageFS(const std::string& pkgid,
- const std::vector<std::string>& appids) {
- bf::path root_path = ci::GetRootAppPath(false, kTestUserId);
- bf::path package_path = GetPackageRoot(pkgid);
- 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(data_path));
- ASSERT_TRUE(bf::exists(shared_path));
- ASSERT_TRUE(bf::exists(cache_path));
-
- bf::path manifest_path =
- bf::path(getUserManifestPath(
- kTestUserId, false)) / (pkgid + ".xml");
- ASSERT_TRUE(bf::exists(manifest_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";
- ASSERT_TRUE(bf::exists(widget_root_path));
- ASSERT_TRUE(bf::exists(config_path));
-
- bf::path private_tmp_path = package_path / "tmp";
- ASSERT_TRUE(bf::exists(private_tmp_path));
-
- // backups should not exist
- bf::path package_backup = ci::GetBackupPathForPackagePath(package_path);
- bf::path manifest_backup = ci::GetBackupPathForManifestFile(manifest_path);
- ASSERT_FALSE(bf::exists(package_backup));
- ASSERT_FALSE(bf::exists(manifest_backup));
-
- for (bf::recursive_directory_iterator iter(package_path);
- iter != bf::recursive_directory_iterator(); ++iter) {
- if (bf::is_symlink(symlink_status(iter->path())))
- continue;
- struct stat stats;
- stat(iter->path().c_str(), &stats);
- ASSERT_EQ(kTestUserId, stats.st_uid) << "Invalid uid: " << iter->path();
- if (iter->path().filename() == "data") {
- boost::optional<gid_t> gid = ci::GetGidByGroupName(kTestGroupName);
- ASSERT_EQ(*gid, stats.st_gid) << "Invalid gid: " << iter->path();
- } else {
- ASSERT_EQ(kTestGroupId, stats.st_gid) << "Invalid gid: " << iter->path();
- }
- }
-}
-
-void PackageCheckCleanup(const std::string& pkgid,
- const std::vector<std::string>&) {
- bf::path package_path = GetPackageRoot(pkgid);
- ASSERT_FALSE(bf::exists(package_path));
-
- bf::path manifest_path =
- bf::path(getUserManifestPath(
- kTestUserId, false)) / (pkgid + ".xml");
- ASSERT_FALSE(bf::exists(manifest_path));
-
- // backups should not exist
- bf::path package_backup = ci::GetBackupPathForPackagePath(package_path);
- bf::path manifest_backup = ci::GetBackupPathForManifestFile(manifest_path);
- ASSERT_FALSE(bf::exists(package_backup));
- ASSERT_FALSE(bf::exists(manifest_backup));
-}
+#include "unit_tests/smoke_utils.h"
-void ValidatePackage(const std::string& pkgid,
- const std::vector<std::string>& appids) {
- ASSERT_TRUE(ci::QueryIsPackageInstalled(
- pkgid, ci::GetRequestMode(kTestUserId),
- kTestUserId));
- ValidatePackageFS(pkgid, appids);
-}
-
-void CheckPackageNonExistance(const std::string& pkgid,
- const std::vector<std::string>& appids) {
- ASSERT_FALSE(ci::QueryIsPackageInstalled(
- pkgid, ci::GetRequestMode(kTestUserId),
- kTestUserId));
- PackageCheckCleanup(pkgid, appids);
-}
-
-std::unique_ptr<ci::AppQueryInterface> CreateQueryInterface() {
- std::unique_ptr<ci::AppQueryInterface> query_interface(
- new wgt::WgtAppQueryInterface());
- return query_interface;
-}
-
-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, type);
- switch (mode) {
- case RequestResult::FAIL:
- installer->AddStep<ci::configuration::StepFail>();
- break;
- default:
- break;
- }
- return installer->Run();
-}
-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(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, type, mode);
-}
-
-ci::AppInstaller::Result Install(const bf::path& path,
- PackageType type,
- RequestResult mode = RequestResult::NORMAL) {
- const char* argv[] = {"", "-i", path.c_str(), "-u", kTestUserIdStr.c_str()};
- return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
-}
-
-ci::AppInstaller::Result MountInstall(const bf::path& path,
- PackageType type, RequestResult mode = RequestResult::NORMAL) {
- const char* argv[] = {"", "-w", path.c_str(), "-u", kTestUserIdStr.c_str()};
- return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
-}
-
-ci::AppInstaller::Result Uninstall(const std::string& pkgid,
- PackageType type,
- RequestResult mode = RequestResult::NORMAL) {
- const char* argv[] = {"", "-d", pkgid.c_str(), "-u", kTestUserIdStr.c_str()};
- return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
-}
-
-ci::AppInstaller::Result RDSUpdate(const bf::path& path,
- const std::string& pkgid,
- PackageType type,
- RequestResult mode = RequestResult::NORMAL) {
- 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", pkgid.c_str(), "-u",
- kTestUserIdStr.c_str()};
- return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
-}
-
-ci::AppInstaller::Result DeltaInstall(const bf::path& path,
- 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, type);
-}
-
-ci::AppInstaller::Result EnablePackage(const std::string& pkgid,
- PackageType type,
- RequestResult mode = RequestResult::NORMAL) {
- const char* argv[] = {"", "-A", pkgid.c_str(), "-u", kTestUserIdStr.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(), "-u", kTestUserIdStr.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[] = {"", "-b", recovery_file.c_str(), "-u",
- kTestUserIdStr.c_str()};
- TestPkgmgrInstaller pkgmgr_installer;
- std::unique_ptr<ci::AppQueryInterface> query_interface =
- CreateQueryInterface();
- auto pkgmgr =
- ci::PkgMgrInterface::Create(SIZEOFARRAY(argv), 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, type, mode);
-}
-
-} // namespace
namespace common_installer {
class SmokeEnvironment : public testing::Environment {
public:
- explicit SmokeEnvironment(const bf::path& home) : home_(home) {
+ explicit SmokeEnvironment(ci::RequestMode mode) {\
+ request_mode_ = mode;
}
void SetUp() override {
- bf::path UserDBDir = bf::path(kUserDataBaseDir) / kTestUserIdStr;
- 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);
+ if (request_mode_ == ci::RequestMode::USER) {
+ ASSERT_TRUE(AddTestUser(kNormalUserName));
+ } else {
+ kTestUserId = kGlobalUserUid;
+ kTestGroupId = kGlobalUserGid;
+ kTestUserIdStr = std::to_string(kTestUserId);
}
+ backups_ = SetupBackupDirectories();
+ for (auto& path : backups_)
+ BackupPath(path);
}
void TearDown() override {
- bf::path UserDBDir = bf::path(kUserDataBaseDir) / kTestUserIdStr;
- 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);
+ ASSERT_TRUE(request_mode_ == ci::RequestMode::GLOBAL ||
+ (request_mode_ == ci::RequestMode::USER &&
+ kGlobalUserUid != kTestUserId));
+ UninstallAllSmokeApps(request_mode_);
+ for (auto& path : backups_)
+ RestorePath(path);
+ if (request_mode_ == ci::RequestMode::USER)
+ ASSERT_TRUE(DeleteTestUser(kNormalUserName));
}
private:
- bf::path home_;
+ ci::RequestMode request_mode_;
+ std::vector<bf::path> backups_;
};
class SmokeTest : public testing::Test {
};
+class PreloadSmokeTest : public testing::Test {
+ void SetUp() override {
+ ASSERT_EQ(kGlobalUserUid, kTestUserId);
+ }
+};
+
TEST_F(SmokeTest, InstallationMode) {
bf::path path = kSmokePackagesDirectory / "InstallationMode.wgt";
- std::string pkgid = "smokeapp03";
- std::string appid = "smokeapp03.InstallationMode";
+ std::string pkgid = "smokewgt03";
+ std::string appid = "smokewgt03.InstallationMode";
ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
- ValidatePackage(pkgid, {appid});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
}
TEST_F(SmokeTest, UpdateMode) {
bf::path path_old = kSmokePackagesDirectory / "UpdateMode.wgt";
bf::path path_new = kSmokePackagesDirectory / "UpdateMode_2.wgt";
- std::string pkgid = "smokeapp04";
- std::string appid = "smokeapp04.UpdateMode";
+ std::string pkgid = "smokewgt04";
+ std::string appid = "smokewgt04.UpdateMode";
ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid);
+ AddDataFiles(pkgid, kTestUserId);
ASSERT_EQ(Install(path_new, PackageType::WGT), ci::AppInstaller::Result::OK);
- ValidatePackage(pkgid, {appid});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
- ValidateDataFiles(pkgid);
+ ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
}
TEST_F(SmokeTest, DeinstallationMode) {
bf::path path = kSmokePackagesDirectory / "DeinstallationMode.wgt";
- std::string pkgid = "smokeapp05";
- std::string appid = "smokeapp05.DeinstallationMode";
+ std::string pkgid = "smokewgt05";
+ std::string appid = "smokewgt05.DeinstallationMode";
ASSERT_EQ(Install(path, PackageType::WGT),
ci::AppInstaller::Result::OK);
- ASSERT_EQ(Uninstall(pkgid, PackageType::WGT), ci::AppInstaller::Result::OK);
- CheckPackageNonExistance(pkgid, {appid});
+ ASSERT_EQ(Uninstall(pkgid, PackageType::WGT, false),
+ ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
}
TEST_F(SmokeTest, RDSMode) {
bf::path path = kSmokePackagesDirectory / "RDSMode.wgt";
- std::string pkgid = "smokeapp11";
- std::string appid = "smokeapp11.RDSMode";
+ std::string pkgid = "smokewgt11";
+ std::string appid = "smokewgt11.RDSMode";
bf::path delta_directory = kSmokePackagesDirectory / "delta_dir/";
bf::path sdk_expected_directory =
bf::path(ci::GetRootAppPath(false, kTestUserId)) / "tmp" / pkgid;
ASSERT_TRUE(CopyDir(delta_directory, sdk_expected_directory));
ASSERT_EQ(RDSUpdate(path, pkgid, PackageType::WGT),
ci::AppInstaller::Result::OK);
- ValidatePackage(pkgid, {appid});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
// Check delta modifications
- ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid) / "res" / "wgt" / "DELETED"));
- ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid) / "res" / "wgt" / "ADDED"));
+ ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ "res" / "wgt" / "DELETED"));
+ ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ "res" / "wgt" / "ADDED"));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "2\n"));
}
TEST_F(SmokeTest, EnablePkg) {
bf::path path = kSmokePackagesDirectory / "EnablePkg.wgt";
- std::string pkgid = "smokeapp22";
+ std::string pkgid = "smokewgt22";
ASSERT_EQ(Install(path, PackageType::WGT),
ci::AppInstaller::Result::OK);
ASSERT_EQ(DisablePackage(pkgid, PackageType::WGT),
TEST_F(SmokeTest, DisablePkg) {
bf::path path = kSmokePackagesDirectory / "DisablePkg.wgt";
- std::string pkgid = "smokeapp21";
- std::string appid = "smokeapp21.DisablePkg";
+ std::string pkgid = "smokewgt21";
+ std::string appid = "smokewgt21.DisablePkg";
ASSERT_EQ(Install(path, PackageType::WGT),
ci::AppInstaller::Result::OK);
ASSERT_EQ(DisablePackage(pkgid, PackageType::WGT),
ci::AppInstaller::Result::OK);
ASSERT_TRUE(ci::QueryIsDisabledPackage(pkgid, kTestUserId));
- ValidatePackageFS(pkgid, {appid});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
}
TEST_F(SmokeTest, DeltaMode) {
bf::path path = kSmokePackagesDirectory / "DeltaMode.wgt";
bf::path delta_package = kSmokePackagesDirectory / "DeltaMode.delta";
- std::string pkgid = "smokeapp17";
- std::string appid = "smokeapp17.DeltaMode";
+ std::string pkgid = "smokewgt17";
+ std::string appid = "smokewgt17.DeltaMode";
ASSERT_EQ(DeltaInstall(path, delta_package, PackageType::WGT),
ci::AppInstaller::Result::OK);
- ValidatePackage(pkgid, {appid});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
// Check delta modifications
- ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid) / "res" / "wgt" / "DELETED"));
- ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid) / "res" / "wgt" / "ADDED"));
- ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid) / "res" / "wgt" / "css" / "style.css")); // NOLINT
- ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid) / "res" / "wgt" / "images" / "tizen_32.png")); // NOLINT
- ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid) / "res" / "wgt" / "js" / "main.js")); // NOLINT
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "version 2\n")); // NOLINT
+ ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ "res" / "wgt" / "DELETED"));
+ ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ "res" / "wgt" / "ADDED"));
+ ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ "res" / "wgt" / "css" / "style.css"));
+ ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ "res" / "wgt" / "images" / "tizen_32.png"));
+ ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ "res" / "wgt" / "js" / "main.js"));
+ ASSERT_TRUE(ValidateFileContentInPackage(
+ pkgid, "res/wgt/MODIFIED", "version 2\n"));
}
TEST_F(SmokeTest, RecoveryMode_ForInstallation) {
backend_crash.Run("-i", path.string(), "-u", kTestUserIdStr.c_str());
ASSERT_NE(backend_crash.Wait(), 0);
- std::string pkgid = "smokeapp09";
- std::string appid = "smokeapp09.RecoveryModeForInstallation";
+ std::string pkgid = "smokewgt09";
+ std::string appid = "smokewgt09.RecoveryModeForInstallation";
bf::path recovery_file = FindRecoveryFile();
ASSERT_FALSE(recovery_file.empty());
ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
ci::AppInstaller::Result::OK);
- CheckPackageNonExistance(pkgid, {appid});
+ ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
}
TEST_F(SmokeTest, RecoveryMode_ForUpdate) {
bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForUpdate_2.wgt";
RemoveAllRecoveryFiles();
ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK);
- std::string pkgid = "smokeapp10";
- std::string appid = "smokeapp10.RecoveryModeForUpdate";
- AddDataFiles(pkgid);
+ std::string pkgid = "smokewgt10";
+ std::string appid = "smokewgt10.RecoveryModeForUpdate";
+ AddDataFiles(pkgid, kTestUserId);
Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
backend_crash.Run("-i", path_new.string(), "-u", kTestUserIdStr.c_str());
ASSERT_NE(backend_crash.Wait(), 0);
ASSERT_FALSE(recovery_file.empty());
ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
ci::AppInstaller::Result::OK);
- ValidatePackage(pkgid, {appid});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
- ValidateDataFiles(pkgid);
+ ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
}
TEST_F(SmokeTest, RecoveryMode_ForDelta) {
backend_crash.Run("-i", path_new.string(), "-u", kTestUserIdStr.c_str());
ASSERT_NE(backend_crash.Wait(), 0);
- std::string pkgid = "smokeapp30";
- std::string appid = "smokeapp30.RecoveryModeForDelta";
+ std::string pkgid = "smokewgt30";
+ std::string appid = "smokewgt30.RecoveryModeForDelta";
bf::path recovery_file = FindRecoveryFile();
ASSERT_FALSE(recovery_file.empty());
ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
ci::AppInstaller::Result::OK);
- ValidatePackage(pkgid, {appid});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
}
backend_crash.Run("-w", path.string(), "-u", kTestUserIdStr.c_str());
ASSERT_NE(backend_crash.Wait(), 0);
- std::string pkgid = "smokeapp31";
- std::string appid = "smokeapp31.RecoveryModeForMountInstall";
+ std::string pkgid = "smokewgt31";
+ std::string appid = "smokewgt31.RecoveryModeForMountInstall";
bf::path recovery_file = FindRecoveryFile();
ASSERT_FALSE(recovery_file.empty());
ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
ci::AppInstaller::Result::OK);
- CheckPackageNonExistance(pkgid, {appid});
+ ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
}
TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
kSmokePackagesDirectory / "RecoveryMode_ForMountUpdate.wgt";
bf::path path_new =
kSmokePackagesDirectory / "RecoveryMode_ForMountUpdate_2.wgt";
- std::string pkgid = "smokeapp32";
- std::string appid = "smokeapp32.RecoveryModeForMountUpdate";
+ std::string pkgid = "smokewgt32";
+ std::string appid = "smokewgt32.RecoveryModeForMountUpdate";
RemoveAllRecoveryFiles();
ASSERT_EQ(MountInstall(path_old, PackageType::WGT),
ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid);
+ AddDataFiles(pkgid, kTestUserId);
Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
backend_crash.Run("-w", path_new.string(), "-u", kTestUserIdStr.c_str());
ASSERT_NE(backend_crash.Wait(), 0);
ci::AppInstaller::Result::OK);
ScopedTzipInterface interface(pkgid);
- ValidatePackage(pkgid, {appid});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
- ValidateDataFiles(pkgid);
+ ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
}
TEST_F(SmokeTest, InstallationMode_GoodSignature) {
+ // pkgid: smokewgt08
bf::path path = kSmokePackagesDirectory / "InstallationMode_GoodSignature.wgt"; // NOLINT
ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
}
TEST_F(SmokeTest, InstallationMode_WrongSignature) {
+ // pkgid: smokewgt12
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 = kSmokePackagesDirectory / "InstallationMode_Rollback.wgt";
- std::string pkgid = "smokeapp06";
- std::string appid = "smokeapp06.InstallationModeRollback";
+ std::string pkgid = "smokewgt06";
+ std::string appid = "smokewgt06.InstallationModeRollback";
ASSERT_EQ(Install(path, PackageType::WGT, RequestResult::FAIL),
ci::AppInstaller::Result::ERROR);
- CheckPackageNonExistance(pkgid, {appid});
+ ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
}
TEST_F(SmokeTest, UpdateMode_Rollback) {
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";
+ std::string pkgid = "smokewgt07";
+ std::string appid = "smokewgt07.UpdateModeRollback";
ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid);
+ AddDataFiles(pkgid, kTestUserId);
ASSERT_EQ(Install(path_new, PackageType::WGT, RequestResult::FAIL),
ci::AppInstaller::Result::ERROR);
- ValidatePackage(pkgid, {appid});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
- ValidateDataFiles(pkgid);
+ ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+}
+
+TEST_F(SmokeTest, DeltaMode_Rollback) {
+ bf::path path = kSmokePackagesDirectory / "DeltaMode_Rollback.wgt";
+ bf::path delta_package = kSmokePackagesDirectory / "DeltaMode_Rollback.delta";
+ std::string pkgid = "smokewgt01";
+ std::string appid = "smokewgt01.DeltaMode";
+ ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, kTestUserId);
+ ASSERT_EQ(Install(delta_package, PackageType::WGT, RequestResult::FAIL),
+ ci::AppInstaller::Result::ERROR);
+
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED",
+ "version 1\n"));
+ ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ "res/wgt/DELETED"));
+ ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ "res/wgt/ADDED"));
}
TEST_F(SmokeTest, InstallationMode_Hybrid) {
bf::path path = kSmokePackagesDirectory / "InstallationMode_Hybrid.wgt";
std::string pkgid = "smokehyb01";
+ // Excutable for native app doesn't create symlink
std::string appid1 = "smokehyb01.Web";
- std::string appid2 = "smokehyb01.Native";
ASSERT_EQ(Install(path, PackageType::HYBRID), ci::AppInstaller::Result::OK);
- ValidatePackage(pkgid, {appid1, appid2});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
}
TEST_F(SmokeTest, UpdateMode_Hybrid) {
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(Install(path_old, PackageType::HYBRID),
ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid);
+// AddDataFiles(pkgid, kTestUserId);
ASSERT_EQ(Install(path_new, PackageType::HYBRID),
ci::AppInstaller::Result::OK);
- ValidatePackage(pkgid, {appid1, appid2});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "VERSION", "2\n"));
- ValidateDataFiles(pkgid);
+// ValidateDataFiles(pkgid, kTestUserId);
}
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::HYBRID),
+ ASSERT_EQ(Uninstall(pkgid, PackageType::HYBRID, false),
ci::AppInstaller::Result::OK);
- CheckPackageNonExistance(pkgid, {appid1, appid2});
+ ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid1}));
}
TEST_F(SmokeTest, DeltaMode_Hybrid) {
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});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
// Check delta modifications
bf::path root_path = ci::GetRootAppPath(false,
bf::path path = kSmokePackagesDirectory / "MountInstallationMode_Hybrid.wgt";
std::string pkgid = "smokehyb05";
std::string appid1 = "smokehyb05.web";
- std::string appid2 = "smokehyb05.service";
ASSERT_EQ(MountInstall(path, PackageType::HYBRID),
ci::AppInstaller::Result::OK);
ScopedTzipInterface interface(pkgid);
- ValidatePackage(pkgid, {appid1, appid2});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
}
TEST_F(SmokeTest, MountUpdateMode_Hybrid) {
bf::path path_new = kSmokePackagesDirectory / "MountUpdateMode_Hybrid_2.wgt";
std::string pkgid = "smokehyb06";
std::string appid1 = "smokehyb06.web";
- std::string appid2 = "smokehyb06.service";
ASSERT_EQ(MountInstall(path_old, PackageType::HYBRID),
ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid);
+ AddDataFiles(pkgid, kTestUserId);
ASSERT_EQ(MountInstall(path_new, PackageType::HYBRID),
ci::AppInstaller::Result::OK);
ScopedTzipInterface interface(pkgid);
- ValidatePackage(pkgid, {appid1, appid2});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "2\n"));
- ValidateDataFiles(pkgid);
+ ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
}
TEST_F(SmokeTest, InstallationMode_Rollback_Hybrid) {
"InstallationMode_Rollback_Hybrid.wgt";
std::string pkgid = "smokehyb07";
std::string appid1 = "smokehyb07.web";
- std::string appid2 = "smokehyb07.service";
ASSERT_EQ(Install(path, PackageType::HYBRID, RequestResult::FAIL),
ci::AppInstaller::Result::ERROR);
- CheckPackageNonExistance(pkgid, {appid1, appid2});
+ ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid1}));
}
TEST_F(SmokeTest, UpdateMode_Rollback_Hybrid) {
"UpdateMode_Rollback_Hybrid_2.wgt";
std::string pkgid = "smokehyb08";
std::string appid1 = "smokehyb08.web";
- std::string appid2 = "smokehyb08.service";
ASSERT_EQ(Install(path_old, PackageType::HYBRID),
ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid);
+ AddDataFiles(pkgid, kTestUserId);
ASSERT_EQ(Install(path_new, PackageType::HYBRID,
RequestResult::FAIL), ci::AppInstaller::Result::ERROR);
- ValidatePackage(pkgid, {appid1, appid2});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "1\n"));
- ValidateDataFiles(pkgid);
+ ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+}
+
+TEST_F(SmokeTest, DeltaMode_Rollback_Hybrid) {
+ bf::path path = kSmokePackagesDirectory / "DeltaMode_Rollback_Hybrid.wgt";
+ bf::path delta_package = kSmokePackagesDirectory /
+ "DeltaMode_Rollback_Hybrid.delta";
+ std::string pkgid = "smokehyb11";
+ std::string appid1 = "smokehyb11.web";
+ ASSERT_EQ(Install(path, PackageType::HYBRID), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, kTestUserId);
+ ASSERT_EQ(Install(delta_package, PackageType::HYBRID, RequestResult::FAIL),
+ ci::AppInstaller::Result::ERROR);
+
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
+ // Check delta modifications
+ bf::path root_path = GetPackageRoot(pkgid, kTestUserId);
+ ASSERT_TRUE(bf::exists(root_path / "res" / "wgt" / "DELETED"));
+ ASSERT_FALSE(bf::exists(root_path / "res" / "wgt" / "ADDED"));
+ ASSERT_TRUE(bf::exists(root_path / "lib" / "DELETED"));
+ ASSERT_FALSE(bf::exists(root_path / "lib" / "ADDED"));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED",
+ "version 1\n"));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/MODIFIED",
+ "version 1\n"));
+ ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
}
TEST_F(SmokeTest, MountInstallationMode_Rollback_Hybrid) {
"MountInstallationMode_Rollback_Hybrid.wgt";
std::string pkgid = "smokehyb09";
std::string appid1 = "smokehyb09.web";
- std::string appid2 = "smokehyb09.service";
ASSERT_EQ(MountInstall(path, PackageType::HYBRID, RequestResult::FAIL),
ci::AppInstaller::Result::ERROR);
ScopedTzipInterface interface(pkgid);
- CheckPackageNonExistance(pkgid, {appid1, appid2});
+ ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid1}));
}
TEST_F(SmokeTest, MountUpdateMode_Rollback_Hybrid) {
"MountUpdateMode_Rollback_Hybrid_2.wgt";
std::string pkgid = "smokehyb10";
std::string appid1 = "smokehyb10.web";
- std::string appid2 = "smokehyb10.service";
ASSERT_EQ(MountInstall(path_old, PackageType::HYBRID),
ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid);
+ AddDataFiles(pkgid, kTestUserId);
ASSERT_EQ(MountInstall(path_new, PackageType::HYBRID,
RequestResult::FAIL), ci::AppInstaller::Result::ERROR);
ScopedTzipInterface interface(pkgid);
- ValidatePackage(pkgid, {appid1, appid2});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "1\n"));
- ValidateDataFiles(pkgid);
+ ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
}
TEST_F(SmokeTest, MountInstallationMode) {
bf::path path = kSmokePackagesDirectory / "MountInstallationMode.wgt";
- std::string pkgid = "smokeapp28";
- std::string appid = "smokeapp28.InstallationMode";
+ std::string pkgid = "smokewgt28";
+ std::string appid = "smokewgt28.InstallationMode";
ASSERT_EQ(MountInstall(path, PackageType::WGT), ci::AppInstaller::Result::OK);
ScopedTzipInterface interface(pkgid);
- ValidatePackage(pkgid, {appid});
+ ASSERT_TRUE(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";
+ std::string pkgid = "smokewgt29";
+ std::string appid = "smokewgt29.UpdateMode";
ASSERT_EQ(MountInstall(path_old, PackageType::WGT),
ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid);
+ AddDataFiles(pkgid, kTestUserId);
ASSERT_EQ(MountInstall(path_new, PackageType::WGT),
ci::AppInstaller::Result::OK);
ScopedTzipInterface interface(pkgid);
- ValidatePackage(pkgid, {appid});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
- ValidateDataFiles(pkgid);
+ ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
}
TEST_F(SmokeTest, MountInstallationMode_Rollback) {
bf::path path =
kSmokePackagesDirectory / "MountInstallationMode_Rollback.wgt";
- std::string pkgid = "smokeapp33";
- std::string appid = "smokeapp33.web";
+ std::string pkgid = "smokewgt33";
+ std::string appid = "smokewgt33.web";
ASSERT_EQ(MountInstall(path, PackageType::WGT, RequestResult::FAIL),
ci::AppInstaller::Result::ERROR);
ScopedTzipInterface interface(pkgid);
- CheckPackageNonExistance(pkgid, {appid});
+ ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
}
TEST_F(SmokeTest, MountUpdateMode_Rollback) {
bf::path path_old = kSmokePackagesDirectory / "MountUpdateMode_Rollback.wgt";
bf::path path_new =
kSmokePackagesDirectory / "MountUpdateMode_Rollback_2.wgt";
- std::string pkgid = "smokeapp34";
- std::string appid = "smokeapp34.web";
+ std::string pkgid = "smokewgt34";
+ std::string appid = "smokewgt34.web";
ASSERT_EQ(MountInstall(path_old, PackageType::WGT),
ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid);
+ AddDataFiles(pkgid, kTestUserId);
ASSERT_EQ(MountInstall(path_new, PackageType::WGT,
RequestResult::FAIL), ci::AppInstaller::Result::ERROR);
ScopedTzipInterface interface(pkgid);
- ValidatePackage(pkgid, {appid});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
- ValidateDataFiles(pkgid);
+ ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
}
TEST_F(SmokeTest, UserDefinedPlugins) {
bf::path path = kSmokePackagesDirectory / "SimpleEchoPrivilege.wgt";
- std::string pkgid = "0CSPVhKmRk";
- std::string appid = "0CSPVhKmRk.SimpleEcho";
+ std::string pkgid = "smokewgt02";
+ std::string appid = "smokewgt02.SimpleEcho";
std::string call_privilege = "http://tizen.org/privilege/call";
std::string location_privilege = "http://tizen.org/privilege/location";
std::string power_privilege = "http://tizen.org/privilege/power";
ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
- ValidatePackage(pkgid, {appid});
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
std::vector<std::string> res;
ASSERT_TRUE(ci::QueryPrivilegesForPkgId(pkgid, kTestUserId, &res));
ASSERT_TRUE(std::find(res.begin(), res.end(), call_privilege) != res.end());
ASSERT_TRUE(std::find(res.begin(), res.end(), power_privilege) != res.end());
}
+TEST_F(SmokeTest, InstallExternalMode) {
+ ASSERT_TRUE(CheckAvailableExternalPath());
+ bf::path path = kSmokePackagesDirectory / "InstallExternalMode.wgt";
+ std::string pkgid = "smokewgt35";
+ std::string appid = "smokewgt35.web";
+ ASSERT_EQ(InstallExternal(path, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ ValidateExternalPackage(pkgid, {appid});
+}
+
+TEST_F(SmokeTest, MigrateLegacyExternalImageMode) {
+ ASSERT_TRUE(CheckAvailableExternalPath());
+ bf::path path =
+ kSmokePackagesDirectory / "MigrateLegacyExternalImageMode.wgt";
+ std::string pkgid = "smokewgt36";
+ std::string appid = "smokewgt36.web";
+ bf::path legacy_path = kSmokePackagesDirectory / kLegacyExtImageDir;
+ ASSERT_EQ(MigrateLegacyExternalImage(pkgid, path, legacy_path,
+ PackageType::WGT), ci::AppInstaller::Result::OK);
+ ValidateExternalPackage(pkgid, {appid});
+}
+
+TEST_F(PreloadSmokeTest, InstallationMode_Preload) {
+ ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
+ bf::path path = kSmokePackagesDirectory / "InstallationMode_Preload.wgt";
+ std::string pkgid = "smokewgt37";
+ std::string appid = "smokewgt37.InstallationModePreload";
+ ASSERT_EQ(InstallPreload(path, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, true));
+}
+
+TEST_F(PreloadSmokeTest, UpdateMode_Preload) {
+ ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
+ bf::path path_old = kSmokePackagesDirectory / "UpdateMode_Preload.wgt";
+ bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Preload2.wgt";
+ std::string pkgid = "smokewgt38";
+ std::string appid = "smokewgt38.UpdateModePreload";
+ ASSERT_EQ(InstallPreload(path_old, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, kTestUserId);
+ ASSERT_EQ(InstallPreload(path_new, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, true));
+
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2",
+ true));
+ ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+}
+
+TEST_F(PreloadSmokeTest, DeinstallationMode_Preload) {
+ ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
+ bf::path path = kSmokePackagesDirectory / "DeinstallationMode_Preload.wgt";
+ std::string pkgid = "smokewgt39";
+ std::string appid = "smokewgt39.DeinstallationModePreload";
+ ASSERT_EQ(InstallPreload(path, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ ASSERT_EQ(Uninstall(pkgid, PackageType::WGT, true),
+ ci::AppInstaller::Result::OK);
+ CheckPackageReadonlyNonExistance(pkgid, {appid});
+}
+
+TEST_F(SmokeTest, SharedRes24) {
+ bf::path path = kSmokePackagesDirectory / "SharedRes24.wgt";
+ std::string pkgid = "smokeSh2xx";
+ std::string appid = "smokeSh2xx.SharedRes24";
+ ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
+ ValidatePackage(pkgid, {appid});
+ bf::path root_path = ci::GetRootAppPath(false, kTestUserId);
+ ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "NOT-SHARED-WGT")); // NOLINT
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "shared" / "res" / "NOT-SHARED-WGT")); // NOLINT
+}
+
+TEST_F(SmokeTest, SharedRes30) {
+ bf::path path = kSmokePackagesDirectory / "SharedRes30.wgt";
+ std::string pkgid = "smokeSh3xx";
+ std::string appid = "smokeSh3xx.SharedRes30";
+ ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ bf::path root_path = ci::GetRootAppPath(false, kTestUserId);
+ ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT")); // NOLINT
+ ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "shared" / "res" / "SHARED-WGT")); // NOLINT
+}
+
+TEST_F(SmokeTest, SharedRes30Delta) {
+ bf::path path = kSmokePackagesDirectory / "SharedRes30Delta.wgt";
+ bf::path delta_package = kSmokePackagesDirectory / "SharedRes30Delta.delta";
+ std::string pkgid = "smokeSh3De";
+ std::string appid = "smokeSh3De.SharedRes30Delta";
+ ASSERT_EQ(DeltaInstall(path, delta_package, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ // Check delta modifications
+ bf::path root_path = ci::GetRootAppPath(false, kTestUserId);
+ ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT-2")); // NOLINT
+ ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "shared" / "res" / "SHARED-WGT-2")); // NOLINT
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT-1")); // NOLINT
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "shared" / "res" / "SHARED-WGT-1")); // NOLINT
+}
+
+TEST_F(SmokeTest, SharedRes30Hybrid) {
+ bf::path path = kSmokePackagesDirectory / "SharedRes30Hybrid.wgt";
+ std::string pkgid = "smokeSh3Hy";
+ std::string appid1 = "smokeSh3Hy.SharedRes30Hybrid";
+ std::string appid2 = "sharedres30hybridserivce";
+ ASSERT_EQ(Install(path, PackageType::HYBRID), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1, appid2}));
+ bf::path root_path = ci::GetRootAppPath(false, kTestUserId);
+ ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT")); // NOLINT
+ ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "shared" / "res" / "SHARED-WGT")); // NOLINT
+ ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-TPK")); // NOLINT
+ ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-TPK")); // NOLINT
+}
+
+TEST_F(SmokeTest, SharedRes30HybridDelta) {
+ bf::path path = kSmokePackagesDirectory / "SharedRes30HybridDelta.wgt";
+ bf::path delta_package = kSmokePackagesDirectory /
+ "SharedRes30HybridDelta.delta";
+ std::string pkgid = "smokeSh3HD";
+ std::string appid1 = "smokeSh3HD.SharedRes30HybridDelta";
+ std::string appid2 = "sharedres30hybriddeltaserivce";
+ ASSERT_EQ(DeltaInstall(path, delta_package, PackageType::HYBRID),
+ ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1, appid2}));
+ // Check delta modifications
+ bf::path root_path = ci::GetRootAppPath(false, kTestUserId);
+ ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT-2")); // NOLINT
+ ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "shared" / "res" / "SHARED-WGT-2")); // NOLINT
+ ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-TPK-2")); // NOLINT
+ ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-TPK-2")); // NOLINT
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT-1")); // NOLINT
+ ASSERT_FALSE(bf::exists(root_path / pkgid / "shared" / "res" / "SHARED-WGT-1")); // NOLINT
+}
+
} // namespace common_installer
int main(int argc, char** argv) {
+ ci::RequestMode request_mode = ParseRequestMode(argc, argv);
+ if (getuid() != 0 || request_mode != ci::RequestMode::GLOBAL) {
+ std::cout << "Skip tests for preload request" << std::endl;
+ ::testing::GTEST_FLAG(filter) = "SmokeTest.*";
+ }
testing::InitGoogleTest(&argc, argv);
- bf::path directory =
- bf::path("/home") / tzplatform_getenv(TZ_SYS_DEFAULT_USER);
- testing::AddGlobalTestEnvironment(
- new common_installer::SmokeEnvironment(directory));
+ env = testing::AddGlobalTestEnvironment(
+ new common_installer::SmokeEnvironment(request_mode));
+ signal(SIGINT, signalHandler);
+ signal(SIGSEGV, signalHandler);
return RUN_ALL_TESTS();
}