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 root_path = ci::GetRootAppPath(false,
- kTestUserId);
- bf::path file_path = root_path / pkgid / relative;
+ bf::path file_path = GetPackageRoot(pkgid) / 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 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 = root_path / pkgid;
+ 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";
void PackageCheckCleanup(const std::string& pkgid,
const std::vector<std::string>&) {
- bf::path root_path = ci::GetRootAppPath(
- false, kTestUserId);
- bf::path package_path = root_path / pkgid;
+ bf::path package_path = GetPackageRoot(pkgid);
ASSERT_FALSE(bf::exists(package_path));
bf::path manifest_path =
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, type) != ci::AppInstaller::Result::OK) {
- LOG(ERROR) << "Failed to install application. Cannot update";
- return ci::AppInstaller::Result::UNKNOWN;
- }
- 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(), "-u", kTestUserIdStr.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) {
bf::path path_new = kSmokePackagesDirectory / "UpdateMode_2.wgt";
std::string pkgid = "smokeapp04";
std::string appid = "smokeapp04.UpdateMode";
- ASSERT_EQ(Update(path_old, path_new, PackageType::WGT),
- ci::AppInstaller::Result::OK);
+ ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid);
+ 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);
}
TEST_F(SmokeTest, DeinstallationMode) {
ValidatePackage(pkgid, {appid});
// Check delta modifications
- bf::path root_path = ci::GetRootAppPath(false,
- kTestUserId);
- ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "DELETED"));
- ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "ADDED"));
+ ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid) / "res" / "wgt" / "DELETED"));
+ ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid) / "res" / "wgt" / "ADDED"));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "2\n"));
}
std::string appid = "smokeapp20.ClearMode";
ASSERT_EQ(Install(path, PackageType::WGT),
ci::AppInstaller::Result::OK);
- bf::path root_path = ci::GetRootAppPath(false,
- kTestUserId);
bs::error_code error;
- bf::create_directory(root_path / pkgid / "data" / "dir", error);
+ bf::create_directory(GetPackageRoot(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_TRUE(TouchFile(GetPackageRoot(pkgid) / "data" / "dir" / "file"));
+ ASSERT_TRUE(TouchFile(GetPackageRoot(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"));
+ ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid) / "data" / "dir" / "file"));
+ ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid) / "res" / "file"));
}
TEST_F(SmokeTest, DeltaMode) {
ValidatePackage(pkgid, {appid});
// Check delta modifications
- bf::path root_path = ci::GetRootAppPath(false,
- kTestUserId);
- 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
- 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"));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "version 2\n"));
+ 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
}
TEST_F(SmokeTest, RecoveryMode_ForInstallation) {
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);
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);
- std::string pkgid = "smokeapp10";
- std::string appid = "smokeapp10.RecoveryModeForUpdate";
bf::path recovery_file = FindRecoveryFile();
ASSERT_FALSE(recovery_file.empty());
ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
ValidatePackage(pkgid, {appid});
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
+ ValidateDataFiles(pkgid);
}
TEST_F(SmokeTest, RecoveryMode_ForDelta) {
RemoveAllRecoveryFiles();
ASSERT_EQ(MountInstall(path_old, PackageType::WGT),
ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid);
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);
}
TEST_F(SmokeTest, InstallationMode_GoodSignature) {
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, PackageType::WGT, RequestResult::FAIL),
- ci::AppInstaller::Result::ERROR);
+ ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid);
+ 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);
}
TEST_F(SmokeTest, InstallationMode_Hybrid) {
std::string pkgid = "smokehyb02";
std::string appid1 = "smokehyb02.Web";
std::string appid2 = "smokehyb02.Native";
- ASSERT_EQ(Update(path_old, path_new, PackageType::HYBRID),
+ ASSERT_EQ(Install(path_old, PackageType::HYBRID),
+ ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid);
+ ASSERT_EQ(Install(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"));
+ ValidateDataFiles(pkgid);
}
TEST_F(SmokeTest, DeinstallationMode_Hybrid) {
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"));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "version 2\n"));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/MODIFIED", "version 2\n"));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "version 2\n")); // NOLINT
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/MODIFIED", "version 2\n")); // NOLINT
}
TEST_F(SmokeTest, MountInstallationMode_Hybrid) {
std::string pkgid = "smokehyb05";
std::string appid1 = "smokehyb05.web";
std::string appid2 = "smokehyb05.service";
- ASSERT_EQ(MountInstall(path, PackageType::HYBRID), ci::AppInstaller::Result::OK);
+ ASSERT_EQ(MountInstall(path, PackageType::HYBRID),
+ ci::AppInstaller::Result::OK);
ScopedTzipInterface interface(pkgid);
ValidatePackage(pkgid, {appid1, appid2});
}
std::string pkgid = "smokehyb06";
std::string appid1 = "smokehyb06.web";
std::string appid2 = "smokehyb06.service";
- ASSERT_EQ(MountUpdate(path_old, path_new, PackageType::WGT),
+ ASSERT_EQ(MountInstall(path_old, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid);
+ ASSERT_EQ(MountInstall(path_new, PackageType::WGT),
ci::AppInstaller::Result::OK);
ScopedTzipInterface interface(pkgid);
ValidatePackage(pkgid, {appid1, appid2});
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "2\n"));
+ ValidateDataFiles(pkgid);
}
TEST_F(SmokeTest, InstallationMode_Rollback_Hybrid) {
std::string pkgid = "smokehyb08";
std::string appid1 = "smokehyb08.web";
std::string appid2 = "smokehyb08.service";
- ASSERT_EQ(Update(path_old, path_new, PackageType::HYBRID,
+ ASSERT_EQ(Install(path_old, PackageType::HYBRID),
+ ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid);
+ ASSERT_EQ(Install(path_new, PackageType::HYBRID,
RequestResult::FAIL), ci::AppInstaller::Result::ERROR);
ValidatePackage(pkgid, {appid1, appid2});
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "1\n"));
+ ValidateDataFiles(pkgid);
}
TEST_F(SmokeTest, MountInstallationMode_Rollback_Hybrid) {
std::string pkgid = "smokehyb10";
std::string appid1 = "smokehyb10.web";
std::string appid2 = "smokehyb10.service";
- ASSERT_EQ(MountUpdate(path_old, path_new, PackageType::HYBRID,
+ ASSERT_EQ(MountInstall(path_old, PackageType::HYBRID),
+ ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid);
+ ASSERT_EQ(MountInstall(path_new, PackageType::HYBRID,
RequestResult::FAIL), ci::AppInstaller::Result::ERROR);
ScopedTzipInterface interface(pkgid);
ValidatePackage(pkgid, {appid1, appid2});
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "1\n"));
+ ValidateDataFiles(pkgid);
}
TEST_F(SmokeTest, MountInstallationMode) {
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),
+ ASSERT_EQ(MountInstall(path_old, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid);
+ 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);
}
TEST_F(SmokeTest, MountInstallationMode_Rollback) {
- bf::path path = kSmokePackagesDirectory / "MountInstallationMode_Rollback.wgt";
+ bf::path path =
+ kSmokePackagesDirectory / "MountInstallationMode_Rollback.wgt";
std::string pkgid = "smokeapp33";
std::string appid = "smokeapp33.web";
ASSERT_EQ(MountInstall(path, PackageType::WGT, RequestResult::FAIL),
TEST_F(SmokeTest, MountUpdateMode_Rollback) {
bf::path path_old = kSmokePackagesDirectory / "MountUpdateMode_Rollback.wgt";
- bf::path path_new = kSmokePackagesDirectory / "MountUpdateMode_Rollback_2.wgt";
+ bf::path path_new =
+ kSmokePackagesDirectory / "MountUpdateMode_Rollback_2.wgt";
std::string pkgid = "smokeapp34";
std::string appid = "smokeapp34.web";
- ASSERT_EQ(MountUpdate(path_old, path_new, PackageType::WGT,
+ ASSERT_EQ(MountInstall(path_old, PackageType::WGT),
+ ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid);
+ 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);
}
TEST_F(SmokeTest, UserDefinedPlugins) {