TestParameters params;
};
+class PreloadSmokeTest : public testing::Test {
+ public:
+ PreloadSmokeTest() : backend(std::to_string(env->test_user.uid)),
+ params{PackageType::WGT, true} {
+ params.test_user.uid = env->test_user.uid;
+ params.test_user.gid = env->test_user.gid;
+ }
+ protected:
+ WgtBackendInterface backend;
+ TestParameters params;
+};
+
class HybridSmokeTest : public testing::Test {
public:
HybridSmokeTest() : backend(std::to_string(env->test_user.uid)),
});
}
+TEST_F(PreloadSmokeTest, RecoveryMode_ForReadonlyUpdateInstall) {
+ ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
+ bf::path path_old = kSmokePackagesDirectory /
+ "RecoveryMode_ForReadonlyUpdateInstall.wgt";
+ bf::path path_new = kSmokePackagesDirectory /
+ "RecoveryMode_ForReadonlyUpdateInstall_2.wgt";
+ RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
+ ASSERT_EQ(backend.InstallPreload(path_old), ci::AppInstaller::Result::OK);
+ std::string pkgid = "smokewgt51";
+ std::string appid = "smokewgt51.RecoveryModeForReadonlyUpdateInstall";
+ AddDataFiles(pkgid, params.test_user.uid);
+ std::string test_uid_str = std::to_string(params.test_user.uid);
+ std::vector<std::string> args =
+ {"", "-i", path_new.string(), "-u", test_uid_str.c_str()};
+ backend.CrashAfterEachStep(&args, [&](int step) -> bool {
+ if (step >= 2) {
+ bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
+ params.test_user.uid);
+ EXTENDED_ASSERT_FALSE(recovery_file.empty());
+ std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
+ GetRecoverFileInfo(recovery_file);
+ EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
+ ci::AppInstaller::Result::OK);
+ if (recovery_info->cleanup())
+ params.is_readonly = false;
+ EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
+
+ std::string version = recovery_info->cleanup() ? "2\n" :"1\n";
+ EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
+ "res/wgt/VERSION", version, params));
+ EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
+
+ if (recovery_info->cleanup()) {
+ EXTENDED_ASSERT_EQ(backend.Uninstall(pkgid),
+ ci::AppInstaller::Result::OK);
+ AddDataFiles(pkgid, params.test_user.uid);
+ }
+ }
+ return true;
+ }, params.pkg_type);
+}
+
} // namespace smoke_test
int main(int argc, char** argv) {
ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::ERROR);
}
+TEST_F(PreloadSmokeTest, RecoveryMode_ForReadonlyUpdateInstall) {
+ ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
+ bf::path path_old = kSmokePackagesDirectory /
+ "RecoveryMode_ForReadonlyUpdateInstall.wgt";
+ bf::path path_new = kSmokePackagesDirectory /
+ "RecoveryMode_ForReadonlyUpdateInstall_2.wgt";
+ RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
+ ASSERT_EQ(backend.InstallPreload(path_old), ci::AppInstaller::Result::OK);
+ std::string pkgid = "smokewgt51";
+ std::string appid = "smokewgt51.RecoveryModeForReadonlyUpdateInstall";
+ AddDataFiles(pkgid, params.test_user.uid);
+ ci::Subprocess backend_crash("/usr/bin/wgt-installer-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("/wgt-recovery",
+ params.test_user.uid);
+ ASSERT_FALSE(recovery_file.empty());
+ 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",
+ params));
+ ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
+}
+
} // namespace smoke_test
int main(int argc, char** argv) {