1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
5 #include <gtest/gtest-death-test.h>
7 #include <common/utils/subprocess.h>
8 #include <common/utils/file_util.h>
9 #include <common/pkgmgr_query.h>
10 #include <unit_tests/common/smoke_utils.h>
14 #include "unit_tests/wgt_smoke_utils.h"
16 namespace st = smoke_test;
17 namespace bf = boost::filesystem;
18 namespace bs = boost::system;
19 namespace ci = common_installer;
20 namespace bo = boost::program_options;
22 namespace smoke_test {
24 class SmokeEnvironment : public testing::Environment {
26 explicit SmokeEnvironment(ci::RequestMode mode) {\
29 void SetUp() override {
30 if (request_mode_ == ci::RequestMode::USER)
31 ASSERT_TRUE(AddTestUser(&test_user));
32 backups_ = SetupBackupDirectories(test_user.uid);
33 for (auto& path : backups_)
34 ASSERT_TRUE(BackupPath(path));
36 void TearDown() override {
37 ASSERT_TRUE(request_mode_ == ci::RequestMode::GLOBAL ||
38 (request_mode_ == ci::RequestMode::USER &&
39 kGlobalUserUid != test_user.uid));
40 WgtBackendInterface backend(std::to_string(test_user.uid));
41 UninstallAllSmokeApps(request_mode_, test_user.uid, &backend);
42 for (auto& path : backups_)
43 ASSERT_TRUE(RestorePath(path));
44 if (request_mode_ == ci::RequestMode::USER)
45 ASSERT_TRUE(DeleteTestUser());
50 ci::RequestMode request_mode_;
51 std::vector<bf::path> backups_;
54 } // namespace smoke_test
58 smoke_test::SmokeEnvironment* env = nullptr;
59 void signalHandler(int signum) {
66 namespace smoke_test {
68 class SmokeTest : public testing::Test {
70 SmokeTest() : backend(std::to_string(env->test_user.uid)),
71 params{PackageType::WGT, false} {
72 params.test_user.uid = env->test_user.uid;
73 params.test_user.gid = env->test_user.gid;
76 WgtBackendInterface backend;
77 TestParameters params;
80 class RollbackSmokeTest : public testing::Test {
82 RollbackSmokeTest() : backend(std::to_string(env->test_user.uid),
83 RequestResult::FAIL), params{PackageType::WGT, false} {
84 params.test_user.uid = env->test_user.uid;
85 params.test_user.gid = env->test_user.gid;
88 WgtBackendInterface backend;
89 TestParameters params;
92 class HybridSmokeTest : public testing::Test {
94 HybridSmokeTest() : backend(std::to_string(env->test_user.uid)),
95 params{PackageType::HYBRID, false} {
96 params.test_user.uid = env->test_user.uid;
97 params.test_user.gid = env->test_user.gid;
100 HybridBackendInterface backend;
101 TestParameters params;
104 class RollbackHybridSmokeTest : public testing::Test {
106 RollbackHybridSmokeTest() : backend(std::to_string(env->test_user.uid),
107 RequestResult::FAIL), params{PackageType::HYBRID, false} {
108 params.test_user.uid = env->test_user.uid;
109 params.test_user.gid = env->test_user.gid;
112 HybridBackendInterface backend;
113 TestParameters params;
116 class PreloadSmokeTest : public testing::Test {
118 PreloadSmokeTest() : backend(std::to_string(env->test_user.uid)),
119 params{PackageType::WGT, true} {
120 params.test_user.uid = env->test_user.uid;
121 params.test_user.gid = env->test_user.gid;
124 WgtBackendInterface backend;
125 TestParameters params;
128 class HybridPreloadSmokeTest : public testing::Test {
130 HybridPreloadSmokeTest() : backend(std::to_string(env->test_user.uid)),
131 params{PackageType::HYBRID, true} {
132 params.test_user.uid = env->test_user.uid;
133 params.test_user.gid = env->test_user.gid;
136 HybridBackendInterface backend;
137 TestParameters params;
140 TEST_F(SmokeTest, InstallationMode) {
141 bf::path path = kSmokePackagesDirectory / "InstallationMode.wgt";
142 std::string pkgid = "smokewgt03";
143 std::string appid = "smokewgt03.InstallationMode";
144 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
145 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
148 TEST_F(SmokeTest, UpdateMode) {
149 bf::path path_old = kSmokePackagesDirectory / "UpdateMode.wgt";
150 bf::path path_new = kSmokePackagesDirectory / "UpdateMode_2.wgt";
151 std::string pkgid = "smokewgt04";
152 std::string appid = "smokewgt04.UpdateMode";
153 ASSERT_EQ(backend.InstallSuccess(path_old), ci::AppInstaller::Result::OK);
154 AddDataFiles(pkgid, params.test_user.uid);
155 ASSERT_EQ(backend.Install(path_new), ci::AppInstaller::Result::OK);
156 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
158 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n",
160 ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
163 TEST_F(SmokeTest, DeinstallationMode) {
164 bf::path path = kSmokePackagesDirectory / "DeinstallationMode.wgt";
165 std::string pkgid = "smokewgt05";
166 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
167 ASSERT_EQ(backend.Uninstall(pkgid), ci::AppInstaller::Result::OK);
168 ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
171 TEST_F(SmokeTest, RDSMode) {
172 bf::path path = kSmokePackagesDirectory / "RDSMode.wgt";
173 std::string pkgid = "smokewgt11";
174 std::string appid = "smokewgt11.RDSMode";
175 bf::path delta_directory = kSmokePackagesDirectory / "delta_dir";
176 bf::path sdk_expected_directory = kSdkDirectory / "tmp" / pkgid;
177 ASSERT_TRUE(ci::CopyDir(delta_directory, sdk_expected_directory));
178 ASSERT_EQ(backend.RDSUpdate(path, pkgid),
179 ci::AppInstaller::Result::OK);
180 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
181 // Check delta modifications
182 ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
183 "res" / "wgt" / "DELETED"));
184 ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
185 "res" / "wgt" / "ADDED"));
186 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "2\n",
190 TEST_F(SmokeTest, EnablePkg) {
191 bf::path path = kSmokePackagesDirectory / "EnablePkg.wgt";
192 std::string pkgid = "smokewgt22";
193 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
194 ASSERT_EQ(backend.DisablePackage(pkgid), ci::AppInstaller::Result::OK);
195 ASSERT_EQ(backend.EnablePackage(pkgid), ci::AppInstaller::Result::OK);
197 ci::PkgQueryInterface pkg_query(pkgid, params.test_user.uid);
198 ASSERT_TRUE(pkg_query.IsPackageInstalled(
199 ci::GetRequestMode(params.test_user.uid)));
202 TEST_F(SmokeTest, DisablePkg) {
203 bf::path path = kSmokePackagesDirectory / "DisablePkg.wgt";
204 std::string pkgid = "smokewgt21";
205 std::string appid = "smokewgt21.DisablePkg";
206 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
207 ASSERT_EQ(backend.DisablePackage(pkgid), ci::AppInstaller::Result::OK);
208 ASSERT_TRUE(ci::QueryIsDisabledPackage(pkgid, params.test_user.uid));
209 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
212 TEST_F(SmokeTest, DeltaMode) {
213 bf::path path = kSmokePackagesDirectory / "DeltaMode.wgt";
214 bf::path delta_package = kSmokePackagesDirectory / "DeltaMode.delta";
215 std::string pkgid = "smokewgt17";
216 std::string appid = "smokewgt17.DeltaMode";
217 ASSERT_EQ(backend.InstallSuccess(path), ci::AppInstaller::Result::OK);
218 ASSERT_EQ(backend.Install(delta_package), ci::AppInstaller::Result::OK);
219 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
221 // Check delta modifications
222 ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
223 "res" / "wgt" / "DELETED"));
224 ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
225 "res" / "wgt" / "ADDED"));
226 ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
227 "res" / "wgt" / "css" / "style.css"));
228 ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
229 "res" / "wgt" / "images" / "tizen_32.png"));
230 ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
231 "res" / "wgt" / "js" / "main.js"));
232 ASSERT_TRUE(ValidateFileContentInPackage(
233 pkgid, "res/wgt/MODIFIED", "version 2\n", params));
236 TEST_F(SmokeTest, RecoveryMode_ForInstallation) {
237 bf::path path = kSmokePackagesDirectory / "RecoveryMode_ForInstallation.wgt";
238 ci::Subprocess backend_crash("/usr/bin/wgt-installer-ut/smoke-test-helper");
239 std::string test_uid_str = std::to_string(params.test_user.uid);
240 backend_crash.Run("-i", path.string(), "-u", test_uid_str.c_str());
241 ASSERT_NE(backend_crash.Wait(), 0);
243 std::string pkgid = "smokewgt09";
244 bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
245 params.test_user.uid);
246 ASSERT_FALSE(recovery_file.empty());
247 ASSERT_EQ(backend.Recover(recovery_file), ci::AppInstaller::Result::OK);
248 ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
251 TEST_F(SmokeTest, RecoveryMode_ForUpdate) {
252 bf::path path_old = kSmokePackagesDirectory / "RecoveryMode_ForUpdate.wgt";
253 bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForUpdate_2.wgt";
254 RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
255 ASSERT_EQ(backend.InstallSuccess(path_old), ci::AppInstaller::Result::OK);
256 std::string pkgid = "smokewgt10";
257 std::string appid = "smokewgt10.RecoveryModeForUpdate";
258 AddDataFiles(pkgid, params.test_user.uid);
259 ci::Subprocess backend_crash("/usr/bin/wgt-installer-ut/smoke-test-helper");
260 std::string test_uid_str = std::to_string(params.test_user.uid);
261 backend_crash.Run("-i", path_new.string(), "-u", test_uid_str.c_str());
262 ASSERT_NE(backend_crash.Wait(), 0);
264 bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
265 params.test_user.uid);
266 ASSERT_FALSE(recovery_file.empty());
267 ASSERT_EQ(backend.Recover(recovery_file), ci::AppInstaller::Result::OK);
268 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
270 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n",
272 ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
275 TEST_F(SmokeTest, RecoveryMode_ForDelta) {
276 bf::path path_old = kSmokePackagesDirectory / "RecoveryMode_ForDelta.wgt";
277 bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForDelta.delta";
278 RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
279 ASSERT_EQ(backend.InstallSuccess(path_old), ci::AppInstaller::Result::OK);
280 ci::Subprocess backend_crash("/usr/bin/wgt-installer-ut/smoke-test-helper");
281 std::string test_uid_str = std::to_string(params.test_user.uid);
282 backend_crash.Run("-i", path_new.string(), "-u", test_uid_str.c_str());
283 ASSERT_NE(backend_crash.Wait(), 0);
285 std::string pkgid = "smokewgt30";
286 std::string appid = "smokewgt30.RecoveryModeForDelta";
287 bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
288 params.test_user.uid);
289 ASSERT_FALSE(recovery_file.empty());
290 ASSERT_EQ(backend.Recover(recovery_file), ci::AppInstaller::Result::OK);
291 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
293 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n",
297 TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
298 bf::path path = kSmokePackagesDirectory / "RecoveryMode_ForMountInstall.wgt";
299 RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
300 ci::Subprocess backend_crash("/usr/bin/wgt-installer-ut/smoke-test-helper");
301 std::string test_uid_str = std::to_string(params.test_user.uid);
302 backend_crash.Run("-w", path.string(), "-u", test_uid_str.c_str());
303 ASSERT_NE(backend_crash.Wait(), 0);
305 std::string pkgid = "smokewgt31";
306 bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
307 params.test_user.uid);
308 ASSERT_FALSE(recovery_file.empty());
309 ASSERT_EQ(backend.Recover(recovery_file), ci::AppInstaller::Result::OK);
310 ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
313 TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
315 kSmokePackagesDirectory / "RecoveryMode_ForMountUpdate.wgt";
317 kSmokePackagesDirectory / "RecoveryMode_ForMountUpdate_2.wgt";
318 std::string pkgid = "smokewgt32";
319 std::string appid = "smokewgt32.RecoveryModeForMountUpdate";
320 RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
321 ASSERT_EQ(backend.MountInstallSuccess(path_old),
322 ci::AppInstaller::Result::OK);
323 AddDataFiles(pkgid, params.test_user.uid);
324 ci::Subprocess backend_crash("/usr/bin/wgt-installer-ut/smoke-test-helper");
325 std::string test_uid_str = std::to_string(params.test_user.uid);
326 backend_crash.Run("-w", path_new.string(), "-u", test_uid_str.c_str());
327 ASSERT_NE(backend_crash.Wait(), 0);
329 // Filesystem may be mounted after crash
330 ScopedTzipInterface poweroff_unmount_interface(pkgid, params.test_user.uid);
331 poweroff_unmount_interface.Release();
333 bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
334 params.test_user.uid);
335 ASSERT_FALSE(recovery_file.empty());
336 ASSERT_EQ(backend.Recover(recovery_file), ci::AppInstaller::Result::OK);
338 ScopedTzipInterface interface(pkgid, params.test_user.uid);
339 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
340 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n",
342 ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
345 TEST_F(SmokeTest, InstallationMode_GoodSignature) {
347 bf::path path = kSmokePackagesDirectory / "InstallationMode_GoodSignature.wgt"; // NOLINT
348 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
351 TEST_F(SmokeTest, InstallationMode_WrongSignature) {
353 bf::path path = kSmokePackagesDirectory / "InstallationMode_WrongSignature.wgt"; // NOLINT
354 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::ERROR);
357 TEST_F(RollbackSmokeTest, InstallationMode) {
358 bf::path path = kSmokePackagesDirectory / "InstallationMode_Rollback.wgt";
359 std::string pkgid = "smokewgt06";
360 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::ERROR);
361 ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
364 TEST_F(RollbackSmokeTest, UpdateMode) {
365 bf::path path_old = kSmokePackagesDirectory / "UpdateMode_Rollback.wgt";
366 bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Rollback_2.wgt";
367 std::string pkgid = "smokewgt07";
368 std::string appid = "smokewgt07.UpdateModeRollback";
369 ASSERT_EQ(backend.InstallSuccess(path_old), ci::AppInstaller::Result::OK);
370 AddDataFiles(pkgid, params.test_user.uid);
371 ASSERT_EQ(backend.Install(path_new), ci::AppInstaller::Result::ERROR);
372 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
374 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n",
376 ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
379 TEST_F(RollbackSmokeTest, DeltaMode) {
380 bf::path path = kSmokePackagesDirectory / "DeltaMode_Rollback.wgt";
381 bf::path delta_package = kSmokePackagesDirectory / "DeltaMode_Rollback.delta";
382 std::string pkgid = "smokewgt01";
383 std::string appid = "smokewgt01.DeltaMode";
384 ASSERT_EQ(backend.InstallSuccess(path), ci::AppInstaller::Result::OK);
385 AddDataFiles(pkgid, params.test_user.uid);
386 ASSERT_EQ(backend.Install(delta_package), ci::AppInstaller::Result::ERROR);
388 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
389 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED",
390 "version 1\n", params));
391 ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
392 ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
394 ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid, params.test_user.uid) /
398 TEST_F(HybridSmokeTest, InstallationMode) {
399 bf::path path = kSmokePackagesDirectory / "InstallationMode_Hybrid.wgt";
400 std::string pkgid = "smokehyb01";
401 // Excutable for native app doesn't create symlink
402 std::string appid1 = "smokehyb01.Web";
403 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
404 ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
407 TEST_F(HybridSmokeTest, UpdateMode) {
408 bf::path path_old = kSmokePackagesDirectory / "UpdateMode_Hybrid.wgt";
409 bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Hybrid_2.wgt";
410 std::string pkgid = "smokehyb02";
411 std::string appid1 = "smokehyb02.Web";
412 ASSERT_EQ(backend.InstallSuccess(path_old), ci::AppInstaller::Result::OK);
413 AddDataFiles(pkgid, params.test_user.uid);
414 ASSERT_EQ(backend.Install(path_new),
415 ci::AppInstaller::Result::OK);
416 ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
418 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n",
420 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "VERSION", "2\n", params));
421 ValidateDataFiles(pkgid, params.test_user.uid);
424 TEST_F(HybridSmokeTest, DeinstallationMode) {
425 bf::path path = kSmokePackagesDirectory / "DeinstallationMode_Hybrid.wgt";
426 std::string pkgid = "smokehyb03";
427 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
428 ASSERT_EQ(backend.Uninstall(pkgid), ci::AppInstaller::Result::OK);
429 ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
432 TEST_F(HybridSmokeTest, DeltaMode) {
433 bf::path path = kSmokePackagesDirectory / "DeltaMode_Hybrid.wgt";
434 bf::path delta_package = kSmokePackagesDirectory / "DeltaMode_Hybrid.delta";
435 std::string pkgid = "smokehyb04";
436 std::string appid1 = "smokehyb04.Web";
437 ASSERT_EQ(backend.InstallSuccess(path), ci::AppInstaller::Result::OK);
438 ASSERT_EQ(backend.Install(delta_package), ci::AppInstaller::Result::OK);
439 ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
441 // Check delta modifications
442 bf::path root_path = ci::GetRootAppPath(false, params.test_user.uid);
443 ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "DELETED"));
444 ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "ADDED"));
445 ASSERT_FALSE(bf::exists(root_path / pkgid / "lib" / "DELETED"));
446 ASSERT_TRUE(bf::exists(root_path / pkgid / "lib" / "ADDED"));
447 ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "css" / "style.css")); // NOLINT
448 ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "images" / "tizen_32.png")); // NOLINT
449 ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "js" / "main.js"));
450 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "version 2\n", params)); // NOLINT
451 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/MODIFIED", "version 2\n", params)); // NOLINT
454 TEST_F(HybridSmokeTest, MountInstallationMode) {
455 bf::path path = kSmokePackagesDirectory / "MountInstallationMode_Hybrid.wgt";
456 std::string pkgid = "smokehyb05";
457 std::string appid1 = "smokehyb05.web";
458 ASSERT_EQ(backend.MountInstall(path), ci::AppInstaller::Result::OK);
459 ScopedTzipInterface interface(pkgid, params.test_user.uid);
460 ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
463 TEST_F(HybridSmokeTest, MountUpdateMode) {
464 bf::path path_old = kSmokePackagesDirectory / "MountUpdateMode_Hybrid.wgt";
465 bf::path path_new = kSmokePackagesDirectory / "MountUpdateMode_Hybrid_2.wgt";
466 std::string pkgid = "smokehyb06";
467 std::string appid1 = "smokehyb06.web";
468 ASSERT_EQ(backend.MountInstallSuccess(path_old),
469 ci::AppInstaller::Result::OK);
470 AddDataFiles(pkgid, params.test_user.uid);
471 ASSERT_EQ(backend.MountInstall(path_new), ci::AppInstaller::Result::OK);
472 ScopedTzipInterface interface(pkgid, params.test_user.uid);
473 ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
475 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n",
477 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "2\n",
479 ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
482 TEST_F(RollbackHybridSmokeTest, InstallationMode) {
483 bf::path path = kSmokePackagesDirectory /
484 "InstallationMode_Rollback_Hybrid.wgt";
485 std::string pkgid = "smokehyb07";
486 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::ERROR);
487 ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
490 TEST_F(RollbackHybridSmokeTest, UpdateMode) {
491 bf::path path_old = kSmokePackagesDirectory /
492 "UpdateMode_Rollback_Hybrid.wgt";
493 bf::path path_new = kSmokePackagesDirectory /
494 "UpdateMode_Rollback_Hybrid_2.wgt";
495 std::string pkgid = "smokehyb08";
496 std::string appid1 = "smokehyb08.web";
497 ASSERT_EQ(backend.InstallSuccess(path_old), ci::AppInstaller::Result::OK);
498 AddDataFiles(pkgid, params.test_user.uid);
499 ASSERT_EQ(backend.Install(path_new), ci::AppInstaller::Result::ERROR);
500 ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
502 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n",
504 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "1\n",
506 ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
509 TEST_F(RollbackHybridSmokeTest, DeltaMode) {
510 bf::path path = kSmokePackagesDirectory / "DeltaMode_Rollback_Hybrid.wgt";
511 bf::path delta_package = kSmokePackagesDirectory /
512 "DeltaMode_Rollback_Hybrid.delta";
513 std::string pkgid = "smokehyb11";
514 std::string appid1 = "smokehyb11.web";
515 ASSERT_EQ(backend.InstallSuccess(path), ci::AppInstaller::Result::OK);
516 AddDataFiles(pkgid, params.test_user.uid);
517 ASSERT_EQ(backend.Install(delta_package),
518 ci::AppInstaller::Result::ERROR);
520 ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
521 // Check delta modifications
522 bf::path root_path = GetPackageRoot(pkgid, params.test_user.uid);
523 ASSERT_TRUE(bf::exists(root_path / "res" / "wgt" / "DELETED"));
524 ASSERT_FALSE(bf::exists(root_path / "res" / "wgt" / "ADDED"));
525 ASSERT_TRUE(bf::exists(root_path / "lib" / "DELETED"));
526 ASSERT_FALSE(bf::exists(root_path / "lib" / "ADDED"));
527 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED",
528 "version 1\n", params));
529 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/MODIFIED",
530 "version 1\n", params));
531 ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
534 TEST_F(RollbackHybridSmokeTest, MountInstallationMode) {
535 bf::path path = kSmokePackagesDirectory /
536 "MountInstallationMode_Rollback_Hybrid.wgt";
537 std::string pkgid = "smokehyb09";
538 ASSERT_EQ(backend.MountInstall(path), ci::AppInstaller::Result::ERROR);
539 ScopedTzipInterface interface(pkgid, params.test_user.uid);
540 ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
543 TEST_F(RollbackHybridSmokeTest, MountUpdateMode) {
544 bf::path path_old = kSmokePackagesDirectory /
545 "MountUpdateMode_Rollback_Hybrid.wgt";
546 bf::path path_new = kSmokePackagesDirectory /
547 "MountUpdateMode_Rollback_Hybrid_2.wgt";
548 std::string pkgid = "smokehyb10";
549 std::string appid1 = "smokehyb10.web";
550 ASSERT_EQ(backend.MountInstallSuccess(path_old),
551 ci::AppInstaller::Result::OK);
552 AddDataFiles(pkgid, params.test_user.uid);
553 ASSERT_EQ(backend.MountInstall(path_new), ci::AppInstaller::Result::ERROR);
554 ScopedTzipInterface interface(pkgid, params.test_user.uid);
555 ASSERT_TRUE(ValidatePackage(pkgid, {appid1}, params));
557 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n",
559 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "1\n",
561 ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
564 TEST_F(SmokeTest, MountInstallationMode) {
565 bf::path path = kSmokePackagesDirectory / "MountInstallationMode.wgt";
566 std::string pkgid = "smokewgt28";
567 std::string appid = "smokewgt28.InstallationMode";
568 ASSERT_EQ(backend.MountInstall(path), ci::AppInstaller::Result::OK);
569 ScopedTzipInterface interface(pkgid, params.test_user.uid);
570 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
573 TEST_F(SmokeTest, MountUpdateMode) {
574 bf::path path_old = kSmokePackagesDirectory / "MountUpdateMode.wgt";
575 bf::path path_new = kSmokePackagesDirectory / "MountUpdateMode_2.wgt";
576 std::string pkgid = "smokewgt29";
577 std::string appid = "smokewgt29.UpdateMode";
578 ASSERT_EQ(backend.MountInstallSuccess(path_old),
579 ci::AppInstaller::Result::OK);
580 AddDataFiles(pkgid, params.test_user.uid);
581 ASSERT_EQ(backend.MountInstall(path_new), ci::AppInstaller::Result::OK);
582 ScopedTzipInterface interface(pkgid, params.test_user.uid);
583 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
585 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n",
587 ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
590 TEST_F(RollbackSmokeTest, MountInstallationMode) {
592 kSmokePackagesDirectory / "MountInstallationMode_Rollback.wgt";
593 std::string pkgid = "smokewgt33";
594 ASSERT_EQ(backend.MountInstall(path), ci::AppInstaller::Result::ERROR);
595 ScopedTzipInterface interface(pkgid, params.test_user.uid);
596 ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
599 TEST_F(RollbackSmokeTest, MountUpdateMode) {
600 bf::path path_old = kSmokePackagesDirectory / "MountUpdateMode_Rollback.wgt";
602 kSmokePackagesDirectory / "MountUpdateMode_Rollback_2.wgt";
603 std::string pkgid = "smokewgt34";
604 std::string appid = "smokewgt34.web";
605 ASSERT_EQ(backend.MountInstallSuccess(path_old),
606 ci::AppInstaller::Result::OK);
607 AddDataFiles(pkgid, params.test_user.uid);
608 ASSERT_EQ(backend.MountInstall(path_new), ci::AppInstaller::Result::ERROR);
609 ScopedTzipInterface interface(pkgid, params.test_user.uid);
610 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
612 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n",
614 ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
617 TEST_F(SmokeTest, UserDefinedPlugins) {
618 bf::path path = kSmokePackagesDirectory / "SimpleEchoPrivilege.wgt";
619 std::string pkgid = "smokewgt02";
620 std::string appid = "smokewgt02.SimpleEcho";
621 std::string call_privilege = "http://tizen.org/privilege/call";
622 std::string location_privilege = "http://tizen.org/privilege/location";
623 std::string power_privilege = "http://tizen.org/privilege/power";
625 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
626 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
627 std::vector<std::string> res;
628 ci::PkgQueryInterface pkg_query(pkgid, params.test_user.uid);
629 ASSERT_TRUE(pkg_query.PrivilegesForPkgId(&res));
630 ASSERT_TRUE(std::find(res.begin(), res.end(), call_privilege) != res.end());
631 ASSERT_TRUE(std::find(res.begin(), res.end(), location_privilege)
633 ASSERT_TRUE(std::find(res.begin(), res.end(), power_privilege) != res.end());
636 TEST_F(SmokeTest, InstallExternalMode) {
637 ASSERT_TRUE(CheckAvailableExternalPath());
638 bf::path path = kSmokePackagesDirectory / "InstallExternalMode.wgt";
639 std::string pkgid = "smokewgt35";
640 std::string appid = "smokewgt35.web";
641 ASSERT_EQ(backend.InstallWithStorage(path, StorageType::EXTERNAL),
642 ci::AppInstaller::Result::OK);
643 ValidateExternalPackage(pkgid, {appid}, params);
646 TEST_F(SmokeTest, MigrateLegacyExternalImageMode) {
647 ASSERT_TRUE(CheckAvailableExternalPath());
649 kSmokePackagesDirectory / "MigrateLegacyExternalImageMode.wgt";
650 std::string pkgid = "smokewgt36";
651 std::string appid = "smokewgt36.web";
652 bf::path legacy_path = kSmokePackagesDirectory / kLegacyExtImageDir;
653 std::string test_uid_str = std::to_string(params.test_user.uid);
654 if (test_uid_str == kDefaultUserIdStr ||
655 params.test_user.uid == kGlobalUserUid) {
656 ASSERT_EQ(backend.MigrateLegacyExternalImage(pkgid, path, legacy_path),
657 ci::AppInstaller::Result::OK);
658 ValidateExternalPackage(pkgid, {appid}, params);
660 ASSERT_EQ(backend.MigrateLegacyExternalImage(pkgid, path, legacy_path),
661 ci::AppInstaller::Result::ERROR);
665 TEST_F(PreloadSmokeTest, InstallationMode) {
666 ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
667 bf::path path = kSmokePackagesDirectory / "InstallationMode_Preload.wgt";
668 std::string pkgid = "smokewgt37";
669 std::string appid = "smokewgt37.InstallationModePreload";
670 ASSERT_EQ(backend.InstallPreload(path), ci::AppInstaller::Result::OK);
671 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
674 TEST_F(PreloadSmokeTest, UpdateMode) {
675 ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
676 bf::path path_old = kSmokePackagesDirectory / "UpdateMode_Preload.wgt";
677 bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Preload2.wgt";
678 std::string pkgid = "smokewgt38";
679 std::string appid = "smokewgt38.UpdateModePreload";
680 ASSERT_EQ(backend.InstallPreload(path_old), ci::AppInstaller::Result::OK);
681 AddDataFiles(pkgid, params.test_user.uid);
682 ASSERT_EQ(backend.InstallPreload(path_new), ci::AppInstaller::Result::OK);
683 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
685 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2",
687 ASSERT_TRUE(ValidateDataFiles(pkgid, params.test_user.uid));
690 TEST_F(PreloadSmokeTest, DeinstallationMode) {
691 ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
692 bf::path path = kSmokePackagesDirectory / "DeinstallationMode_Preload.wgt";
693 std::string pkgid = "smokewgt39";
694 ASSERT_EQ(backend.InstallPreload(path), ci::AppInstaller::Result::OK);
695 ASSERT_EQ(backend.UninstallPreload(pkgid), ci::AppInstaller::Result::OK);
696 CheckPackageReadonlyNonExistance(pkgid, params);
699 TEST_F(SmokeTest, ManifestDirectInstallMode) {
700 ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
701 bf::path src_path = kSmokePackagesDirectory / "ManifestDirectInstallMode";
702 std::string pkgid = "smokewgt40";
703 std::string appid = "smokewgt40.ManifestDirectInstallMode";
704 bf::path pkg_path = ci::GetRootAppPath(false, params.test_user.uid);
706 ci::CopyDir(src_path / pkgid, pkg_path / pkgid);
707 ci::PkgQueryInterface pkg_query(pkgid, params.test_user.uid);
708 ASSERT_FALSE(pkg_query.IsPackageInstalled(
709 ci::GetRequestMode(params.test_user.uid)));
710 ASSERT_EQ(backend.ManifestDirectInstall(pkgid),
711 ci::AppInstaller::Result::OK);
712 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
715 TEST_F(SmokeTest, ManifestDirectUpdateMode) {
716 bf::path path = kSmokePackagesDirectory / "ManifestDirectUpdateMode.wgt";
717 std::string pkgid = "smokewgt41";
718 std::string appid = "smokewgt41.ManifestDirectUpdateMode";
720 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
721 int install_time = GetAppInstalledTime(appid.c_str(), params.test_user.uid);
722 ASSERT_EQ(backend.ManifestDirectInstall(pkgid),
723 ci::AppInstaller::Result::OK);
724 ASSERT_TRUE(GetAppInstalledTime(appid.c_str(),
725 params.test_user.uid) > install_time)
726 << "Package is not updated (app installed time didn't change).";
727 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
730 TEST_F(PreloadSmokeTest, ReadonlyUpdateInstallMode) {
731 ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
732 bf::path path = kSmokePackagesDirectory / "ReadonlyUpdateInstallMode.wgt";
733 std::string pkgid = "smokewgt42";
734 std::string appid = "smokewgt42.ReadonlyUpdateInstallMode";
736 ASSERT_EQ(backend.InstallPreload(path), ci::AppInstaller::Result::OK);
737 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
738 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
741 TEST_F(PreloadSmokeTest, ReadonlyUpdateUninstallMode) {
742 ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
743 bf::path path = kSmokePackagesDirectory / "ReadonlyUpdateUninstallMode.wgt";
744 std::string pkgid = "smokewgt43";
745 std::string appid = "smokewgt43.ReadonlyUpdateUninstallMode";
747 ASSERT_EQ(backend.InstallPreload(path),
748 ci::AppInstaller::Result::OK);
749 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
750 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
751 ASSERT_EQ(backend.Uninstall(pkgid), ci::AppInstaller::Result::OK);
752 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
755 TEST_F(HybridSmokeTest, ManifestDirectInstallMode) {
756 ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
757 bf::path src_path = kSmokePackagesDirectory /
758 "ManifestDirectInstallMode_Hybrid";
759 std::string pkgid = "smokehyb12";
760 std::string appid = "smokehyb12.ManifestDirectInstallModeHybrid";
761 bf::path pkg_path = ci::GetRootAppPath(false, params.test_user.uid);
763 ci::CopyDir(src_path / pkgid, pkg_path / pkgid);
764 ci::PkgQueryInterface pkg_query(pkgid, params.test_user.uid);
765 ASSERT_FALSE(pkg_query.IsPackageInstalled(
766 ci::GetRequestMode(params.test_user.uid)));
767 ASSERT_EQ(backend.ManifestDirectInstall(pkgid),
768 ci::AppInstaller::Result::OK);
769 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
772 TEST_F(HybridSmokeTest, ManifestDirectUpdateMode) {
773 bf::path path = kSmokePackagesDirectory /
774 "ManifestDirectUpdateMode_Hybrid.wgt";
775 std::string pkgid = "smokehyb13";
776 std::string appid = "smokehyb13.ManifestDirectUpdateModeHybrid";
778 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
779 int install_time = GetAppInstalledTime(appid.c_str(), params.test_user.uid);
780 ASSERT_EQ(backend.ManifestDirectInstall(pkgid), ci::AppInstaller::Result::OK);
781 ASSERT_TRUE(GetAppInstalledTime(appid.c_str(),
782 params.test_user.uid) > install_time)
783 << "Package is not updated (app installed time didn't change).";
784 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
787 TEST_F(SmokeTest, SharedRes24) {
788 bf::path path = kSmokePackagesDirectory / "SharedRes24.wgt";
789 std::string pkgid = "smokeSh2xx";
790 std::string appid = "smokeSh2xx.SharedRes24";
791 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
792 ValidatePackage(pkgid, {appid}, params);
793 bf::path root_path = ci::GetRootAppPath(false, params.test_user.uid);
794 ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "NOT-SHARED-WGT")); // NOLINT
795 ASSERT_FALSE(bf::exists(root_path / pkgid / "shared" / "res" / "NOT-SHARED-WGT")); // NOLINT
798 TEST_F(SmokeTest, SharedRes30) {
799 bf::path path = kSmokePackagesDirectory / "SharedRes30.wgt";
800 std::string pkgid = "smokeSh3xx";
801 std::string appid = "smokeSh3xx.SharedRes30";
802 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
803 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
804 bf::path root_path = ci::GetRootAppPath(false, params.test_user.uid);
805 ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT")); // NOLINT
806 ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-WGT")); // NOLINT
809 TEST_F(SmokeTest, SharedRes30Delta) {
810 bf::path path = kSmokePackagesDirectory / "SharedRes30Delta.wgt";
811 bf::path delta_package = kSmokePackagesDirectory / "SharedRes30Delta.delta";
812 std::string pkgid = "smokeSh3De";
813 std::string appid = "smokeSh3De.SharedRes30Delta";
814 ASSERT_EQ(backend.InstallSuccess(path), ci::AppInstaller::Result::OK);
815 ASSERT_EQ(backend.Install(delta_package), ci::AppInstaller::Result::OK);
816 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, params));
817 // Check delta modifications
818 bf::path root_path = ci::GetRootAppPath(false, params.test_user.uid);
819 ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT-2")); // NOLINT
820 ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-WGT-2")); // NOLINT
821 ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT-1")); // NOLINT
822 ASSERT_FALSE(bf::exists(root_path / pkgid / "shared" / "res" / "SHARED-WGT-1")); // NOLINT
825 TEST_F(HybridSmokeTest, SharedRes30Hybrid) {
826 bf::path path = kSmokePackagesDirectory / "SharedRes30Hybrid.wgt";
827 std::string pkgid = "smokeSh3Hy";
828 std::string appid1 = "smokeSh3Hy.SharedRes30Hybrid";
829 std::string appid2 = "sharedres30hybridserivce";
830 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
831 ASSERT_TRUE(ValidatePackage(pkgid, {appid1, appid2}, params));
832 bf::path root_path = ci::GetRootAppPath(false, params.test_user.uid);
833 ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT")); // NOLINT
834 ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-WGT")); // NOLINT
835 ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-TPK")); // NOLINT
838 TEST_F(HybridSmokeTest, SharedRes30HybridDelta) {
839 bf::path path = kSmokePackagesDirectory / "SharedRes30HybridDelta.wgt";
840 bf::path delta_package = kSmokePackagesDirectory /
841 "SharedRes30HybridDelta.delta";
842 std::string pkgid = "smokeSh3HD";
843 std::string appid1 = "smokeSh3HD.SharedRes30HybridDelta";
844 std::string appid2 = "sharedres30hybriddeltaserivce";
845 ASSERT_EQ(backend.InstallSuccess(path), ci::AppInstaller::Result::OK);
846 ASSERT_EQ(backend.Install(delta_package), ci::AppInstaller::Result::OK);
847 ASSERT_TRUE(ValidatePackage(pkgid, {appid1, appid2}, params));
848 // Check delta modifications
849 bf::path root_path = ci::GetRootAppPath(false, params.test_user.uid);
850 ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT-2")); // NOLINT
851 ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-WGT-2")); // NOLINT
852 ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-TPK-2")); // NOLINT
853 ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT-1")); // NOLINT
854 ASSERT_FALSE(bf::exists(root_path / pkgid / "shared" / "res" / "SHARED-WGT-1")); // NOLINT
857 TEST_F(SmokeTest, InstallExtendedMode) {
858 ASSERT_TRUE(CheckAvailableExtendedPath());
859 bf::path path = kSmokePackagesDirectory / "InstallExtendedMode.wgt";
860 std::string pkgid = "smokewgt44";
861 std::string appid = "smokewgt44.web";
862 ASSERT_EQ(backend.InstallWithStorage(path, StorageType::EXTENDED),
863 ci::AppInstaller::Result::OK);
864 ASSERT_TRUE(ValidateExtendedPackage(pkgid, {appid}, params));
867 TEST_F(SmokeTest, RecoveryMode_CrashAfterUnzip) {
868 bf::path path = kSmokePackagesDirectory / "RecoveryMode_CrashAfterUnzip.wgt";
869 RemoveAllRecoveryFiles("/wgt-recovery", params.test_user.uid);
870 ci::Subprocess backend_crash("/usr/bin/wgt-installer-ut/smoke-test-helper");
871 std::string test_uid_str = std::to_string(params.test_user.uid);
872 backend_crash.Run("-i", path.string(), "-u", test_uid_str.c_str(),
873 "-step_name", "Unzip");
874 ASSERT_NE(backend_crash.Wait(), 0);
876 std::string pkgid = "smokewgt45";
877 bf::path recovery_file = FindRecoveryFile("/wgt-recovery",
878 params.test_user.uid);
879 ASSERT_FALSE(recovery_file.empty());
880 std::unique_ptr<ci::recovery::RecoveryFile> recovery_info =
881 GetRecoverFileInfo(recovery_file);
882 ASSERT_TRUE(recovery_info);
883 ASSERT_EQ(backend.Recover(recovery_file), ci::AppInstaller::Result::OK);
884 ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
885 ASSERT_FALSE(bf::exists(recovery_info->unpacked_dir()));
888 TEST_F(SmokeTest, InstallationMode_GlobalServiceAppWithUiAppId) {
889 bf::path path = kSmokePackagesDirectory /
890 "InstallationMode_GlobalServiceAppWithUiAppId.wgt";
891 std::string pkgid = "smokewgt46";
892 std::string ui_appid = "smokewgt46.uiapp";
893 std::string service_appid = "smokewgt46.serviceapp";
894 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
895 ASSERT_TRUE(ValidatePackage(pkgid, {ui_appid, service_appid}, params));
898 TEST_F(SmokeTest, InstallationMode_GlobalServiceAppWithoutUiAppId) {
899 bf::path path = kSmokePackagesDirectory /
900 "InstallationMode_GlobalServiceAppWithoutUiAppId.wgt";
901 std::string pkgid = "smokewgt47";
902 std::string service_appid = "smokewgt47.serviceapp";
903 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
904 ASSERT_TRUE(ValidatePackage(pkgid, {service_appid}, params));
907 TEST_F(SmokeTest, InstallationMode_UIServiceAppWithUiAppId) {
908 bf::path path = kSmokePackagesDirectory /
909 "InstallationMode_UIServiceAppWithUiAppId.wgt";
910 std::string pkgid = "smokewgt48";
911 std::string ui_appid = "smokewgt48.uiapp";
912 std::string service_appid = "smokewgt48.serviceapp";
913 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
914 ASSERT_TRUE(ValidatePackage(pkgid, {ui_appid, service_appid}, params));
917 TEST_F(SmokeTest, InstallationMode_UIServiceAppWithoutUiAppId) {
918 bf::path path = kSmokePackagesDirectory /
919 "InstallationMode_UIServiceAppWithoutUiAppId.wgt";
920 std::string pkgid = "smokewgt49";
921 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::ERROR);
924 TEST_F(SmokeTest, InstallationMode_UIAppWithoutUiAppId) {
925 bf::path path = kSmokePackagesDirectory /
926 "InstallationMode_UIAppWithoutUiAppId.wgt";
927 std::string pkgid = "smokewgt50";
928 ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::ERROR);
931 } // namespace smoke_test
933 int main(int argc, char** argv) {
935 ci::RequestMode request_mode = st::ParseRequestMode(argc, argv);
936 if (getuid() != 0 || request_mode != ci::RequestMode::GLOBAL) {
937 std::cout << "Skip tests for preload request" << std::endl;
938 ::testing::GTEST_FLAG(filter) = "SmokeTest.*";
940 testing::InitGoogleTest(&argc, argv);
941 ::env = static_cast<smoke_test::SmokeEnvironment*>(
942 testing::AddGlobalTestEnvironment(
943 new smoke_test::SmokeEnvironment(request_mode)));
944 signal(SIGINT, ::signalHandler);
945 signal(SIGSEGV, ::signalHandler);
946 return RUN_ALL_TESTS();
948 std::cout << "Exception occurred during testing" << std::endl;