Wgt-backend and tpk-backend have common util functions for smoke tests.
They should be exported to lib in app-installers.
Submit together:
- https://review.tizen.org/gerrit/#/c/149136/
- https://review.tizen.org/gerrit/#/c/149601/
Change-Id: I405ee42332bc443fd9749e78008093280f9bbf57
Signed-off-by: Damian Pietruchowski <d.pietruchow@samsung.com>
BuildRequires: boost-devel
BuildRequires: cmake
BuildRequires: gtest-devel
+BuildRequires: app-installers-tests
BuildRequires: pkgconfig(app-installers)
BuildRequires: pkgconfig(manifest-parser)
BuildRequires: pkgconfig(wgt-manifest-handlers)
SET(DESTINATION_DIR wgt-backend-ut)
+SET(TARGET_SMOKE_UTILS smoke-utils)
# Executables
ADD_EXECUTABLE(${TARGET_SMOKE_TEST}
smoke_utils.cc
)
ADD_EXECUTABLE(${TARGET_SMOKE_TEST_EXTENSIVE}
- extensive_smoke_test.cc
- smoke_utils.h
- smoke_utils.cc
+ extensive_smoke_test.cc
+ smoke_utils.h
+ smoke_utils.cc
)
ADD_EXECUTABLE(${TARGET_SMOKE_TEST_HELPER}
smoke_test_helper.cc
# FindGTest module do not sets all needed libraries in GTEST_LIBRARIES and
# GTest main libraries is still missing, so additional linking of
# GTEST_MAIN_LIBRARIES is needed.
-TARGET_LINK_LIBRARIES(${TARGET_SMOKE_TEST} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_LIBNAME_HYBRID} ${GTEST_MAIN_LIBRARIES})
-TARGET_LINK_LIBRARIES(${TARGET_SMOKE_TEST_EXTENSIVE} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_LIBNAME_HYBRID} ${GTEST_MAIN_LIBRARIES})
+TARGET_LINK_LIBRARIES(${TARGET_SMOKE_TEST} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_LIBNAME_HYBRID} ${GTEST_MAIN_LIBRARIES} ${TARGET_SMOKE_UTILS})
+TARGET_LINK_LIBRARIES(${TARGET_SMOKE_TEST_EXTENSIVE} PRIVATE ${TARGET_LIBNAME_WGT} ${TARGET_LIBNAME_HYBRID} ${GTEST_MAIN_LIBRARIES} ${TARGET_SMOKE_UTILS})
TARGET_LINK_LIBRARIES(${TARGET_SMOKE_TEST_HELPER} PRIVATE ${TARGET_LIBNAME_WGT})
TARGET_LINK_LIBRARIES(${TARGET_MANIFEST_TEST} PRIVATE ${TARGET_LIBNAME_WGT} ${GTEST_MAIN_LIBRARIES})
#include <common/utils/subprocess.h>
#include <common/utils/file_util.h>
+#include <unit_tests/common/smoke_utils.h>
#include <gtest/gtest.h>
#include <gtest/gtest-death-test.h>
#include "unit_tests/smoke_utils.h"
+namespace ci = common_installer;
-namespace common_installer {
+namespace smoke_test {
class SmokeEnvironment : public testing::Environment {
public:
request_mode_ = mode;
}
void SetUp() override {
- if (request_mode_ == ci::RequestMode::USER) {
- ASSERT_TRUE(AddTestUser(kNormalUserName));
- } else {
- kTestUserId = kGlobalUserUid;
- kTestGroupId = kGlobalUserGid;
- kTestUserIdStr = std::to_string(kTestUserId);
- }
- backups_ = SetupBackupDirectories();
+ if (request_mode_ == ci::RequestMode::USER)
+ ASSERT_TRUE(AddTestUser(&test_user));
+ backups_ = SetupBackupDirectories(test_user.uid);
for (auto& path : backups_)
- BackupPath(path);
+ ASSERT_TRUE(BackupPath(path));
}
void TearDown() override {
ASSERT_TRUE(request_mode_ == ci::RequestMode::GLOBAL ||
(request_mode_ == ci::RequestMode::USER &&
- kGlobalUserUid != kTestUserId));
- UninstallAllSmokeApps(request_mode_);
+ kGlobalUserUid != test_user.uid));
+ WgtBackendInterface backend(std::to_string(test_user.uid));
+ UninstallAllSmokeApps(request_mode_, test_user.uid, &backend);
for (auto& path : backups_)
- RestorePath(path);
+ ASSERT_TRUE(RestorePath(path));
if (request_mode_ == ci::RequestMode::USER)
- ASSERT_TRUE(DeleteTestUser(kNormalUserName));
+ ASSERT_TRUE(DeleteTestUser());
}
+ User test_user;
private:
ci::RequestMode request_mode_;
std::vector<bf::path> backups_;
};
+} // namespace smoke_test
+
+namespace {
+
+testing::Environment *env = nullptr;
+void signalHandler(int signum) {
+ env->TearDown();
+ exit(signum);
+}
+
+smoke_test::SmokeEnvironment *dcast(testing::Environment* _env) {
+ return dynamic_cast<smoke_test::SmokeEnvironment *>(_env);
+}
+
+} // namespace
+
+namespace smoke_test {
+
class SmokeTest : public testing::Test {
+ public:
+ SmokeTest() : backend(std::to_string(dcast(env)->test_user.uid)),
+ params{PackageType::WGT, false} {
+ params.test_user.uid = dcast(env)->test_user.uid;
+ params.test_user.gid = dcast(env)->test_user.gid;
+ }
+ protected:
+ WgtBackendInterface backend;
+ TestParameters params;
};
-class PreloadSmokeTest : public testing::Test {
- void SetUp() override {
- ASSERT_EQ(kGlobalUserUid, kTestUserId);
+class HybridSmokeTest : public testing::Test {
+ public:
+ HybridSmokeTest() : backend(std::to_string(dcast(env)->test_user.uid)),
+ params{PackageType::HYBRID, false} {
+ params.test_user.uid = dcast(env)->test_user.uid;
+ params.test_user.gid = dcast(env)->test_user.gid;
}
+ protected:
+ HybridBackendInterface backend;
+ TestParameters params;
};
TEST_F(SmokeTest, RecoveryMode_ForInstallation) {
std::string pkgid = "smokewgt09";
std::string appid = "smokewgt09.RecoveryModeForInstallation";
+ std::string test_user_str = std::to_string(params.test_user.uid);
std::vector<std::string> args =
- {"", "-i", path.string(), "-u", kTestUserIdStr.c_str()};
- CrashAfterEachStep(args, [=](int step) -> bool {
+ {"", "-i", path.string(), "-u", test_user_str.c_str()};
+ backend.CrashAfterEachStep(&args, [&](int step) -> bool {
if (step >= 1) {
- bf::path recovery_file = FindRecoveryFile();
+ bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
+ params.test_user.uid);
EXTENDED_ASSERT_FALSE(recovery_file.empty());
- EXTENDED_ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
+ EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
ci::AppInstaller::Result::OK);
- EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
+ EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
}
return true;
- });
+ }, params.pkg_type);
}
TEST_F(SmokeTest, RecoveryMode_ForUpdate) {
bf::path path_old = kSmokePackagesDirectory / "RecoveryMode_ForUpdate.wgt";
bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForUpdate_2.wgt";
- RemoveAllRecoveryFiles();
- ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK);
+ RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
+ ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK);
std::string pkgid = "smokewgt10";
std::string appid = "smokewgt10.RecoveryModeForUpdate";
- AddDataFiles(pkgid, kTestUserId);
+ AddDataFiles(pkgid, params.test_user.uid);
+ std::string test_user_str = std::to_string(params.test_user.uid);
std::vector<std::string> args =
- {"", "-i", path_new.string(), "-u", kTestUserIdStr.c_str()};
- CrashAfterEachStep(args, [=](int step) -> bool {
+ {"", "-i", path_new.string(), "-u", test_user_str.c_str()};
+ backend.CrashAfterEachStep(&args, [&](int step) -> bool {
if (step >= 1) {
- bf::path recovery_file = FindRecoveryFile();
+ bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
+ params.test_user.uid);
EXTENDED_ASSERT_FALSE(recovery_file.empty());
- EXTENDED_ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
+ EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
ci::AppInstaller::Result::OK);
- EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
- "res/wgt/VERSION", "1\n"));
- EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ "res/wgt/VERSION", "1\n", params));
+ EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
}
return true;
- });
+ }, params.pkg_type);
}
TEST_F(SmokeTest, RecoveryMode_ForDelta) {
bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForDelta.delta";
std::string pkgid = "smokewgt30";
std::string appid = "smokewgt30.RecoveryModeForDelta";
- RemoveAllRecoveryFiles();
- ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid, kTestUserId);
+ RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
+ ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, params.test_user.uid);
+ std::string test_user_str = std::to_string(params.test_user.uid);
std::vector<std::string> args =
- {"", "-i", path_new.string(), "-u", kTestUserIdStr.c_str()};
- CrashAfterEachStep(args, [=](int step) -> bool {
+ {"", "-i", path_new.string(), "-u", test_user_str.c_str()};
+ backend.CrashAfterEachStep(&args, [&](int step) -> bool {
if (step >= 1) {
- bf::path recovery_file = FindRecoveryFile();
+ bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
+ params.test_user.uid);
EXTENDED_ASSERT_FALSE(recovery_file.empty());
- EXTENDED_ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
+ EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
ci::AppInstaller::Result::OK);
- EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
- "res/wgt/VERSION", "1\n"));
- EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ "res/wgt/VERSION", "1\n", params));
+ EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
}
return true;
- });
+ }, params.pkg_type);
}
TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
bf::path path = kSmokePackagesDirectory / "RecoveryMode_ForMountInstall.wgt";
std::string pkgid = "smokewgt31";
std::string appid = "smokewgt31.RecoveryModeForMountInstall";
- RemoveAllRecoveryFiles();
+ RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
+ std::string test_user_str = std::to_string(params.test_user.uid);
std::vector<std::string> args =
- {"", "-w", path.string(), "-u", kTestUserIdStr.c_str()};
- CrashAfterEachStep(args, [=](int step) -> bool {
+ {"", "-w", path.string(), "-u", test_user_str.c_str()};
+ backend.CrashAfterEachStep(&args, [&](int step) -> bool {
if (step >= 1) {
- bf::path recovery_file = FindRecoveryFile();
+ bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
+ params.test_user.uid);
EXTENDED_ASSERT_FALSE(recovery_file.empty());
- EXTENDED_ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
+ EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
ci::AppInstaller::Result::OK);
- EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
+ EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
}
return true;
- });
+ }, params.pkg_type);
}
TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
kSmokePackagesDirectory / "RecoveryMode_ForMountUpdate_2.wgt";
std::string pkgid = "smokewgt32";
std::string appid = "smokewgt32.RecoveryModeForMountUpdate";
- RemoveAllRecoveryFiles();
- ASSERT_EQ(MountInstall(path_old, PackageType::WGT),
- ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid, kTestUserId);
+ RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
+ ASSERT_EQ(backend.MountInstall(path_old), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, params.test_user.uid);
+ std::string test_user_str = std::to_string(params.test_user.uid);
std::vector<std::string> args =
- {"", "-w", path_new.string(), "-u", kTestUserIdStr.c_str()};
- CrashAfterEachStep(args, [=](int step) -> bool {
+ {"", "-w", path_new.string(), "-u", test_user_str.c_str()};
+ backend.CrashAfterEachStep(&args, [&](int step) -> bool {
if (step >= 1) {
// Filesystem may be mounted after crash
- ScopedTzipInterface poweroff_unmount_interface(pkgid);
+ ScopedTzipInterface poweroff_unmount_interface(pkgid,
+ params.test_user.uid);
poweroff_unmount_interface.Release();
- bf::path recovery_file = FindRecoveryFile();
+ bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
+ params.test_user.uid);
EXTENDED_ASSERT_FALSE(recovery_file.empty());
- EXTENDED_ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
+ EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
ci::AppInstaller::Result::OK);
- ScopedTzipInterface interface(pkgid);
- EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ScopedTzipInterface interface(pkgid, params.test_user.uid);
+ EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(
- pkgid, "res/wgt/VERSION", "1\n"));
- EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ pkgid, "res/wgt/VERSION", "1\n", params));
+ EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
}
return true;
- });
+ }, params.pkg_type);
}
std::string pkgid = "smokewgt06";
std::string appid = "smokewgt06.InstallationModeRollback";
- const char* argv[] = {"", "-i", path.c_str(), "-u", kTestUserIdStr.c_str()};
- TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [=]() -> bool {
- EXTENDED_ASSERT_EQ(Install(path, PackageType::WGT, RequestResult::FAIL),
- ci::AppInstaller::Result::ERROR);
- EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
+ std::string test_user_str = std::to_string(params.test_user.uid);
+ const char* argv[] = {"", "-i", path.c_str(), "-u", test_user_str.c_str()};
+ backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool {
+ EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
return true;
});
}
bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Rollback_2.wgt";
std::string pkgid = "smokewgt07";
std::string appid = "smokewgt07.UpdateModeRollback";
- ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid, kTestUserId);
+ ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, params.test_user.uid);
+ std::string test_user_str = std::to_string(params.test_user.uid);
const char* argv[] =
- {"", "-i", path_new.c_str(), "-u", kTestUserIdStr.c_str()};
- TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [=]() -> bool {
- EXTENDED_ASSERT_EQ(Install(path_new, PackageType::WGT, RequestResult::FAIL),
- ci::AppInstaller::Result::ERROR);
- EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ {"", "-i", path_new.c_str(), "-u", test_user_str.c_str()};
+ backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool {
+ EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
- "res/wgt/VERSION", "1\n"));
- EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ "res/wgt/VERSION", "1\n", params));
+ EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
return true;
});
}
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(backend.Install(path), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, params.test_user.uid);
+ std::string test_user_str = std::to_string(params.test_user.uid);
const char* argv[] =
- {"", "-i", delta_package.c_str(), "-u", kTestUserIdStr.c_str()};
- TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [=]() -> bool {
- EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ {"", "-i", delta_package.c_str(), "-u", test_user_str.c_str()};
+ backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool {
+ EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED",
- "version 1\n"));
- EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
- EXTENDED_ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
- "res/wgt/DELETED"));
- EXTENDED_ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
- "res/wgt/ADDED"));
+ "version 1\n", params));
+ EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
+ EXTENDED_ASSERT_TRUE(bf::exists(GetPackageRoot(
+ pkgid, params.test_user.uid) / "res/wgt/DELETED"));
+ EXTENDED_ASSERT_FALSE(bf::exists(GetPackageRoot(
+ pkgid, params.test_user.uid) / "res/wgt/ADDED"));
return true;
});
}
-TEST_F(SmokeTest, InstallationMode_Rollback_Hybrid) {
+TEST_F(HybridSmokeTest, InstallationMode_Rollback) {
bf::path path = kSmokePackagesDirectory /
"InstallationMode_Rollback_Hybrid.wgt";
std::string pkgid = "smokehyb07";
std::string appid1 = "smokehyb07.web";
- const char* argv[] = {"", "-i", path.c_str(), "-u", kTestUserIdStr.c_str()};
- TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [=]() -> bool {
- EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid1}));
+ std::string test_user_str = std::to_string(params.test_user.uid);
+ const char* argv[] = {"", "-i", path.c_str(), "-u", test_user_str.c_str()};
+ backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool {
+ EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
return true;
- }, PackageType::HYBRID);
+ });
}
-TEST_F(SmokeTest, UpdateMode_Rollback_Hybrid) {
+TEST_F(HybridSmokeTest, UpdateMode_Rollback) {
bf::path path_old = kSmokePackagesDirectory /
"UpdateMode_Rollback_Hybrid.wgt";
bf::path path_new = kSmokePackagesDirectory /
"UpdateMode_Rollback_Hybrid_2.wgt";
std::string pkgid = "smokehyb08";
std::string appid1 = "smokehyb08.web";
- ASSERT_EQ(Install(path_old, PackageType::HYBRID),
- ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid, kTestUserId);
+ ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, params.test_user.uid);
+ std::string test_user_str = std::to_string(params.test_user.uid);
const char* argv[] =
- {"", "-i", path_new.c_str(), "-u", kTestUserIdStr.c_str()};
- TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [=]() -> bool {
- EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
+ {"", "-i", path_new.c_str(), "-u", test_user_str.c_str()};
+ backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool {
+ EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
- "res/wgt/VERSION", "1\n"));
+ "res/wgt/VERSION", "1\n", params));
EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
- "lib/VERSION", "1\n"));
- EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ "lib/VERSION", "1\n", params));
+ EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
return true;
- }, PackageType::HYBRID);
+ });
}
-TEST_F(SmokeTest, DeltaMode_Rollback_Hybrid) {
+TEST_F(HybridSmokeTest, 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);
- const char* argv[] = {"", "-i", path.c_str(), "-u", kTestUserIdStr.c_str()};
- TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [=]() -> bool {
- EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
+ ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, params.test_user.uid);
+ std::string test_user_str = std::to_string(params.test_user.uid);
+ const char* argv[] = {"", "-i", path.c_str(), "-u", test_user_str.c_str()};
+ backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool {
+ EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
// Check delta modifications
- bf::path root_path = GetPackageRoot(pkgid, kTestUserId);
+ bf::path root_path = GetPackageRoot(pkgid, params.test_user.uid);
EXTENDED_ASSERT_TRUE(bf::exists(root_path / "res" / "wgt" / "DELETED"));
EXTENDED_ASSERT_FALSE(bf::exists(root_path / "res" / "wgt" / "ADDED"));
EXTENDED_ASSERT_TRUE(bf::exists(root_path / "lib" / "DELETED"));
EXTENDED_ASSERT_FALSE(bf::exists(root_path / "lib" / "ADDED"));
EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED",
- "version 1\n"));
+ "version 1\n", params));
EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/MODIFIED",
- "version 1\n"));
- EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ "version 1\n", params));
+ EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
return true;
});
}
-TEST_F(SmokeTest, MountInstallationMode_Rollback_Hybrid) {
+TEST_F(HybridSmokeTest, MountInstallationMode_Rollback) {
bf::path path = kSmokePackagesDirectory /
"MountInstallationMode_Rollback_Hybrid.wgt";
std::string pkgid = "smokehyb09";
std::string appid1 = "smokehyb09.web";
- const char* argv[] = {"", "-w", path.c_str(), "-u", kTestUserIdStr.c_str()};
- TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [=]() -> bool {
- ScopedTzipInterface interface(pkgid);
- EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid1}));
+ std::string test_user_str = std::to_string(params.test_user.uid);
+ const char* argv[] = {"", "-w", path.c_str(), "-u", test_user_str.c_str()};
+ backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool {
+ ScopedTzipInterface interface(pkgid, params.test_user.uid);
+ EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
return true;
- }, PackageType::HYBRID);
+ });
}
-TEST_F(SmokeTest, MountUpdateMode_Rollback_Hybrid) {
+TEST_F(HybridSmokeTest, MountUpdateMode_Rollback) {
bf::path path_old = kSmokePackagesDirectory /
"MountUpdateMode_Rollback_Hybrid.wgt";
bf::path path_new = kSmokePackagesDirectory /
"MountUpdateMode_Rollback_Hybrid_2.wgt";
std::string pkgid = "smokehyb10";
std::string appid1 = "smokehyb10.web";
- ASSERT_EQ(MountInstall(path_old, PackageType::HYBRID),
- ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid, kTestUserId);
+ ASSERT_EQ(backend.MountInstall(path_old), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, params.test_user.uid);
+ std::string test_user_str = std::to_string(params.test_user.uid);
const char* argv[] =
- {"", "-w", path_new.c_str(), "-u", kTestUserIdStr.c_str()};
- TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [=]() -> bool {
- ScopedTzipInterface interface(pkgid);
- EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
+ {"", "-w", path_new.c_str(), "-u", test_user_str.c_str()};
+ backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool {
+ ScopedTzipInterface interface(pkgid, params.test_user.uid);
+ EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
- "res/wgt/VERSION", "1\n"));
+ "res/wgt/VERSION", "1\n", params));
EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
- "lib/VERSION", "1\n"));
- EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ "lib/VERSION", "1\n", params));
+ EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
return true;
});
}
kSmokePackagesDirectory / "MountInstallationMode_Rollback.wgt";
std::string pkgid = "smokewgt33";
std::string appid = "smokewgt33.web";
- const char* argv[] = {"", "-w", path.c_str(), "-u", kTestUserIdStr.c_str()};
- TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [=]() -> bool {
- ScopedTzipInterface interface(pkgid);
- EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
+ std::string test_user_str = std::to_string(params.test_user.uid);
+ const char* argv[] = {"", "-w", path.c_str(), "-u", test_user_str.c_str()};
+ backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [=]() -> bool {
+ ScopedTzipInterface interface(pkgid, params.test_user.uid);
+ EXTENDED_ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
return true;
});
}
kSmokePackagesDirectory / "MountUpdateMode_Rollback_2.wgt";
std::string pkgid = "smokewgt34";
std::string appid = "smokewgt34.web";
- ASSERT_EQ(MountInstall(path_old, PackageType::WGT),
+ ASSERT_EQ(backend.MountInstall(path_old),
ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid, kTestUserId);
+ AddDataFiles(pkgid, params.test_user.uid);
+ std::string test_user_str = std::to_string(params.test_user.uid);
const char* argv[] =
- {"", "-w", path_new.c_str(), "-u", kTestUserIdStr.c_str()};
- TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [=]() -> bool {
- EXTENDED_ASSERT_EQ(MountInstall(path_new, PackageType::WGT,
- RequestResult::FAIL), ci::AppInstaller::Result::ERROR);
- ScopedTzipInterface interface(pkgid);
- EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ {"", "-w", path_new.c_str(), "-u", test_user_str.c_str()};
+ backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool {
+ ScopedTzipInterface interface(pkgid, params.test_user.uid);
+ EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
- "res/wgt/VERSION", "1\n"));
- EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ "res/wgt/VERSION", "1\n", params));
+ EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
return true;
});
}
-} // namespace common_installer
+} // namespace smoke_test
int main(int argc, char** argv) {
- ci::RequestMode request_mode = ParseRequestMode(argc, argv);
+ ci::RequestMode request_mode = smoke_test::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);
- env = testing::AddGlobalTestEnvironment(
- new common_installer::SmokeEnvironment(request_mode));
- signal(SIGINT, signalHandler);
- signal(SIGSEGV, signalHandler);
+ ::env = testing::AddGlobalTestEnvironment(
+ new smoke_test::SmokeEnvironment(request_mode));
+ signal(SIGINT, ::signalHandler);
+ signal(SIGSEGV, ::signalHandler);
return RUN_ALL_TESTS();
}
// Use of this source code is governed by an apache-2.0 license that can be
// found in the LICENSE file.
+#include <gtest/gtest-death-test.h>
+
#include <common/utils/subprocess.h>
#include <common/utils/file_util.h>
+#include <common/pkgmgr_query.h>
+#include <unit_tests/common/smoke_utils.h>
-#include <gtest/gtest-death-test.h>
+#include <memory>
#include "unit_tests/smoke_utils.h"
+namespace st = smoke_test;
+namespace bf = boost::filesystem;
+namespace bs = boost::system;
+namespace ci = common_installer;
+namespace bo = boost::program_options;
-namespace common_installer {
+namespace smoke_test {
class SmokeEnvironment : public testing::Environment {
public:
request_mode_ = mode;
}
void SetUp() override {
- if (request_mode_ == ci::RequestMode::USER) {
- ASSERT_TRUE(AddTestUser(kNormalUserName));
- } else {
- kTestUserId = kGlobalUserUid;
- kTestGroupId = kGlobalUserGid;
- kTestUserIdStr = std::to_string(kTestUserId);
- }
- backups_ = SetupBackupDirectories();
+ if (request_mode_ == ci::RequestMode::USER)
+ ASSERT_TRUE(AddTestUser(&test_user));
+ backups_ = SetupBackupDirectories(test_user.uid);
for (auto& path : backups_)
ASSERT_TRUE(BackupPath(path));
}
void TearDown() override {
ASSERT_TRUE(request_mode_ == ci::RequestMode::GLOBAL ||
(request_mode_ == ci::RequestMode::USER &&
- kGlobalUserUid != kTestUserId));
- UninstallAllSmokeApps(request_mode_);
+ kGlobalUserUid != test_user.uid));
+ WgtBackendInterface backend(std::to_string(test_user.uid));
+ UninstallAllSmokeApps(request_mode_, test_user.uid, &backend);
for (auto& path : backups_)
ASSERT_TRUE(RestorePath(path));
if (request_mode_ == ci::RequestMode::USER)
- ASSERT_TRUE(DeleteTestUser(kNormalUserName));
+ ASSERT_TRUE(DeleteTestUser());
}
+ User test_user;
private:
ci::RequestMode request_mode_;
std::vector<bf::path> backups_;
};
+} // namespace smoke_test
+
+namespace {
+
+testing::Environment *env = nullptr;
+void signalHandler(int signum) {
+ env->TearDown();
+ exit(signum);
+}
+
+smoke_test::SmokeEnvironment *dcast(testing::Environment* _env) {
+ return dynamic_cast<smoke_test::SmokeEnvironment *>(_env);
+}
+
+} // namespace
+
+namespace smoke_test {
+
class SmokeTest : public testing::Test {
+ public:
+ SmokeTest() : backend(std::to_string(dcast(env)->test_user.uid)),
+ params{PackageType::WGT, false} {
+ params.test_user.uid = dcast(env)->test_user.uid;
+ params.test_user.gid = dcast(env)->test_user.gid;
+ }
+ protected:
+ WgtBackendInterface backend;
+ TestParameters params;
+};
+
+class RollbackSmokeTest : public testing::Test {
+ public:
+ RollbackSmokeTest() : backend(std::to_string(dcast(env)->test_user.uid),
+ RequestResult::FAIL), params{PackageType::WGT, false} {
+ params.test_user.uid = dcast(env)->test_user.uid;
+ params.test_user.gid = dcast(env)->test_user.gid;
+ }
+ protected:
+ WgtBackendInterface backend;
+ TestParameters params;
+};
+
+class HybridSmokeTest : public testing::Test {
+ public:
+ HybridSmokeTest() : backend(std::to_string(dcast(env)->test_user.uid)),
+ params{PackageType::HYBRID, false} {
+ params.test_user.uid = dcast(env)->test_user.uid;
+ params.test_user.gid = dcast(env)->test_user.gid;
+ }
+ protected:
+ HybridBackendInterface backend;
+ TestParameters params;
+};
+
+class RollbackHybridSmokeTest : public testing::Test {
+ public:
+ RollbackHybridSmokeTest() : backend(std::to_string(dcast(env)->test_user.uid),
+ RequestResult::FAIL), params{PackageType::HYBRID, false} {
+ params.test_user.uid = dcast(env)->test_user.uid;
+ params.test_user.gid = dcast(env)->test_user.gid;
+ }
+ protected:
+ HybridBackendInterface backend;
+ TestParameters params;
};
class PreloadSmokeTest : public testing::Test {
- void SetUp() override {
- ASSERT_EQ(kGlobalUserUid, kTestUserId);
+ public:
+ PreloadSmokeTest() : backend(std::to_string(dcast(env)->test_user.uid)),
+ params{PackageType::WGT, true} {
+ params.test_user.uid = dcast(env)->test_user.uid;
+ params.test_user.gid = dcast(env)->test_user.gid;
}
+ protected:
+ WgtBackendInterface backend;
+ TestParameters params;
+};
+
+class HybridPreloadSmokeTest : public testing::Test {
+ public:
+ HybridPreloadSmokeTest() : backend(std::to_string(dcast(env)->test_user.uid)),
+ params{PackageType::HYBRID, true} {
+ params.test_user.uid = dcast(env)->test_user.uid;
+ params.test_user.gid = dcast(env)->test_user.gid;
+ }
+ protected:
+ HybridBackendInterface backend;
+ TestParameters params;
};
TEST_F(SmokeTest, InstallationMode) {
bf::path path = kSmokePackagesDirectory / "InstallationMode.wgt";
std::string pkgid = "smokewgt03";
std::string appid = "smokewgt03.InstallationMode";
- ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
}
TEST_F(SmokeTest, UpdateMode) {
bf::path path_new = kSmokePackagesDirectory / "UpdateMode_2.wgt";
std::string pkgid = "smokewgt04";
std::string appid = "smokewgt04.UpdateMode";
- ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid, kTestUserId);
- ASSERT_EQ(Install(path_new, PackageType::WGT), ci::AppInstaller::Result::OK);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ASSERT_EQ(backend.InstallSuccess(path_old), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, params.test_user.uid);
+ ASSERT_EQ(backend.Install(path_new), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
- ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n",
+ params));
+ ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
}
TEST_F(SmokeTest, DeinstallationMode) {
bf::path path = kSmokePackagesDirectory / "DeinstallationMode.wgt";
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, false),
- ci::AppInstaller::Result::OK);
- ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
+ ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+ ASSERT_EQ(backend.Uninstall(pkgid), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
}
TEST_F(SmokeTest, RDSMode) {
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;
+ bf::path(ci::GetRootAppPath(false, params.test_user.uid)) / "tmp" / pkgid;
bs::error_code error;
bf::create_directories(sdk_expected_directory.parent_path(), error);
ASSERT_FALSE(error);
- ASSERT_TRUE(CopyDir(delta_directory, sdk_expected_directory));
- ASSERT_EQ(RDSUpdate(path, pkgid, PackageType::WGT),
- ci::AppInstaller::Result::OK);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ASSERT_TRUE(ci::CopyDir(delta_directory, sdk_expected_directory));
+ ASSERT_EQ(backend.RDSUpdate(path, pkgid), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
// Check delta modifications
- ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
"res" / "wgt" / "DELETED"));
- ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
"res" / "wgt" / "ADDED"));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "2\n"));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "2\n",
+ params));
}
TEST_F(SmokeTest, EnablePkg) {
bf::path path = kSmokePackagesDirectory / "EnablePkg.wgt";
std::string pkgid = "smokewgt22";
- 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_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+ ASSERT_EQ(backend.DisablePackage(pkgid), ci::AppInstaller::Result::OK);
+ ASSERT_EQ(backend.EnablePackage(pkgid), ci::AppInstaller::Result::OK);
- ci::PkgQueryInterface pkg_query(pkgid, kTestUserId);
- ASSERT_TRUE(pkg_query.IsPackageInstalled(ci::GetRequestMode(kTestUserId)));
+ ci::PkgQueryInterface pkg_query(pkgid, params.test_user.uid);
+ ASSERT_TRUE(pkg_query.IsPackageInstalled(
+ ci::GetRequestMode(params.test_user.uid)));
}
TEST_F(SmokeTest, DisablePkg) {
bf::path path = kSmokePackagesDirectory / "DisablePkg.wgt";
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));
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+ ASSERT_EQ(backend.DisablePackage(pkgid), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ci::QueryIsDisabledPackage(pkgid, params.test_user.uid));
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
}
TEST_F(SmokeTest, DeltaMode) {
bf::path delta_package = kSmokePackagesDirectory / "DeltaMode.delta";
std::string pkgid = "smokewgt17";
std::string appid = "smokewgt17.DeltaMode";
- ASSERT_EQ(DeltaInstall(path, delta_package, PackageType::WGT),
- ci::AppInstaller::Result::OK);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ASSERT_EQ(backend.InstallSuccess(path), ci::AppInstaller::Result::OK);
+ ASSERT_EQ(backend.Install(delta_package), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
// Check delta modifications
- ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
"res" / "wgt" / "DELETED"));
- ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
"res" / "wgt" / "ADDED"));
- ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
"res" / "wgt" / "css" / "style.css"));
- ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
"res" / "wgt" / "images" / "tizen_32.png"));
- ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
"res" / "wgt" / "js" / "main.js"));
ASSERT_TRUE(ValidateFileContentInPackage(
- pkgid, "res/wgt/MODIFIED", "version 2\n"));
+ pkgid, "res/wgt/MODIFIED", "version 2\n", params));
}
TEST_F(SmokeTest, RecoveryMode_ForInstallation) {
bf::path path = kSmokePackagesDirectory / "RecoveryMode_ForInstallation.wgt";
- Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
- backend_crash.Run("-i", path.string(), "-u", kTestUserIdStr.c_str());
+ ci::Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
+ std::string test_uid_str = std::to_string(params.test_user.uid);
+ backend_crash.Run("-i", path.string(), "-u", test_uid_str.c_str());
ASSERT_NE(backend_crash.Wait(), 0);
std::string pkgid = "smokewgt09";
std::string appid = "smokewgt09.RecoveryModeForInstallation";
- bf::path recovery_file = FindRecoveryFile();
+ bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
+ params.test_user.uid);
ASSERT_FALSE(recovery_file.empty());
- ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
- ci::AppInstaller::Result::OK);
- ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
+ ASSERT_EQ(backend.Recover(recovery_file), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
}
TEST_F(SmokeTest, RecoveryMode_ForUpdate) {
bf::path path_old = kSmokePackagesDirectory / "RecoveryMode_ForUpdate.wgt";
bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForUpdate_2.wgt";
- RemoveAllRecoveryFiles();
- ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK);
+ RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
+ ASSERT_EQ(backend.InstallSuccess(path_old), ci::AppInstaller::Result::OK);
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());
+ AddDataFiles(pkgid, params.test_user.uid);
+ ci::Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
+ std::string test_uid_str = std::to_string(params.test_user.uid);
+ backend_crash.Run("-i", path_new.string(), "-u", test_uid_str.c_str());
ASSERT_NE(backend_crash.Wait(), 0);
- bf::path recovery_file = FindRecoveryFile();
+ bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
+ params.test_user.uid);
ASSERT_FALSE(recovery_file.empty());
- ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
- ci::AppInstaller::Result::OK);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ASSERT_EQ(backend.Recover(recovery_file), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
- ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n",
+ params));
+ ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
}
TEST_F(SmokeTest, RecoveryMode_ForDelta) {
bf::path path_old = kSmokePackagesDirectory / "RecoveryMode_ForDelta.wgt";
bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForDelta.delta";
- RemoveAllRecoveryFiles();
- ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK);
- Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
- backend_crash.Run("-i", path_new.string(), "-u", kTestUserIdStr.c_str());
+ RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
+ ASSERT_EQ(backend.InstallSuccess(path_old), ci::AppInstaller::Result::OK);
+ ci::Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
+ std::string test_uid_str = std::to_string(params.test_user.uid);
+ backend_crash.Run("-i", path_new.string(), "-u", test_uid_str.c_str());
ASSERT_NE(backend_crash.Wait(), 0);
std::string pkgid = "smokewgt30";
std::string appid = "smokewgt30.RecoveryModeForDelta";
- bf::path recovery_file = FindRecoveryFile();
+ bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
+ params.test_user.uid);
ASSERT_FALSE(recovery_file.empty());
- ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
- ci::AppInstaller::Result::OK);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ASSERT_EQ(backend.Recover(recovery_file), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n",
+ params));
}
TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
bf::path path = kSmokePackagesDirectory / "RecoveryMode_ForMountInstall.wgt";
- RemoveAllRecoveryFiles();
- Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
- backend_crash.Run("-w", path.string(), "-u", kTestUserIdStr.c_str());
+ RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
+ ci::Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
+ std::string test_uid_str = std::to_string(params.test_user.uid);
+ backend_crash.Run("-w", path.string(), "-u", test_uid_str.c_str());
ASSERT_NE(backend_crash.Wait(), 0);
std::string pkgid = "smokewgt31";
std::string appid = "smokewgt31.RecoveryModeForMountInstall";
- bf::path recovery_file = FindRecoveryFile();
+ bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
+ params.test_user.uid);
ASSERT_FALSE(recovery_file.empty());
- ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
- ci::AppInstaller::Result::OK);
- ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
+ ASSERT_EQ(backend.Recover(recovery_file), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
}
TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
kSmokePackagesDirectory / "RecoveryMode_ForMountUpdate_2.wgt";
std::string pkgid = "smokewgt32";
std::string appid = "smokewgt32.RecoveryModeForMountUpdate";
- RemoveAllRecoveryFiles();
- ASSERT_EQ(MountInstall(path_old, PackageType::WGT),
+ RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
+ ASSERT_EQ(backend.MountInstallSuccess(path_old),
ci::AppInstaller::Result::OK);
- 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());
+ AddDataFiles(pkgid, params.test_user.uid);
+ ci::Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
+ std::string test_uid_str = std::to_string(params.test_user.uid);
+ backend_crash.Run("-w", path_new.string(), "-u", test_uid_str.c_str());
ASSERT_NE(backend_crash.Wait(), 0);
// Filesystem may be mounted after crash
- ScopedTzipInterface poweroff_unmount_interface(pkgid);
+ ScopedTzipInterface poweroff_unmount_interface(pkgid, params.test_user.uid);
poweroff_unmount_interface.Release();
- bf::path recovery_file = FindRecoveryFile();
+ bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
+ params.test_user.uid);
ASSERT_FALSE(recovery_file.empty());
- ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
- ci::AppInstaller::Result::OK);
+ ASSERT_EQ(backend.Recover(recovery_file), ci::AppInstaller::Result::OK);
- ScopedTzipInterface interface(pkgid);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
- ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ ScopedTzipInterface interface(pkgid, params.test_user.uid);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n",
+ params));
+ ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
}
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);
+ ASSERT_EQ(backend.Install(path), 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);
+ ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::ERROR);
}
-TEST_F(SmokeTest, InstallationMode_Rollback) {
+TEST_F(RollbackSmokeTest, InstallationMode) {
bf::path path = kSmokePackagesDirectory / "InstallationMode_Rollback.wgt";
std::string pkgid = "smokewgt06";
std::string appid = "smokewgt06.InstallationModeRollback";
- ASSERT_EQ(Install(path, PackageType::WGT, RequestResult::FAIL),
- ci::AppInstaller::Result::ERROR);
- ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
+ ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::ERROR);
+ ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
}
-TEST_F(SmokeTest, UpdateMode_Rollback) {
+TEST_F(RollbackSmokeTest, UpdateMode) {
bf::path path_old = kSmokePackagesDirectory / "UpdateMode_Rollback.wgt";
bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Rollback_2.wgt";
std::string pkgid = "smokewgt07";
std::string appid = "smokewgt07.UpdateModeRollback";
- ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid, kTestUserId);
- ASSERT_EQ(Install(path_new, PackageType::WGT, RequestResult::FAIL),
- ci::AppInstaller::Result::ERROR);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ASSERT_EQ(backend.InstallSuccess(path_old), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, params.test_user.uid);
+ ASSERT_EQ(backend.Install(path_new), ci::AppInstaller::Result::ERROR);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
- ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n",
+ params));
+ ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
}
-TEST_F(SmokeTest, DeltaMode_Rollback) {
+TEST_F(RollbackSmokeTest, DeltaMode) {
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_EQ(backend.InstallSuccess(path), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, params.test_user.uid);
+ ASSERT_EQ(backend.Install(delta_package), ci::AppInstaller::Result::ERROR);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED",
- "version 1\n"));
- ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
- ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ "version 1\n", params));
+ ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
+ ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
"res/wgt/DELETED"));
- ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
+ ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
"res/wgt/ADDED"));
}
-TEST_F(SmokeTest, InstallationMode_Hybrid) {
+TEST_F(HybridSmokeTest, InstallationMode) {
bf::path path = kSmokePackagesDirectory / "InstallationMode_Hybrid.wgt";
std::string pkgid = "smokehyb01";
// Excutable for native app doesn't create symlink
std::string appid1 = "smokehyb01.Web";
- ASSERT_EQ(Install(path, PackageType::HYBRID), ci::AppInstaller::Result::OK);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
+ ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
}
-TEST_F(SmokeTest, UpdateMode_Hybrid) {
+TEST_F(HybridSmokeTest, UpdateMode) {
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";
- ASSERT_EQ(Install(path_old, PackageType::HYBRID),
- ci::AppInstaller::Result::OK);
-// AddDataFiles(pkgid, kTestUserId);
- ASSERT_EQ(Install(path_new, PackageType::HYBRID),
+ ASSERT_EQ(backend.InstallSuccess(path_old), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, params.test_user.uid);
+ ASSERT_EQ(backend.Install(path_new),
ci::AppInstaller::Result::OK);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "VERSION", "2\n"));
-// ValidateDataFiles(pkgid, kTestUserId);
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n",
+ params));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "VERSION", "2\n", params));
+ ValidateDataFiles(pkgid, params.test_user.uid);
}
-TEST_F(SmokeTest, DeinstallationMode_Hybrid) {
+TEST_F(HybridSmokeTest, DeinstallationMode) {
bf::path path = kSmokePackagesDirectory / "DeinstallationMode_Hybrid.wgt";
std::string pkgid = "smokehyb03";
std::string appid1 = "smokehyb03.Web";
- ASSERT_EQ(Install(path, PackageType::HYBRID),
- ci::AppInstaller::Result::OK);
- ASSERT_EQ(Uninstall(pkgid, PackageType::HYBRID, false),
- ci::AppInstaller::Result::OK);
- ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid1}));
+ ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+ ASSERT_EQ(backend.Uninstall(pkgid), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
}
-TEST_F(SmokeTest, DeltaMode_Hybrid) {
+TEST_F(HybridSmokeTest, DeltaMode) {
bf::path path = kSmokePackagesDirectory / "DeltaMode_Hybrid.wgt";
bf::path delta_package = kSmokePackagesDirectory / "DeltaMode_Hybrid.delta";
std::string pkgid = "smokehyb04";
std::string appid1 = "smokehyb04.Web";
- ASSERT_EQ(DeltaInstall(path, delta_package, PackageType::HYBRID),
- ci::AppInstaller::Result::OK);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
+ ASSERT_EQ(backend.InstallSuccess(path), ci::AppInstaller::Result::OK);
+ ASSERT_EQ(backend.Install(delta_package), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
// Check delta modifications
- bf::path root_path = ci::GetRootAppPath(false,
- kTestUserId);
+ bf::path root_path = ci::GetRootAppPath(false, params.test_user.uid);
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 / "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")); // NOLINT
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/MODIFIED", "version 2\n")); // NOLINT
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "version 2\n", params)); // NOLINT
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/MODIFIED", "version 2\n", params)); // NOLINT
}
-TEST_F(SmokeTest, MountInstallationMode_Hybrid) {
+TEST_F(HybridSmokeTest, MountInstallationMode) {
bf::path path = kSmokePackagesDirectory / "MountInstallationMode_Hybrid.wgt";
std::string pkgid = "smokehyb05";
std::string appid1 = "smokehyb05.web";
- ASSERT_EQ(MountInstall(path, PackageType::HYBRID),
- ci::AppInstaller::Result::OK);
- ScopedTzipInterface interface(pkgid);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
+ ASSERT_EQ(backend.MountInstall(path), ci::AppInstaller::Result::OK);
+ ScopedTzipInterface interface(pkgid, params.test_user.uid);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
}
-TEST_F(SmokeTest, MountUpdateMode_Hybrid) {
+TEST_F(HybridSmokeTest, MountUpdateMode) {
bf::path path_old = kSmokePackagesDirectory / "MountUpdateMode_Hybrid.wgt";
bf::path path_new = kSmokePackagesDirectory / "MountUpdateMode_Hybrid_2.wgt";
std::string pkgid = "smokehyb06";
std::string appid1 = "smokehyb06.web";
- ASSERT_EQ(MountInstall(path_old, PackageType::HYBRID),
- ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid, kTestUserId);
- ASSERT_EQ(MountInstall(path_new, PackageType::HYBRID),
- ci::AppInstaller::Result::OK);
- ScopedTzipInterface interface(pkgid);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
+ ASSERT_EQ(backend.MountInstallSuccess(path_old),
+ ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, params.test_user.uid);
+ ASSERT_EQ(backend.MountInstall(path_new), ci::AppInstaller::Result::OK);
+ ScopedTzipInterface interface(pkgid, params.test_user.uid);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "2\n"));
- ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n",
+ params));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "2\n",
+ params));
+ ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
}
-TEST_F(SmokeTest, InstallationMode_Rollback_Hybrid) {
+TEST_F(RollbackHybridSmokeTest, InstallationMode) {
bf::path path = kSmokePackagesDirectory /
"InstallationMode_Rollback_Hybrid.wgt";
std::string pkgid = "smokehyb07";
std::string appid1 = "smokehyb07.web";
- ASSERT_EQ(Install(path, PackageType::HYBRID, RequestResult::FAIL),
- ci::AppInstaller::Result::ERROR);
- ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid1}));
+ ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::ERROR);
+ ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
}
-TEST_F(SmokeTest, UpdateMode_Rollback_Hybrid) {
+TEST_F(RollbackHybridSmokeTest, UpdateMode) {
bf::path path_old = kSmokePackagesDirectory /
"UpdateMode_Rollback_Hybrid.wgt";
bf::path path_new = kSmokePackagesDirectory /
"UpdateMode_Rollback_Hybrid_2.wgt";
std::string pkgid = "smokehyb08";
std::string appid1 = "smokehyb08.web";
- ASSERT_EQ(Install(path_old, PackageType::HYBRID),
- ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid, kTestUserId);
- ASSERT_EQ(Install(path_new, PackageType::HYBRID,
- RequestResult::FAIL), ci::AppInstaller::Result::ERROR);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
+ ASSERT_EQ(backend.InstallSuccess(path_old), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, params.test_user.uid);
+ ASSERT_EQ(backend.Install(path_new), ci::AppInstaller::Result::ERROR);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "1\n"));
- ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n",
+ params));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "1\n",
+ params));
+ ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
}
-TEST_F(SmokeTest, DeltaMode_Rollback_Hybrid) {
+TEST_F(RollbackHybridSmokeTest, DeltaMode) {
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),
+ ASSERT_EQ(backend.InstallSuccess(path), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, params.test_user.uid);
+ ASSERT_EQ(backend.Install(delta_package),
ci::AppInstaller::Result::ERROR);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
// Check delta modifications
- bf::path root_path = GetPackageRoot(pkgid, kTestUserId);
+ bf::path root_path = GetPackageRoot(pkgid, params.test_user.uid);
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"));
+ "version 1\n", params));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/MODIFIED",
- "version 1\n"));
- ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ "version 1\n", params));
+ ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
}
-TEST_F(SmokeTest, MountInstallationMode_Rollback_Hybrid) {
+TEST_F(RollbackHybridSmokeTest, MountInstallationMode) {
bf::path path = kSmokePackagesDirectory /
"MountInstallationMode_Rollback_Hybrid.wgt";
std::string pkgid = "smokehyb09";
std::string appid1 = "smokehyb09.web";
- ASSERT_EQ(MountInstall(path, PackageType::HYBRID, RequestResult::FAIL),
- ci::AppInstaller::Result::ERROR);
- ScopedTzipInterface interface(pkgid);
- ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid1}));
+ ASSERT_EQ(backend.MountInstall(path), ci::AppInstaller::Result::ERROR);
+ ScopedTzipInterface interface(pkgid, params.test_user.uid);
+ ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
}
-TEST_F(SmokeTest, MountUpdateMode_Rollback_Hybrid) {
+TEST_F(RollbackHybridSmokeTest, MountUpdateMode) {
bf::path path_old = kSmokePackagesDirectory /
"MountUpdateMode_Rollback_Hybrid.wgt";
bf::path path_new = kSmokePackagesDirectory /
"MountUpdateMode_Rollback_Hybrid_2.wgt";
std::string pkgid = "smokehyb10";
std::string appid1 = "smokehyb10.web";
- ASSERT_EQ(MountInstall(path_old, PackageType::HYBRID),
+ ASSERT_EQ(backend.MountInstallSuccess(path_old),
ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid, kTestUserId);
- ASSERT_EQ(MountInstall(path_new, PackageType::HYBRID,
- RequestResult::FAIL), ci::AppInstaller::Result::ERROR);
- ScopedTzipInterface interface(pkgid);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
+ AddDataFiles(pkgid, params.test_user.uid);
+ ASSERT_EQ(backend.MountInstall(path_new), ci::AppInstaller::Result::ERROR);
+ ScopedTzipInterface interface(pkgid, params.test_user.uid);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "1\n"));
- ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n",
+ params));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "1\n",
+ params));
+ ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
}
TEST_F(SmokeTest, MountInstallationMode) {
bf::path path = kSmokePackagesDirectory / "MountInstallationMode.wgt";
std::string pkgid = "smokewgt28";
std::string appid = "smokewgt28.InstallationMode";
- ASSERT_EQ(MountInstall(path, PackageType::WGT), ci::AppInstaller::Result::OK);
- ScopedTzipInterface interface(pkgid);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ASSERT_EQ(backend.MountInstall(path), ci::AppInstaller::Result::OK);
+ ScopedTzipInterface interface(pkgid, params.test_user.uid);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
}
TEST_F(SmokeTest, MountUpdateMode) {
bf::path path_new = kSmokePackagesDirectory / "MountUpdateMode_2.wgt";
std::string pkgid = "smokewgt29";
std::string appid = "smokewgt29.UpdateMode";
- ASSERT_EQ(MountInstall(path_old, PackageType::WGT),
- ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid, kTestUserId);
- ASSERT_EQ(MountInstall(path_new, PackageType::WGT),
- ci::AppInstaller::Result::OK);
- ScopedTzipInterface interface(pkgid);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ASSERT_EQ(backend.MountInstallSuccess(path_old),
+ ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, params.test_user.uid);
+ ASSERT_EQ(backend.MountInstall(path_new), ci::AppInstaller::Result::OK);
+ ScopedTzipInterface interface(pkgid, params.test_user.uid);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
- ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n",
+ params));
+ ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
}
-TEST_F(SmokeTest, MountInstallationMode_Rollback) {
+TEST_F(RollbackSmokeTest, MountInstallationMode) {
bf::path path =
kSmokePackagesDirectory / "MountInstallationMode_Rollback.wgt";
std::string pkgid = "smokewgt33";
std::string appid = "smokewgt33.web";
- ASSERT_EQ(MountInstall(path, PackageType::WGT, RequestResult::FAIL),
- ci::AppInstaller::Result::ERROR);
- ScopedTzipInterface interface(pkgid);
- ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
+ ASSERT_EQ(backend.MountInstall(path), ci::AppInstaller::Result::ERROR);
+ ScopedTzipInterface interface(pkgid, params.test_user.uid);
+ ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
}
-TEST_F(SmokeTest, MountUpdateMode_Rollback) {
+TEST_F(RollbackSmokeTest, MountUpdateMode) {
bf::path path_old = kSmokePackagesDirectory / "MountUpdateMode_Rollback.wgt";
bf::path path_new =
kSmokePackagesDirectory / "MountUpdateMode_Rollback_2.wgt";
std::string pkgid = "smokewgt34";
std::string appid = "smokewgt34.web";
- ASSERT_EQ(MountInstall(path_old, PackageType::WGT),
+ ASSERT_EQ(backend.MountInstallSuccess(path_old),
ci::AppInstaller::Result::OK);
- AddDataFiles(pkgid, kTestUserId);
- ASSERT_EQ(MountInstall(path_new, PackageType::WGT,
- RequestResult::FAIL), ci::AppInstaller::Result::ERROR);
- ScopedTzipInterface interface(pkgid);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ AddDataFiles(pkgid, params.test_user.uid);
+ ASSERT_EQ(backend.MountInstall(path_new), ci::AppInstaller::Result::ERROR);
+ ScopedTzipInterface interface(pkgid, params.test_user.uid);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
- ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
- ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n",
+ params));
+ ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
}
TEST_F(SmokeTest, UserDefinedPlugins) {
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);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
std::vector<std::string> res;
- ci::PkgQueryInterface pkg_query(pkgid, kTestUserId);
+ ci::PkgQueryInterface pkg_query(pkgid, params.test_user.uid);
ASSERT_TRUE(pkg_query.PrivilegesForPkgId(&res));
ASSERT_TRUE(std::find(res.begin(), res.end(), call_privilege) != res.end());
ASSERT_TRUE(std::find(res.begin(), res.end(), location_privilege)
bf::path path = kSmokePackagesDirectory / "InstallExternalMode.wgt";
std::string pkgid = "smokewgt35";
std::string appid = "smokewgt35.web";
- ASSERT_EQ(InstallWithStorage(path, PackageType::WGT, StorageType::EXTERNAL),
+ ASSERT_EQ(backend.InstallWithStorage(path, StorageType::EXTERNAL),
ci::AppInstaller::Result::OK);
- ValidateExternalPackage(pkgid, {appid});
+ ValidateExternalPackage(pkgid, {appid}, params);
}
TEST_F(SmokeTest, MigrateLegacyExternalImageMode) {
std::string pkgid = "smokewgt36";
std::string appid = "smokewgt36.web";
bf::path legacy_path = kSmokePackagesDirectory / kLegacyExtImageDir;
- if (kTestUserIdStr == kDefaultUserIdStr || kTestUserId == kGlobalUserUid) {
- ASSERT_EQ(MigrateLegacyExternalImage(pkgid, path, legacy_path,
- PackageType::WGT), ci::AppInstaller::Result::OK);
- ValidateExternalPackage(pkgid, {appid});
+ std::string test_uid_str = std::to_string(params.test_user.uid);
+ if (test_uid_str == kDefaultUserIdStr ||
+ params.test_user.uid == kGlobalUserUid) {
+ ASSERT_EQ(backend.MigrateLegacyExternalImage(pkgid, path, legacy_path),
+ ci::AppInstaller::Result::OK);
+ ValidateExternalPackage(pkgid, {appid}, params);
} else {
- ASSERT_EQ(MigrateLegacyExternalImage(pkgid, path, legacy_path,
- PackageType::WGT), ci::AppInstaller::Result::ERROR);
+ ASSERT_EQ(backend.MigrateLegacyExternalImage(pkgid, path, legacy_path),
+ ci::AppInstaller::Result::ERROR);
}
}
-TEST_F(PreloadSmokeTest, InstallationMode_Preload) {
+TEST_F(PreloadSmokeTest, InstallationMode) {
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));
+ ASSERT_EQ(backend.InstallPreload(path), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
}
-TEST_F(PreloadSmokeTest, UpdateMode_Preload) {
+TEST_F(PreloadSmokeTest, UpdateMode) {
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_EQ(backend.InstallPreload(path_old), ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, params.test_user.uid);
+ ASSERT_EQ(backend.InstallPreload(path_new), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2",
- true));
- ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
+ params));
+ ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
}
-TEST_F(PreloadSmokeTest, DeinstallationMode_Preload) {
+TEST_F(PreloadSmokeTest, DeinstallationMode) {
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});
+ ASSERT_EQ(backend.InstallPreload(path), ci::AppInstaller::Result::OK);
+ ASSERT_EQ(backend.UninstallPreload(pkgid), ci::AppInstaller::Result::OK);
+ CheckPackageReadonlyNonExistance(pkgid, params);
}
-TEST_F(PreloadSmokeTest, ManifestDirectInstallMode) {
+TEST_F(SmokeTest, ManifestDirectInstallMode) {
ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
bf::path src_path = kSmokePackagesDirectory / "ManifestDirectInstallMode";
std::string pkgid = "smokewgt40";
std::string appid = "smokewgt40.ManifestDirectInstallMode";
- bf::path pkg_path = ci::GetRootAppPath(false, kTestUserId);
+ bf::path pkg_path = ci::GetRootAppPath(false, params.test_user.uid);
- CopyDir(src_path / pkgid, pkg_path / pkgid);
- ci::PkgQueryInterface pkg_query(pkgid, kTestUserId);
- ASSERT_FALSE(pkg_query.IsPackageInstalled(ci::GetRequestMode(kTestUserId)));
- ASSERT_EQ(ManifestDirectInstall(pkgid, PackageType::WGT),
+ ci::CopyDir(src_path / pkgid, pkg_path / pkgid);
+ ci::PkgQueryInterface pkg_query(pkgid, params.test_user.uid);
+ ASSERT_FALSE(pkg_query.IsPackageInstalled(
+ ci::GetRequestMode(params.test_user.uid)));
+ ASSERT_EQ(backend.ManifestDirectInstall(pkgid),
ci::AppInstaller::Result::OK);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
}
TEST_F(SmokeTest, ManifestDirectUpdateMode) {
std::string pkgid = "smokewgt41";
std::string appid = "smokewgt41.ManifestDirectUpdateMode";
- ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
- int install_time = GetAppInstalledTime(appid.c_str(), kTestUserId);
- ASSERT_EQ(ManifestDirectInstall(pkgid, PackageType::WGT),
+ ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+ int install_time = GetAppInstalledTime(appid.c_str(), params.test_user.uid);
+ ASSERT_EQ(backend.ManifestDirectInstall(pkgid),
ci::AppInstaller::Result::OK);
- ASSERT_TRUE(GetAppInstalledTime(appid.c_str(), kTestUserId) > install_time)
+ ASSERT_TRUE(GetAppInstalledTime(appid.c_str(),
+ params.test_user.uid) > install_time)
<< "Package is not updated (app installed time didn't change).";
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
}
TEST_F(PreloadSmokeTest, ReadonlyUpdateInstallMode) {
std::string pkgid = "smokewgt42";
std::string appid = "smokewgt42.ReadonlyUpdateInstallMode";
- ASSERT_EQ(InstallPreload(path, PackageType::WGT),
- ci::AppInstaller::Result::OK);
- ASSERT_EQ(Install(path, PackageType::WGT),
- ci::AppInstaller::Result::OK);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}, true));
+ ASSERT_EQ(backend.InstallPreload(path), ci::AppInstaller::Result::OK);
+ ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
}
TEST_F(PreloadSmokeTest, ReadonlyUpdateUninstallMode) {
std::string pkgid = "smokewgt43";
std::string appid = "smokewgt43.ReadonlyUpdateUninstallMode";
- ASSERT_EQ(InstallPreload(path, PackageType::WGT),
- ci::AppInstaller::Result::OK);
- ASSERT_EQ(Install(path, PackageType::WGT),
+ ASSERT_EQ(backend.InstallPreload(path),
ci::AppInstaller::Result::OK);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}, true));
- ASSERT_EQ(Uninstall(pkgid, PackageType::WGT, false),
- ci::AppInstaller::Result::OK);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}, true));
+ ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
+ ASSERT_EQ(backend.Uninstall(pkgid), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
}
-TEST_F(PreloadSmokeTest, ManifestDirectInstallMode_Hybrid) {
+TEST_F(HybridSmokeTest, ManifestDirectInstallMode) {
ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
bf::path src_path = kSmokePackagesDirectory /
"ManifestDirectInstallMode_Hybrid";
std::string pkgid = "smokehyb12";
std::string appid = "smokehyb12.ManifestDirectInstallModeHybrid";
- bf::path pkg_path = ci::GetRootAppPath(false, kTestUserId);
+ bf::path pkg_path = ci::GetRootAppPath(false, params.test_user.uid);
- CopyDir(src_path / pkgid, pkg_path / pkgid);
- ci::PkgQueryInterface pkg_query(pkgid, kTestUserId);
- ASSERT_FALSE(pkg_query.IsPackageInstalled(ci::GetRequestMode(kTestUserId)));
- ASSERT_EQ(ManifestDirectInstall(pkgid, PackageType::HYBRID),
+ ci::CopyDir(src_path / pkgid, pkg_path / pkgid);
+ ci::PkgQueryInterface pkg_query(pkgid, params.test_user.uid);
+ ASSERT_FALSE(pkg_query.IsPackageInstalled(
+ ci::GetRequestMode(params.test_user.uid)));
+ ASSERT_EQ(backend.ManifestDirectInstall(pkgid),
ci::AppInstaller::Result::OK);
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
}
-TEST_F(SmokeTest, ManifestDirectUpdateMode_Hybrid) {
+TEST_F(HybridSmokeTest, ManifestDirectUpdateMode) {
bf::path path = kSmokePackagesDirectory /
"ManifestDirectUpdateMode_Hybrid.wgt";
std::string pkgid = "smokehyb13";
std::string appid = "smokehyb13.ManifestDirectUpdateModeHybrid";
- ASSERT_EQ(Install(path, PackageType::HYBRID), ci::AppInstaller::Result::OK);
- int install_time = GetAppInstalledTime(appid.c_str(), kTestUserId);
- ASSERT_EQ(ManifestDirectInstall(pkgid, PackageType::HYBRID),
- ci::AppInstaller::Result::OK);
- ASSERT_TRUE(GetAppInstalledTime(appid.c_str(), kTestUserId) > install_time)
+ ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+ int install_time = GetAppInstalledTime(appid.c_str(), params.test_user.uid);
+ ASSERT_EQ(backend.ManifestDirectInstall(pkgid), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(GetAppInstalledTime(appid.c_str(),
+ params.test_user.uid) > install_time)
<< "Package is not updated (app installed time didn't change).";
- ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
}
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_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+ ValidatePackage(pkgid, {appid}, params);
+ bf::path root_path = ci::GetRootAppPath(false, params.test_user.uid);
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
}
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_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
+ bf::path root_path = ci::GetRootAppPath(false, params.test_user.uid);
ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT")); // NOLINT
ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-WGT")); // NOLINT
}
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}));
+ ASSERT_EQ(backend.InstallSuccess(path), ci::AppInstaller::Result::OK);
+ ASSERT_EQ(backend.Install(delta_package), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
// Check delta modifications
- bf::path root_path = ci::GetRootAppPath(false, kTestUserId);
+ bf::path root_path = ci::GetRootAppPath(false, params.test_user.uid);
ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT-2")); // NOLINT
ASSERT_TRUE(bf::is_regular_file(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) {
+TEST_F(HybridSmokeTest, 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_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1, appid2}, params));
+ bf::path root_path = ci::GetRootAppPath(false, params.test_user.uid);
ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT")); // NOLINT
ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-WGT")); // NOLINT
ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-TPK")); // NOLINT
}
-TEST_F(SmokeTest, SharedRes30HybridDelta) {
+TEST_F(HybridSmokeTest, 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}));
+ ASSERT_EQ(backend.InstallSuccess(path), ci::AppInstaller::Result::OK);
+ ASSERT_EQ(backend.Install(delta_package), ci::AppInstaller::Result::OK);
+ ASSERT_TRUE(ValidatePackage(pkgid, {appid1, appid2}, params));
// Check delta modifications
- bf::path root_path = ci::GetRootAppPath(false, kTestUserId);
+ bf::path root_path = ci::GetRootAppPath(false, params.test_user.uid);
ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT-2")); // NOLINT
ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-WGT-2")); // NOLINT
ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-TPK-2")); // NOLINT
}
TEST_F(SmokeTest, InstallExtendedMode) {
- ASSERT_TRUE(CheckAvailableExtendedStorage());
+ ASSERT_TRUE(CheckAvailableExtendedPath());
bf::path path = kSmokePackagesDirectory / "InstallExtendedMode.wgt";
std::string pkgid = "smokewgt44";
std::string appid = "smokewgt44.web";
- ASSERT_EQ(InstallWithStorage(path, PackageType::WGT, StorageType::EXTENDED),
+ ASSERT_EQ(backend.InstallWithStorage(path, StorageType::EXTENDED),
ci::AppInstaller::Result::OK);
- ValidatePackage(pkgid, {appid});
+ ASSERT_TRUE(ValidateExtendedPackage(pkgid, {appid}, params));
}
-} // namespace common_installer
+} // namespace smoke_test
int main(int argc, char** argv) {
- ci::RequestMode request_mode = ParseRequestMode(argc, argv);
+ ci::RequestMode request_mode = st::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);
- env = testing::AddGlobalTestEnvironment(
- new common_installer::SmokeEnvironment(request_mode));
- signal(SIGINT, signalHandler);
- signal(SIGSEGV, signalHandler);
+ ::env = testing::AddGlobalTestEnvironment(
+ new smoke_test::SmokeEnvironment(request_mode));
+ signal(SIGINT, ::signalHandler);
+ signal(SIGSEGV, ::signalHandler);
return RUN_ALL_TESTS();
}
// 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/range/iterator_range.hpp>
-#include <boost/format.hpp>
-#include <boost/program_options.hpp>
-#include <boost/system/error_code.hpp>
-
-#include <common/utils/subprocess.h>
-#include <common/step/configuration/step_fail.h>
-#include <common/utils/user_util.h>
-#include <common/utils/file_util.h>
-#include <common/request.h>
-
-#include <gtest/gtest.h>
-#include <gtest/gtest-death-test.h>
-
-#include <manifest_parser/utils/version_number.h>
-
-#include <pkgmgr-info.h>
-#include <signal.h>
-#include <unistd.h>
-#include <tzplatform_config.h>
-#include <vconf.h>
-#include <vconf-internal-keys.h>
-
-#include <array>
-#include <cstdio>
-#include <cstdlib>
-#include <regex>
+#include <unit_tests/common/smoke_utils.h>
#include "wgt/wgt_installer.h"
+#include "hybrid/hybrid_installer.h"
#include "unit_tests/smoke_utils.h"
-namespace bo = boost::program_options;
+namespace ci = common_installer;
+namespace st = smoke_test;
-const uid_t kGlobalUserUid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
-const uid_t kGlobalUserGid = tzplatform_getgid(TZ_SYS_GLOBALAPP_USER);
-const uid_t kDefaultUserUid = tzplatform_getuid(TZ_SYS_DEFAULT_USER);
-uid_t kTestUserId = kGlobalUserUid;
-gid_t kTestGroupId = kGlobalUserGid;
-const char kNormalUserName[] = "smokeuser";
-const char kSystemShareGroupName[] = "system_share";
-std::string kTestUserIdStr = std::to_string(kTestUserId);
-const std::string& kDefaultUserIdStr = std::to_string(kDefaultUserUid);
-const char kLegacyExtImageDir[] = "legacy_extimage_dir";
-const char kMigrateTestDBName[] = "app2sd_migrate.db";
+namespace smoke_test {
const bf::path kSmokePackagesDirectory =
"/usr/share/wgt-backend-ut/test_samples/smoke/";
-
-const char* rwDirectories[] = {
- "data",
- "cache",
- "shared/cache",
- "shared/data",
- "shared/trusted",
-};
-
-// common entries
-const std::vector<std::string> kDBEntries = {
- {".pkgmgr_parser.db"},
- {".pkgmgr_parser.db-journal"},
- {".pkgmgr_cert.db"},
- {".pkgmgr_cert.db-journal"},
- {".app2sd.db"},
- {".app2sd.db-journal"},
-};
-// globaluser entries
-const char kGlobalManifestDir[] = "/opt/share/packages";
-const char kSkelDir[] = "/etc/skel/apps_rw";
-const char kPreloadApps[] = "/usr/apps";
-const char kPreloadManifestDir[] = "/usr/share/packages";
-const char kPreloadIcons[] = "/usr/share/icons";
-
-testing::Environment *env = nullptr;
-void signalHandler(int signum) {
- env->TearDown();
- exit(signum);
-}
-
-ci::RequestMode ParseRequestMode(int argc, char** argv) {
- bo::options_description desc("Available options");
- desc.add_options()
- ("request-mode", bo::value<std::string>(), "set request mode")
- ("global-request,g", "set request mode to global")
- ("user-request,u", "set request mode to user");
-
- bo::variables_map vm;
- bo::store(bo::command_line_parser(argc, argv).
- options(desc).allow_unregistered().run(), vm);
- bo::notify(vm);
-
- if (vm.count("global-request")) {
- std::cout << "Request mode was set to global." << std::endl;
- return ci::RequestMode::GLOBAL;
- }
- if (vm.count("user-request")) {
- std::cout << "Request mode was set to user." << std::endl;
- return ci::RequestMode::USER;
- }
- if (vm.count("request-mode")) {
- if (vm["request-mode"].as<std::string>() == "global") {
- std::cout << "Request mode was set to global." << std::endl;
- return ci::RequestMode::GLOBAL;
- }
- if (vm["request-mode"].as<std::string>() == "user") {
- std::cout << "Request mode was set to user." << std::endl;
- return ci::RequestMode::USER;
- }
- std::cout << "Cannot set request mode to "
- << vm["request-mode"].as<std::string>() << std::endl;
- }
- std::cout << "Request mode was set to global." << std::endl;
- return ci::RequestMode::GLOBAL;
-}
-
-bool TouchFile(const bf::path& path) {
- FILE* f = fopen(path.c_str(), "w+");
- if (!f)
- return false;
- fclose(f);
- return true;
-}
-
-bool AddUser(const char *user_name) {
- GumUser* user = nullptr;
- user = gum_user_create_sync(FALSE);
- if (user == nullptr)
- LOG(WARNING) << "Failed to create gum user! (user name: "
- << user_name << ")";
- g_object_set(G_OBJECT(user), "username", user_name, "usertype",
- GUM_USERTYPE_NORMAL, NULL);
- gboolean rval = FALSE;
- rval = gum_user_add_sync(user);
- g_object_unref(user);
- return rval;
-}
-
-bool DeleteUser(const char *user_name, bool rem_home_dir) {
- bool rval = FALSE;
- GumUser* guser = gum_user_get_by_name_sync(user_name, FALSE);
- if (guser)
- rval = gum_user_delete_sync(guser, rem_home_dir);
- return rval;
-}
-
-bool AddTestUser(const char *user_name) {
- std::cout << "Adding test user: " << user_name << std::endl;
- AddUser(user_name);
- if (boost::optional<uid_t> uid = ci::GetUidByUserName(user_name)) {
- kTestUserId = *uid;
- kTestUserIdStr = std::to_string(kTestUserId);
- std::cout << "User created properly: uid=" << *uid;
- if (boost::optional<gid_t> gid = ci::GetGidByUid(*uid)) {
- kTestGroupId = *gid;
- std::cout << " gid=" << *gid;
- }
- std::cout << std::endl;
- return true;
- }
- LOG(ERROR) << "Adding test user failed";
- return false;
-}
-
-bool DeleteTestUser(const char *user_name) {
- std::cout << "Deleting test user: " << user_name << std::endl;
- uid_t test_uid;
- if (boost::optional<uid_t> uid = ci::GetUidByUserName(user_name))
- test_uid = *uid;
- DeleteUser(user_name, true);
- if (!ci::GetUidByUserName(user_name)) {
- std::cout << "User deleted properly: user_name=" << user_name
- << " uid=" << test_uid << std::endl;
- return true;
- }
- LOG(ERROR) << "Deleting test user failed";
- return false;
-}
-
-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("/wgt-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("/wgt-recovery")
- != std::string::npos) {
- return dir_entry.path();
- }
- }
- }
- return {};
-}
-
-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,
- bool is_readonly) {
- bf::path file_path = ci::GetRootAppPath(is_readonly, kTestUserId);
- file_path = file_path / 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, 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"));
- }
-}
-
-bool 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));
- EXTENDED_ASSERT_TRUE(bf::exists(pkg_path / "data" / "file1.txt"));
- EXTENDED_ASSERT_TRUE(bf::exists(pkg_path / "data" / "file2.txt"));
- }
- } else {
- auto pkg_path = GetPackageRoot(pkgid, uid);
- EXTENDED_ASSERT_TRUE(bf::exists(pkg_path / "data" / "file1.txt"));
- EXTENDED_ASSERT_TRUE(bf::exists(pkg_path / "data" / "file2.txt"));
- }
- return true;
-}
-
-bool ValidatePackageRWFS(const std::string& pkgid, uid_t uid) {
- bf::path root_path = ci::GetRootAppPath(false, uid);
- bf::path package_path = root_path / pkgid;
- bf::path data_path = package_path / rwDirectories[DATA];
- bf::path cache_path = package_path / rwDirectories[CACHE];
- bf::path shared_data_path = package_path / rwDirectories[SHARED_DATA];
-
- EXTENDED_ASSERT_TRUE(bf::exists(data_path));
- EXTENDED_ASSERT_TRUE(bf::exists(cache_path));
-
- struct stat stats;
- stat(data_path.c_str(), &stats);
- // gid of RW dirs should be system_share
- boost::optional<gid_t> system_share =
- ci::GetGidByGroupName(kSystemShareGroupName);
- EXTENDED_ASSERT_EQ(uid, stats.st_uid);
- EXTENDED_ASSERT_EQ(*system_share, stats.st_gid);
- if (bf::exists(shared_data_path)) {
- stat(shared_data_path.c_str(), &stats);
- EXTENDED_ASSERT_EQ(uid, stats.st_uid);
- EXTENDED_ASSERT_EQ(*system_share, stats.st_gid);
- }
-
- stat(cache_path.c_str(), &stats);
- EXTENDED_ASSERT_EQ(uid, stats.st_uid);
- EXTENDED_ASSERT_EQ(*system_share, stats.st_gid);
- return true;
+WgtBackendInterface::AppQueryInterfacePtr
+WgtBackendInterface::CreateQueryInterface() const {
+ return AppQueryInterfacePtr(new wgt::WgtAppQueryInterface());
}
-bool ValidatePackageFS(const std::string& pkgid,
- const std::vector<std::string>& appids,
- uid_t uid, gid_t gid, bool is_readonly) {
- bf::path root_path = ci::GetRootAppPath(is_readonly, uid);
- bf::path package_path = root_path / pkgid;
- bf::path shared_path = package_path / "shared";
- EXTENDED_ASSERT_TRUE(bf::exists(root_path));
- EXTENDED_ASSERT_TRUE(bf::exists(package_path));
- EXTENDED_ASSERT_TRUE(bf::exists(shared_path));
-
- bf::path manifest_path =
- bf::path(getUserManifestPath(uid, is_readonly)) / (pkgid + ".xml");
- EXTENDED_ASSERT_TRUE(bf::exists(manifest_path));
-
- for (auto& appid : appids) {
- bf::path binary_path = package_path / "bin" / appid;
- EXTENDED_ASSERT_TRUE(bf::exists(binary_path));
- }
-
- bf::path widget_root_path = package_path / "res" / "wgt";
- bf::path config_path = widget_root_path / "config.xml";
- EXTENDED_ASSERT_TRUE(bf::exists(widget_root_path));
- EXTENDED_ASSERT_TRUE(bf::exists(config_path));
-
- bf::path private_tmp_path = package_path / "tmp";
- EXTENDED_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);
- EXTENDED_ASSERT_FALSE(bf::exists(package_backup));
- EXTENDED_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;
- bool is_rw_dir = false;
- for (const auto rw_dir : rwDirectories) {
- bf::path rw_dir_path = rw_dir;
- is_rw_dir |= ci::MakeRelativePath(iter->path(), package_path)
- == rw_dir_path;
- }
- if (is_rw_dir || iter->path().filename() == ".mmc") {
- iter.no_push();
- continue;
- }
- struct stat stats;
- stat(iter->path().c_str(), &stats);
- EXTENDED_ASSERT_EQ(uid, stats.st_uid);
- EXTENDED_ASSERT_EQ(gid, stats.st_gid);
- }
- return true;
+WgtBackendInterface::AppInstallerPtr
+WgtBackendInterface::CreateInstaller(ci::PkgMgrPtr pkgmgr) const {
+ return AppInstallerPtr(new wgt::WgtInstaller(pkgmgr));
}
-void PackageCheckCleanup(const std::string& pkgid,
- const std::vector<std::string>&, bool is_readonly) {
- bf::path root_path = ci::GetRootAppPath(is_readonly, kTestUserId);
- bf::path package_path = root_path / pkgid;
- ASSERT_FALSE(bf::exists(package_path));
-
- bf::path manifest_path = bf::path(getUserManifestPath(kTestUserId,
- is_readonly)) / (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));
+WgtBackendInterface::AppQueryInterfacePtr
+HybridBackendInterface::CreateQueryInterface() const {
+ return AppQueryInterfacePtr(new wgt::WgtAppQueryInterface());
}
-bool ValidatePackage(const std::string& pkgid,
- const std::vector<std::string>& appids, bool is_readonly) {
- ci::PkgQueryInterface pkg_query(pkgid, kTestUserId);
- EXTENDED_ASSERT_TRUE(pkg_query.IsPackageInstalled(
- ci::GetRequestMode(kTestUserId)));
- EXTENDED_ASSERT_TRUE(ValidatePackageFS(
- pkgid, appids, kTestUserId, kTestGroupId, is_readonly));
- if (kTestUserId == kGlobalUserUid) {
- ci::UserList list = ci::GetUserList();
- for (auto& l : list)
- EXTENDED_ASSERT_TRUE(ValidatePackageRWFS(pkgid, std::get<0>(l)));
- } else {
- EXTENDED_ASSERT_TRUE(ValidatePackageRWFS(pkgid, kTestUserId));
- }
- return true;
+WgtBackendInterface::AppInstallerPtr
+HybridBackendInterface::CreateInstaller(ci::PkgMgrPtr pkgmgr) const {
+ return AppInstallerPtr(new hybrid::HybridInstaller(pkgmgr));
}
-void ValidateExternalPackageFS(const std::string& pkgid,
- const std::vector<std::string>& appids,
- uid_t uid, gid_t gid) {
- ASSERT_EQ(app2ext_usr_enable_external_pkg(pkgid.c_str(), uid), 0);
- bf::path root_path = ci::GetRootAppPath(false, uid);
- ASSERT_TRUE(bf::exists(root_path / pkgid / ".mmc" / "res"));
- ValidatePackageFS(pkgid, appids, uid, gid, false);
- ASSERT_EQ(app2ext_usr_disable_external_pkg(pkgid.c_str(), uid), 0);
-}
-
-void ValidateExternalPackage(const std::string& pkgid,
- const std::vector<std::string>& appids) {
- ci::PkgQueryInterface pkg_query(pkgid, kTestUserId);
- ASSERT_TRUE(pkg_query.IsPackageInstalled(ci::GetRequestMode(kTestUserId)));
- std::string storage = pkg_query.StorageForPkgId();
- bf::path ext_mount_path = ci::GetExternalCardPath();
- if (bf::is_empty(ext_mount_path)) {
- LOG(INFO) << "Sdcard not exists!";
- ASSERT_EQ(storage, "installed_internal");
- } else {
- ASSERT_EQ(storage, "installed_external");
- }
- ValidateExternalPackageFS(pkgid, appids, kTestUserId, kTestGroupId);
- if (kTestUserId == kGlobalUserUid) {
- ci::UserList list = ci::GetUserList();
- for (auto& l : list)
- ValidatePackageRWFS(pkgid, std::get<0>(l));
- } else {
- ValidatePackageRWFS(pkgid, kTestUserId);
- }
-}
-
-bool CheckPackageNonExistance(const std::string& pkgid,
- const std::vector<std::string>& appids) {
- ci::PkgQueryInterface pkg_query(pkgid, kTestUserId);
- EXTENDED_ASSERT_FALSE(pkg_query.IsPackageInstalled(
- ci::GetRequestMode(kTestUserId)));
- PackageCheckCleanup(pkgid, appids);
- if (kTestUserId == kGlobalUserUid) {
- ci::UserList list = ci::GetUserList();
- bf::path skel_path(kSkelDir);
- EXTENDED_ASSERT_FALSE(bf::exists(skel_path / pkgid));
- for (auto& l : list) {
- bf::path root_path = ci::GetRootAppPath(false, std::get<0>(l));
- bf::path package_path = root_path / pkgid;
- EXTENDED_ASSERT_FALSE(bf::exists(package_path));
- }
- }
- return true;
-}
-
-void CheckPackageReadonlyNonExistance(const std::string& pkgid,
- const std::vector<std::string>& appids) {
- ci::PkgQueryInterface pkg_query(pkgid, kTestUserId);
- ASSERT_FALSE(pkg_query.IsPackageInstalled(ci::GetRequestMode(kTestUserId)));
- PackageCheckCleanup(pkgid, appids, true);
-}
-
-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;
- }
-}
-
-void TestRollbackAfterEachStep(int argc, const char*argv[],
- std::function<bool()> validator,
- PackageType type) {
- 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;
- }
- std::unique_ptr<ci::AppInstaller> backend = CreateInstaller(pkgmgr, type);
- int i;
- for (i = backend->StepCount()-1; i >= 0; i--) {
- backend->AddStepAtIndex<ci::configuration::StepFail>(i);
- LOG(DEBUG) << "StepFail is inserted at: " << i;
- ASSERT_EQ(ci::AppInstaller::Result::ERROR,
- backend->Run());
- if (!validator())
- break;
- }
- ASSERT_EQ(-1, i);
-}
-
-void CrashAfterEachStep(std::vector<std::string> args,
- std::function<bool(int iter)> validator,
- PackageType type) {
- std::unique_ptr<const char*[]> argv(new const char*[args.size()]);
- for (size_t i = 0; i < args.size(); ++i) {
- argv[i] = args[i].c_str();
- }
- TestPkgmgrInstaller pkgmgr_installer;
- std::unique_ptr<ci::AppQueryInterface> query_interface =
- CreateQueryInterface();
- auto pkgmgr =
- ci::PkgMgrInterface::Create(args.size(), const_cast<char**>(argv.get()),
- &pkgmgr_installer,
- query_interface.get());
- if (!pkgmgr) {
- LOG(ERROR) << "Failed to initialize pkgmgr interface";
- return;
- }
- std::unique_ptr<ci::AppInstaller> backend = CreateInstaller(pkgmgr, type);
- int stepCount = backend->StepCount();
-
- args.push_back("-idx");
- args.push_back(std::to_string(stepCount));
- int i;
- for (i = 0; i < stepCount; i++) {
- ci::Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
- args.back() = std::to_string(i);
- backend_crash.Run(args);
- ASSERT_NE(backend_crash.Wait(), 0);
- if (!validator(i))
- break;
- }
- ASSERT_EQ(stepCount, i);
-}
-
-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) {
- 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) {
- const char* argv[] = {"", "-i", path.c_str(), "-u", kTestUserIdStr.c_str()};
- return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
-}
-
-ci::AppInstaller::Result InstallPreload(const bf::path& path, PackageType type,
- RequestResult mode) {
- const char* argv[] = {"", "-i", path.c_str(), "--preload"};
- return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
-}
-
-bool CheckAvailableExternalPath() {
- bf::path ext_mount_path = ci::GetExternalCardPath();
- LOG(DEBUG) << "ext_mount_path :" << ext_mount_path;
- if (ext_mount_path.empty()) {
- LOG(ERROR) << "Sdcard not exists!";
- return false;
- }
- return true;
-}
-
-bool CheckAvailableExtendedStorage() {
- bf::path extended_path = bf::path(tzplatform_getenv(TZ_SYS_EXTENDEDSD));
- LOG(DEBUG) << "extended_path :" << extended_path;
- // TODO(jeremy.jang): It should be checked by libstorage API.
- if (!bf::exists(extended_path)) {
- LOG(ERROR) << "Extended storage not exists!";
- return false;
- }
- return true;
-}
-
-ci::AppInstaller::Result InstallWithStorage(const bf::path& path,
- PackageType type,
- StorageType storage_type,
- RequestResult mode) {
- int default_storage = 0;
- int storage = 0;
- switch (storage_type) {
- case StorageType::EXTERNAL:
- storage = 1;
- break;
- case StorageType::EXTENDED:
- storage = 2;
- break;
- default:
- LOG(ERROR) << "Unknown storage type";
- break;
- }
- vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT,
- &default_storage);
- vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT, storage);
-
- const char* argv[] = {"", "-i", path.c_str(), "-u", kTestUserIdStr.c_str()};
- ci::AppInstaller::Result result =
- CallBackend(SIZEOFARRAY(argv), argv, type, mode);
-
- vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT,
- default_storage);
- return result;
-}
-
-ci::AppInstaller::Result MigrateLegacyExternalImage(const std::string& pkgid,
- const bf::path& path,
- const bf::path& legacy_path,
- PackageType type,
- RequestResult mode) {
- if (InstallWithStorage(path, type, StorageType::EXTERNAL) !=
- ci::AppInstaller::Result::OK) {
- LOG(ERROR) << "Failed to install application. Cannot perform Migrate";
- return ci::AppInstaller::Result::ERROR;
- }
-
- bf::path ext_mount_path = ci::GetExternalCardPath();
- if (bf::is_empty(ext_mount_path)) {
- LOG(ERROR) << "Sdcard not exists!";
- return ci::AppInstaller::Result::ERROR;
- }
- bf::path app2sd_path = ext_mount_path / "app2sd";
-
- char* image_name = app2ext_usr_getname_image(pkgid.c_str(),
- kGlobalUserUid);
- if (!image_name) {
- LOG(ERROR) << "Failed to get external image name";
- return ci::AppInstaller::Result::ERROR;
- }
- bf::path org_image = app2sd_path / image_name;
- free(image_name);
-
- bs::error_code error;
- bf::remove(org_image, error);
- if (error) {
- LOG(ERROR) << "Failed to remove org image";
- return ci::AppInstaller::Result::ERROR;
- }
-
- bf::path db_path = tzplatform_getenv(TZ_SYS_DB);
- bf::path app2sd_db = db_path / ".app2sd.db";
- bf::path app2sd_db_journal = db_path / ".app2sd.db-journal";
- bf::remove(app2sd_db, error);
- if (error) {
- LOG(ERROR) << "Failed to remove app2sd db";
- return ci::AppInstaller::Result::ERROR;
- }
- bf::remove(app2sd_db_journal, error);
- if (error) {
- LOG(ERROR) << "Failed to remove app2sd journal db";
- return ci::AppInstaller::Result::ERROR;
- }
-
- bf::path app2sd_migrate_db = legacy_path / kMigrateTestDBName;
- if (!ci::CopyFile(app2sd_migrate_db, app2sd_db)) {
- LOG(ERROR) << "Failed to copy test db";
- return ci::AppInstaller::Result::ERROR;
- }
-
- bf::path legacy_src = legacy_path / pkgid;
- bf::path legacy_dst = app2sd_path / pkgid;
- if (!ci::CopyFile(legacy_src, legacy_dst)) {
- LOG(ERROR) << "Failed to copy test image";
- return ci::AppInstaller::Result::ERROR;
- }
- const char* argv[] = {"", "--migrate-extimg", pkgid.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) {
- 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,
- bool is_preload,
- RequestResult mode) {
- if (is_preload) {
- const char* argv[] = {"", "-d", pkgid.c_str(), "--preload",
- "--force-remove"};
- return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
- } else {
- 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) {
- 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) {
- 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) {
- 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) {
- const char* argv[] = {"", "-b", recovery_file.c_str(), "-u",
- kTestUserIdStr.c_str()};
- return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
-}
-
-ci::AppInstaller::Result ManifestDirectInstall(const std::string& pkgid,
- PackageType type,
- RequestResult mode) {
- const char* argv[] = {"", "-y", pkgid.c_str(), "-u", kTestUserIdStr.c_str()};
- return CallBackend(SIZEOFARRAY(argv), argv, type, mode);
-}
-
-namespace {
-
-boost::filesystem::path GetTrashPath(const boost::filesystem::path& path) {
- return path.string() + ".trash";
-}
-
-}
-
-bool BackupPath(const bf::path& path) {
- bf::path trash_path = GetTrashPath(path);
- if (bf::exists(trash_path)) {
- LOG(ERROR) << trash_path << " exists. Please remove "
- << trash_path << " manually!";
- return false;
- }
- 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.";
- return false;
- }
- assert(!error);
- }
- return true;
-}
-
-bool 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) {
- bf::path trash_path = GetTrashPath(path);
- LOG(ERROR) << "Remove failed: " << path << " (" << error.message() << ")";
- std::cout << "Moving " << path << " to " << trash_path << std::endl;
- bf::rename(path, trash_path, error);
- if (error)
- LOG(ERROR) << "Failed to move " << path << " to " << trash_path
- << " (" << error.message() << ")";
- else
- LOG(ERROR) << trash_path << " should be removed manually!";
- }
- if (bf::exists(backup_path)) {
- bf::rename(backup_path, path, error);
- if (error) {
- LOG(ERROR) << "Failed to restore backup path: " << backup_path
- << " (" << error.message() << ")";
- return false;
- }
- }
- return true;
-}
-
-std::vector<bf::path> SetupBackupDirectories() {
- std::vector<bf::path> entries;
- bf::path db_dir = bf::path(tzplatform_getenv(TZ_SYS_DB));
- if (kTestUserId != kGlobalUserUid)
- db_dir = db_dir / "user" / std::to_string(kTestUserId);
- for (auto e : kDBEntries) {
- bf::path path = db_dir / e;
- entries.emplace_back(path);
- }
-
- if (getuid() == 0) {
- entries.emplace_back(kPreloadApps);
- entries.emplace_back(kPreloadManifestDir);
- entries.emplace_back(kPreloadIcons);
- }
-
- if (kTestUserId == 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(kTestUserId);
- bf::path approot = tzplatform_getenv(TZ_USER_APPROOT);
- tzplatform_reset_user();
- entries.emplace_back(approot);
- }
-
- bf::path apps_rw = ci::GetRootAppPath(false, kTestUserId);
- entries.emplace_back(apps_rw);
-
- return entries;
-}
-
-void UninstallAllAppsInDirectory(bf::path dir, bool is_preload) {
- if (bf::exists(dir)) {
- for (auto& dir_entry : boost::make_iterator_range(
- bf::directory_iterator(dir), bf::directory_iterator())) {
- if (dir_entry.path().string().find("smoke") != std::string::npos &&
- bf::is_directory(dir_entry)) {
- std::string package = dir_entry.path().filename().string();
- std::regex pkg_regex("smoke[a-zA-Z0-9]{5,}");
- if (std::regex_match(package, pkg_regex)) {
- if (Uninstall(dir_entry.path().filename().string(), PackageType::WGT,
- is_preload, RequestResult::NORMAL) !=
- ci::AppInstaller::Result::OK) {
- LOG(ERROR) << "Cannot uninstall smoke test app: "
- << dir_entry.path().filename().string();
- }
- }
- }
- }
- }
-}
-
-void UninstallAllSmokeApps(ci::RequestMode request_mode) {
- std::cout << "Uninstalling all smoke apps" << std::endl;
- bf::path apps_rw = ci::GetRootAppPath(false, kTestUserId);
- UninstallAllAppsInDirectory(apps_rw, false);
- if (getuid() == 0 && request_mode == ci::RequestMode::GLOBAL) {
- bf::path root_path = kPreloadApps;
- UninstallAllAppsInDirectory(root_path, true);
- }
-}
-
-int GetAppInstalledTime(const char *appid, uid_t uid) {
- int ret = 0;
- int installed_time = 0;
- pkgmgrinfo_appinfo_h handle = NULL;
- ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, uid, &handle);
- if (ret != PMINFO_R_OK)
- return -1;
- ret = pkgmgrinfo_appinfo_get_installed_time(handle, &installed_time);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_appinfo_destroy_appinfo(handle);
- return -1;
- }
- pkgmgrinfo_appinfo_destroy_appinfo(handle);
- return installed_time;
-}
+} // namespace smoke_test
#ifndef UNIT_TESTS_SMOKE_UTILS_H_
#define UNIT_TESTS_SMOKE_UTILS_H_
-
-#include <boost/filesystem/path.hpp>
-
-#include <common/paths.h>
#include <common/pkgmgr_interface.h>
-#include <common/pkgmgr_query.h>
-#include <common/tzip_interface.h>
-#include <gum/gum-user.h>
-#include <gum/gum-user-service.h>
-#include <gum/common/gum-user-types.h>
-#include <manifest_parser/utils/version_number.h>
-
-#include <gtest/gtest.h>
+#include <common/app_installer.h>
+#include <unit_tests/common/smoke_utils.h>
#include <memory>
-#include <vector>
-#include <string>
-#include "hybrid/hybrid_installer.h"
#include "wgt/wgt_app_query_interface.h"
-#define SIZEOFARRAY(ARR) \
- sizeof(ARR) / sizeof(ARR[0]) \
-
-#define EXTENDED_ASSERT_TRUE(expression) do { \
- bool tmp = expression; \
- EXPECT_TRUE(tmp) << #expression << " is not true"; \
- if (!tmp) \
- return false; \
-} while (0);
-
-#define EXTENDED_ASSERT_FALSE(expression) do { \
- bool tmp = expression; \
- EXPECT_FALSE(tmp) << #expression << " is not false"; \
- if (tmp) \
- return false; \
-} while (0);
-
-#define EXTENDED_ASSERT_EQ(expression, value) do { \
- auto ret = expression; \
- EXPECT_EQ(ret, value) << #expression << " is not equal to " << #value; \
- if (ret != value) \
- return false; \
-} while (0);
-
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
-namespace ci = common_installer;
-
-extern const uid_t kGlobalUserUid;
-extern const uid_t kGlobalUserGid;
-extern const uid_t kDefaultUserUid;
-extern uid_t kTestUserId;
-extern gid_t kTestGroupId;
-extern std::string kTestUserIdStr;
-extern const char kNormalUserName[];
-extern const char kSystemShareGroupName[];
-extern const std::string& kDefaultUserIdStr;
-extern const char kLegacyExtImageDir[];
-extern const char kMigrateTestDBName[];
+namespace smoke_test {
extern const bf::path kSmokePackagesDirectory;
-enum RWDirectory {
- DATA,
- CACHE,
- SHARED_CACHE,
- SHARED_DATA,
- SHARED_TRUSTED
-};
-
-extern const char* rwDirectories[];
-
-// common entries
-extern const std::vector<std::string> kDBEntries;
-// globaluser entries
-extern const char kGlobalManifestDir[];
-extern const char kSkelDir[];
-extern const char kPreloadApps[];
-extern const char kPreloadManifestDir[];
-extern const char kPreloadIcons[];
-
-extern testing::Environment *env;
-void signalHandler(int signum);
-
-enum class RequestResult {
- NORMAL,
- FAIL
-};
-
-class ScopedTzipInterface {
+class WgtBackendInterface: public BackendInterface {
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();
- }
+ using BackendInterface::BackendInterface;
private:
- bf::path pkg_path_;
- ci::TzipInterface interface_;
- bool mounted_;
+ AppQueryInterfacePtr CreateQueryInterface() const override;
+ AppInstallerPtr CreateInstaller(
+ common_installer::PkgMgrPtr pkgmgr) const override;
};
-class TestPkgmgrInstaller : public ci::PkgmgrInstallerInterface {
+class HybridBackendInterface: public BackendInterface {
public:
- bool CreatePkgMgrInstaller(pkgmgr_installer** installer,
- ci::InstallationMode* mode) {
- *installer = pkgmgr_installer_offline_new();
- if (!*installer)
- return false;
- *mode = ci::InstallationMode::ONLINE;
- return true;
- }
+ using BackendInterface::BackendInterface;
- bool ShouldCreateSignal() const {
- return false;
- }
-};
-
-enum class PackageType {
- WGT,
- HYBRID
-};
-
-enum class StorageType {
- INTERNAL,
- EXTERNAL,
- EXTENDED
+ private:
+ AppQueryInterfacePtr CreateQueryInterface() const override;
+ AppInstallerPtr CreateInstaller(
+ common_installer::PkgMgrPtr pkgmgr) const override;
};
-ci::RequestMode ParseRequestMode(int argc, char** argv);
-
-bool TouchFile(const bf::path& path);
-
-bool AddUser(const char *user_name);
-
-bool DeleteUser(const char *user_name, bool rem_home_dir);
-
-bool AddTestUser(const char *user_name);
-
-bool DeleteTestUser(const char *user_name);
-
-void RemoveAllRecoveryFiles();
-
-bf::path FindRecoveryFile();
-
-bf::path GetPackageRoot(const std::string& pkgid, uid_t uid);
-
-bool ValidateFileContentInPackage(const std::string& pkgid,
- const std::string& relative,
- const std::string& expected,
- bool is_readonly = false);
-
-void AddDataFiles(const std::string& pkgid, uid_t uid);
-
-bool ValidateDataFiles(const std::string& pkgid, uid_t uid);
-
-bool ValidatePackageRWFS(const std::string& pkgid, uid_t uid);
-
-bool ValidatePackageFS(const std::string& pkgid,
- const std::vector<std::string>& appids,
- uid_t uid, gid_t gid, bool is_readonly);
-
-void PackageCheckCleanup(const std::string& pkgid,
- const std::vector<std::string>&, bool is_readonly = false);
-
-bool ValidatePackage(const std::string& pkgid,
- const std::vector<std::string>& appids, bool is_readonly = false);
-
-void ValidateExternalPackageFS(const std::string& pkgid,
- const std::vector<std::string>& appids,
- uid_t uid, gid_t gid);
-
-void ValidateExternalPackage(const std::string& pkgid,
- const std::vector<std::string>& appids);
-
-bool CheckPackageNonExistance(const std::string& pkgid,
- const std::vector<std::string>& appids);
-
-void CheckPackageReadonlyNonExistance(const std::string& pkgid,
- const std::vector<std::string>& appids);
-
-std::unique_ptr<ci::AppQueryInterface> CreateQueryInterface();
-
-std::unique_ptr<ci::AppInstaller> CreateInstaller(ci::PkgMgrPtr pkgmgr,
- PackageType type);
-
-void TestRollbackAfterEachStep(int argc, const char*argv[],
- std::function<bool()> validator,
- PackageType type = PackageType::WGT);
-
-void CrashAfterEachStep(std::vector<std::string> args,
- std::function<bool(int iter)> validator,
- PackageType type = PackageType::WGT);
-
-ci::AppInstaller::Result RunInstallerWithPkgrmgr(ci::PkgMgrPtr pkgmgr,
- PackageType type,
- RequestResult mode);
-ci::AppInstaller::Result CallBackend(int argc,
- const char* argv[],
- PackageType type,
- RequestResult mode
- = RequestResult::NORMAL);
-
-ci::AppInstaller::Result Install(const bf::path& path,
- PackageType type,
- RequestResult mode = RequestResult::NORMAL);
-
-ci::AppInstaller::Result InstallPreload(const bf::path& path, PackageType type,
- RequestResult mode = RequestResult::NORMAL);
-
-bool CheckAvailableExternalPath();
-
-bool CheckAvailableExtendedStorage();
-
-ci::AppInstaller::Result InstallWithStorage(const bf::path& path,
- PackageType type,
- StorageType storage = StorageType::INTERNAL,
- RequestResult mode = RequestResult::NORMAL);
-
-ci::AppInstaller::Result MigrateLegacyExternalImage(const std::string& pkgid,
- const bf::path& path,
- const bf::path& legacy_path,
- PackageType type,
- RequestResult mode = RequestResult::NORMAL);
-
-ci::AppInstaller::Result MountInstall(const bf::path& path,
- PackageType type, RequestResult mode = RequestResult::NORMAL);
-
-ci::AppInstaller::Result Uninstall(const std::string& pkgid,
- PackageType type,
- bool is_preload,
- RequestResult mode = RequestResult::NORMAL);
-
-ci::AppInstaller::Result RDSUpdate(const bf::path& path,
- const std::string& pkgid,
- PackageType type,
- RequestResult mode = RequestResult::NORMAL);
-
-ci::AppInstaller::Result DeltaInstall(const bf::path& path,
- const bf::path& delta_package, PackageType type);
-
-ci::AppInstaller::Result EnablePackage(const std::string& pkgid,
- PackageType type,
- RequestResult mode = RequestResult::NORMAL);
-
-ci::AppInstaller::Result DisablePackage(const std::string& pkgid,
- PackageType type,
- RequestResult mode = RequestResult::NORMAL);
-
-ci::AppInstaller::Result Recover(const bf::path& recovery_file,
- PackageType type,
- RequestResult mode = RequestResult::NORMAL);
-
-ci::AppInstaller::Result ManifestDirectInstall(const std::string& pkgid,
- PackageType type, RequestResult mode = RequestResult::NORMAL);
-
-bool BackupPath(const bf::path& path);
-
-bool RestorePath(const bf::path& path);
-
-std::vector<bf::path> SetupBackupDirectories();
-
-void UninstallAllAppsInDirectory(bf::path dir, bool is_preload);
-
-void UninstallAllSmokeApps(ci::RequestMode request_mode);
+} // namespace smoke_test
-int GetAppInstalledTime(const char *appid, uid_t uid);
#endif // UNIT_TESTS_SMOKE_UTILS_H_