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 uid_t kGlobalUserUid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+const uid_t kGlobalUserGid = tzplatform_getgid(TZ_SYS_GLOBALAPP_USER);
+const uid_t kTestUserId = kGlobalUserUid;
+const gid_t kTestGroupId = kGlobalUserGid;
+const char kSystemShareGroupName[] = "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";
+// common entries
+const std::vector<std::string> kDBEntries = {
+ {".pkgmgr_parser.db"},
+ {".pkgmgr_parser.db-journal"},
+ {".pkgmgr_cert.db"},
+ {".pkgmgr_cert.db-journal"},
+};
+// globaluser entries
+const char kGlobalManifestDir[] = "/opt/share/packages";
+const char kSkelDir[] = "/etc/skel/apps_rw";
enum class RequestResult {
NORMAL,
return {};
}
-bf::path GetPackageRoot(const std::string& pkgid) {
- bf::path root_path = ci::GetRootAppPath(false, kTestUserId);
+bf::path GetPackageRoot(const std::string& pkgid, uid_t uid) {
+ bf::path root_path = ci::GetRootAppPath(false, uid);
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;
+ bf::path file_path = GetPackageRoot(pkgid, kTestUserId) / relative;
if (!bf::exists(file_path)) {
LOG(ERROR) << file_path << " doesn't exist";
return false;
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 AddDataFiles(const std::string& pkgid, uid_t uid) {
+ if (uid == kGlobalUserUid) {
+ ci::UserList list = ci::GetUserList();
+ for (auto l : list) {
+ auto pkg_path = GetPackageRoot(pkgid, std::get<0>(l));
+ ASSERT_TRUE(TouchFile(pkg_path / "data" / "file1.txt"));
+ ASSERT_TRUE(TouchFile(pkg_path / "data" / "file2.txt"));
+ }
+ } else {
+ auto pkg_path = GetPackageRoot(pkgid, uid);
+ 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 ValidateDataFiles(const std::string& pkgid, uid_t uid) {
+ if (uid == kGlobalUserUid) {
+ ci::UserList list = ci::GetUserList();
+ for (auto l : list) {
+ auto pkg_path = GetPackageRoot(pkgid, std::get<0>(l));
+ ASSERT_TRUE(bf::exists(pkg_path / "data" / "file1.txt"));
+ ASSERT_TRUE(bf::exists(pkg_path / "data" / "file2.txt"));
+ }
+ } else {
+ auto pkg_path = GetPackageRoot(pkgid, uid);
+ 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);
+void ValidatePackageRWFS(const std::string& pkgid, uid_t uid, gid_t gid) {
+ bf::path root_path = ci::GetRootAppPath(false, uid);
+ bf::path package_path = root_path / pkgid;
bf::path data_path = package_path / "data";
- bf::path shared_path = package_path / "shared";
bf::path cache_path = package_path / "cache";
+ bf::path shared_data_path = package_path / "shared" / "data";
+
+ ASSERT_TRUE(bf::exists(data_path));
+ ASSERT_TRUE(bf::exists(cache_path));
+
+ struct stat stats;
+ stat(data_path.c_str(), &stats);
+ // gid of data, and shared/data should be system_share
+ boost::optional<gid_t> system_share =
+ ci::GetGidByGroupName(kSystemShareGroupName);
+ ASSERT_EQ(uid, stats.st_uid) << "Invalid gid: " << data_path;
+ ASSERT_EQ(*system_share, stats.st_gid) << "Invalid gid: " << data_path;
+ if (bf::exists(shared_data_path)) {
+ stat(shared_data_path.c_str(), &stats);
+ ASSERT_EQ(uid, stats.st_uid) << "Invalid gid: " << shared_data_path;
+ ASSERT_EQ(*system_share, stats.st_gid) << "Invalid gid: "
+ << shared_data_path;
+ }
+
+ stat(cache_path.c_str(), &stats);
+ ASSERT_EQ(uid, stats.st_uid) << "Invalid gid: " << cache_path;
+ ASSERT_EQ(gid, stats.st_gid) << "Invalid gid: " << cache_path;
+}
+
+void ValidatePackageFS(const std::string& pkgid,
+ const std::vector<std::string>& appids,
+ uid_t uid, gid_t gid) {
+ bf::path root_path = ci::GetRootAppPath(false, uid);
+ bf::path package_path = GetPackageRoot(pkgid, uid);
+ bf::path shared_path = package_path / "shared";
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");
+ bf::path(getUserManifestPath(uid, false)) / (pkgid + ".xml");
ASSERT_TRUE(bf::exists(manifest_path));
for (auto& appid : appids) {
iter != bf::recursive_directory_iterator(); ++iter) {
if (bf::is_symlink(symlink_status(iter->path())))
continue;
+ if (iter->path().filename() == "data")
+ 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();
- }
+ ASSERT_EQ(uid, stats.st_uid) << "Invalid uid: " << iter->path();
+ ASSERT_EQ(gid, stats.st_gid) << "Invalid gid: " << iter->path();
}
}
void PackageCheckCleanup(const std::string& pkgid,
const std::vector<std::string>&) {
- bf::path package_path = GetPackageRoot(pkgid);
+ bf::path package_path = GetPackageRoot(pkgid, kTestUserId);
ASSERT_FALSE(bf::exists(package_path));
bf::path manifest_path =
ASSERT_TRUE(ci::QueryIsPackageInstalled(
pkgid, ci::GetRequestMode(kTestUserId),
kTestUserId));
- ValidatePackageFS(pkgid, appids);
+ ValidatePackageFS(pkgid, appids, kTestUserId, kTestGroupId);
+ if (kTestUserId == kGlobalUserUid) {
+ ci::UserList list = ci::GetUserList();
+ for (auto& l : list)
+ ValidatePackageRWFS(pkgid, std::get<0>(l), std::get<1>(l));
+ } else {
+ ValidatePackageRWFS(pkgid, kTestUserId, kTestGroupId);
+ }
}
void CheckPackageNonExistance(const std::string& pkgid,
return RunInstallerWithPkgrmgr(pkgmgr, type, mode);
}
+void BackupPath(const bf::path& path) {
+ bf::path backup_path = path.string() + ".bck";
+ std::cout << "Backup path: " << path << " to " << backup_path << std::endl;
+ bs::error_code error;
+ bf::remove_all(backup_path, error);
+ if (error)
+ LOG(ERROR) << "Remove failed: " << backup_path
+ << " (" << error.message() << ")";
+ if (bf::exists(path)) {
+ bf::rename(path, backup_path, error);
+ if (error)
+ LOG(ERROR) << "Failed to setup test environment. Does some previous"
+ << " test crashed? Path: "
+ << backup_path << " should not exist.";
+ assert(!error);
+ }
+}
+
+void RestorePath(const bf::path& path) {
+ bf::path backup_path = path.string() + ".bck";
+ std::cout << "Restore path: " << path << " from " << backup_path << std::endl;
+ bs::error_code error;
+ bf::remove_all(path, error);
+ if (error)
+ LOG(ERROR) << "Remove failed: " << path
+ << " (" << error.message() << ")";
+ if (bf::exists(backup_path)) {
+ bf::rename(backup_path, path, error);
+ if (error)
+ LOG(ERROR) << "Failed to restore backup path: " << backup_path
+ << " (" << error.message() << ")";
+ }
+}
+
+std::vector<bf::path> SetupBackupDirectories(uid_t uid) {
+ std::vector<bf::path> entries;
+ bf::path db_dir = bf::path("/opt/dbspace");
+ if (uid != kGlobalUserUid)
+ db_dir = db_dir / "user" / std::to_string(uid);
+ for (auto e : kDBEntries) {
+ bf::path path = db_dir / e;
+ entries.emplace_back(path);
+ }
+
+ if (uid == kGlobalUserUid) {
+ entries.emplace_back(kSkelDir);
+ entries.emplace_back(kGlobalManifestDir);
+ ci::UserList list = ci::GetUserList();
+ for (auto l : list) {
+ bf::path apps = std::get<2>(l) / "apps_rw";
+ entries.emplace_back(apps);
+ }
+ } else {
+ tzplatform_set_user(uid);
+ bf::path approot = tzplatform_getenv(TZ_USER_APPROOT);
+ tzplatform_reset_user();
+ entries.emplace_back(approot);
+ }
+
+ bf::path apps_rw = ci::GetRootAppPath(false, uid);
+ entries.emplace_back(apps_rw);
+
+ return entries;
+}
+
} // namespace
namespace common_installer {
class SmokeEnvironment : public testing::Environment {
public:
- explicit SmokeEnvironment(const bf::path& home) : home_(home) {
+ explicit SmokeEnvironment(uid_t uid) : uid_(uid) {
}
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);
- }
+ backups_ = SetupBackupDirectories(uid_);
+ 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);
+ // TODO(s89.jang): Uninstall smoke packages to clear security context
+ for (auto& path : backups_)
+ RestorePath(path);
}
private:
- bf::path home_;
+ uid_t uid_;
+ std::vector<bf::path> backups_;
};
class SmokeTest : public testing::Test {
std::string pkgid = "smokeapp04";
std::string appid = "smokeapp04.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(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
- ValidateDataFiles(pkgid);
+ ValidateDataFiles(pkgid, kTestUserId);
}
TEST_F(SmokeTest, DeinstallationMode) {
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"));
}
ASSERT_EQ(DisablePackage(pkgid, PackageType::WGT),
ci::AppInstaller::Result::OK);
ASSERT_TRUE(ci::QueryIsDisabledPackage(pkgid, kTestUserId));
- ValidatePackageFS(pkgid, {appid});
+ ValidatePackage(pkgid, {appid});
}
TEST_F(SmokeTest, DeltaMode) {
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_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")); // NOLINT
+ ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ "res" / "wgt" / "images" / "tizen_32.png")); // NOLINT
+ ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ "res" / "wgt" / "js" / "main.js")); // NOLINT
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "version 2\n")); // NOLINT
}
ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK);
std::string pkgid = "smokeapp10";
std::string appid = "smokeapp10.RecoveryModeForUpdate";
- AddDataFiles(pkgid);
+ 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);
ValidatePackage(pkgid, {appid});
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
- ValidateDataFiles(pkgid);
+ ValidateDataFiles(pkgid, kTestUserId);
}
TEST_F(SmokeTest, RecoveryMode_ForDelta) {
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);
ScopedTzipInterface interface(pkgid);
ValidatePackage(pkgid, {appid});
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
- ValidateDataFiles(pkgid);
+ ValidateDataFiles(pkgid, kTestUserId);
}
TEST_F(SmokeTest, InstallationMode_GoodSignature) {
std::string pkgid = "smokeapp07";
std::string appid = "smokeapp07.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(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
- ValidateDataFiles(pkgid);
+ ValidateDataFiles(pkgid, kTestUserId);
}
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});
+ 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});
+ 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),
ci::AppInstaller::Result::OK);
- CheckPackageNonExistance(pkgid, {appid1, appid2});
+ 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});
+ 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});
+ 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});
+ ValidatePackage(pkgid, {appid1});
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "2\n"));
- ValidateDataFiles(pkgid);
+ 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});
+ 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});
+ ValidatePackage(pkgid, {appid1});
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "1\n"));
- ValidateDataFiles(pkgid);
+ 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});
+ 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});
+ ValidatePackage(pkgid, {appid1});
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "1\n"));
- ValidateDataFiles(pkgid);
+ ValidateDataFiles(pkgid, kTestUserId);
}
TEST_F(SmokeTest, MountInstallationMode) {
std::string appid = "smokeapp29.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(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
- ValidateDataFiles(pkgid);
+ ValidateDataFiles(pkgid, kTestUserId);
}
TEST_F(SmokeTest, MountInstallationMode_Rollback) {
std::string appid = "smokeapp34.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(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
- ValidateDataFiles(pkgid);
+ ValidateDataFiles(pkgid, kTestUserId);
}
TEST_F(SmokeTest, UserDefinedPlugins) {
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
- bf::path directory =
- bf::path("/home") / tzplatform_getenv(TZ_SYS_DEFAULT_USER);
testing::AddGlobalTestEnvironment(
- new common_installer::SmokeEnvironment(directory));
+ new common_installer::SmokeEnvironment(kGlobalUserUid));
return RUN_ALL_TESTS();
}