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 <common/utils/subprocess.h>
6 #include <common/utils/file_util.h>
8 #include <gtest/gtest-death-test.h>
10 #include "unit_tests/smoke_utils.h"
13 namespace common_installer {
15 class SmokeEnvironment : public testing::Environment {
17 explicit SmokeEnvironment(ci::RequestMode mode) {\
20 void SetUp() override {
21 if (request_mode_ == ci::RequestMode::USER) {
22 ASSERT_TRUE(AddTestUser(kNormalUserName));
24 kTestUserId = kGlobalUserUid;
25 kTestGroupId = kGlobalUserGid;
26 kTestUserIdStr = std::to_string(kTestUserId);
28 backups_ = SetupBackupDirectories();
29 for (auto& path : backups_)
30 ASSERT_TRUE(BackupPath(path));
32 void TearDown() override {
33 ASSERT_TRUE(request_mode_ == ci::RequestMode::GLOBAL ||
34 (request_mode_ == ci::RequestMode::USER &&
35 kGlobalUserUid != kTestUserId));
36 UninstallAllSmokeApps(request_mode_);
37 for (auto& path : backups_)
38 ASSERT_TRUE(RestorePath(path));
39 if (request_mode_ == ci::RequestMode::USER)
40 ASSERT_TRUE(DeleteTestUser(kNormalUserName));
44 ci::RequestMode request_mode_;
45 std::vector<bf::path> backups_;
48 class SmokeTest : public testing::Test {
51 class PreloadSmokeTest : public testing::Test {
52 void SetUp() override {
53 ASSERT_EQ(kGlobalUserUid, kTestUserId);
57 TEST_F(SmokeTest, InstallationMode) {
58 bf::path path = kSmokePackagesDirectory / "InstallationMode.wgt";
59 std::string pkgid = "smokewgt03";
60 std::string appid = "smokewgt03.InstallationMode";
61 ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
62 ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
65 TEST_F(SmokeTest, UpdateMode) {
66 bf::path path_old = kSmokePackagesDirectory / "UpdateMode.wgt";
67 bf::path path_new = kSmokePackagesDirectory / "UpdateMode_2.wgt";
68 std::string pkgid = "smokewgt04";
69 std::string appid = "smokewgt04.UpdateMode";
70 ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK);
71 AddDataFiles(pkgid, kTestUserId);
72 ASSERT_EQ(Install(path_new, PackageType::WGT), ci::AppInstaller::Result::OK);
73 ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
75 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
76 ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
79 TEST_F(SmokeTest, DeinstallationMode) {
80 bf::path path = kSmokePackagesDirectory / "DeinstallationMode.wgt";
81 std::string pkgid = "smokewgt05";
82 std::string appid = "smokewgt05.DeinstallationMode";
83 ASSERT_EQ(Install(path, PackageType::WGT),
84 ci::AppInstaller::Result::OK);
85 ASSERT_EQ(Uninstall(pkgid, PackageType::WGT, false),
86 ci::AppInstaller::Result::OK);
87 ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
90 TEST_F(SmokeTest, RDSMode) {
91 bf::path path = kSmokePackagesDirectory / "RDSMode.wgt";
92 std::string pkgid = "smokewgt11";
93 std::string appid = "smokewgt11.RDSMode";
94 bf::path delta_directory = kSmokePackagesDirectory / "delta_dir/";
95 bf::path sdk_expected_directory =
96 bf::path(ci::GetRootAppPath(false, kTestUserId)) / "tmp" / pkgid;
98 bf::create_directories(sdk_expected_directory.parent_path(), error);
100 ASSERT_TRUE(CopyDir(delta_directory, sdk_expected_directory));
101 ASSERT_EQ(RDSUpdate(path, pkgid, PackageType::WGT),
102 ci::AppInstaller::Result::OK);
103 ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
105 // Check delta modifications
106 ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
107 "res" / "wgt" / "DELETED"));
108 ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
109 "res" / "wgt" / "ADDED"));
110 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "2\n"));
113 TEST_F(SmokeTest, EnablePkg) {
114 bf::path path = kSmokePackagesDirectory / "EnablePkg.wgt";
115 std::string pkgid = "smokewgt22";
116 ASSERT_EQ(Install(path, PackageType::WGT),
117 ci::AppInstaller::Result::OK);
118 ASSERT_EQ(DisablePackage(pkgid, PackageType::WGT),
119 ci::AppInstaller::Result::OK);
120 ASSERT_EQ(EnablePackage(pkgid, PackageType::WGT),
121 ci::AppInstaller::Result::OK);
123 ASSERT_TRUE(ci::QueryIsPackageInstalled(pkgid,
124 ci::GetRequestMode(kTestUserId),
128 TEST_F(SmokeTest, DisablePkg) {
129 bf::path path = kSmokePackagesDirectory / "DisablePkg.wgt";
130 std::string pkgid = "smokewgt21";
131 std::string appid = "smokewgt21.DisablePkg";
132 ASSERT_EQ(Install(path, PackageType::WGT),
133 ci::AppInstaller::Result::OK);
134 ASSERT_EQ(DisablePackage(pkgid, PackageType::WGT),
135 ci::AppInstaller::Result::OK);
136 ASSERT_TRUE(ci::QueryIsDisabledPackage(pkgid, kTestUserId));
137 ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
140 TEST_F(SmokeTest, DeltaMode) {
141 bf::path path = kSmokePackagesDirectory / "DeltaMode.wgt";
142 bf::path delta_package = kSmokePackagesDirectory / "DeltaMode.delta";
143 std::string pkgid = "smokewgt17";
144 std::string appid = "smokewgt17.DeltaMode";
145 ASSERT_EQ(DeltaInstall(path, delta_package, PackageType::WGT),
146 ci::AppInstaller::Result::OK);
147 ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
149 // Check delta modifications
150 ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
151 "res" / "wgt" / "DELETED"));
152 ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
153 "res" / "wgt" / "ADDED"));
154 ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
155 "res" / "wgt" / "css" / "style.css"));
156 ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
157 "res" / "wgt" / "images" / "tizen_32.png"));
158 ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
159 "res" / "wgt" / "js" / "main.js"));
160 ASSERT_TRUE(ValidateFileContentInPackage(
161 pkgid, "res/wgt/MODIFIED", "version 2\n"));
164 TEST_F(SmokeTest, RecoveryMode_ForInstallation) {
165 bf::path path = kSmokePackagesDirectory / "RecoveryMode_ForInstallation.wgt";
166 Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
167 backend_crash.Run("-i", path.string(), "-u", kTestUserIdStr.c_str());
168 ASSERT_NE(backend_crash.Wait(), 0);
170 std::string pkgid = "smokewgt09";
171 std::string appid = "smokewgt09.RecoveryModeForInstallation";
172 bf::path recovery_file = FindRecoveryFile();
173 ASSERT_FALSE(recovery_file.empty());
174 ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
175 ci::AppInstaller::Result::OK);
176 ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
179 TEST_F(SmokeTest, RecoveryMode_ForUpdate) {
180 bf::path path_old = kSmokePackagesDirectory / "RecoveryMode_ForUpdate.wgt";
181 bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForUpdate_2.wgt";
182 RemoveAllRecoveryFiles();
183 ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK);
184 std::string pkgid = "smokewgt10";
185 std::string appid = "smokewgt10.RecoveryModeForUpdate";
186 AddDataFiles(pkgid, kTestUserId);
187 Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
188 backend_crash.Run("-i", path_new.string(), "-u", kTestUserIdStr.c_str());
189 ASSERT_NE(backend_crash.Wait(), 0);
191 bf::path recovery_file = FindRecoveryFile();
192 ASSERT_FALSE(recovery_file.empty());
193 ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
194 ci::AppInstaller::Result::OK);
195 ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
197 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
198 ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
201 TEST_F(SmokeTest, RecoveryMode_ForDelta) {
202 bf::path path_old = kSmokePackagesDirectory / "RecoveryMode_ForDelta.wgt";
203 bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForDelta.delta";
204 RemoveAllRecoveryFiles();
205 ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK);
206 Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
207 backend_crash.Run("-i", path_new.string(), "-u", kTestUserIdStr.c_str());
208 ASSERT_NE(backend_crash.Wait(), 0);
210 std::string pkgid = "smokewgt30";
211 std::string appid = "smokewgt30.RecoveryModeForDelta";
212 bf::path recovery_file = FindRecoveryFile();
213 ASSERT_FALSE(recovery_file.empty());
214 ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
215 ci::AppInstaller::Result::OK);
216 ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
218 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
221 TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
222 bf::path path = kSmokePackagesDirectory / "RecoveryMode_ForMountInstall.wgt";
223 RemoveAllRecoveryFiles();
224 Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
225 backend_crash.Run("-w", path.string(), "-u", kTestUserIdStr.c_str());
226 ASSERT_NE(backend_crash.Wait(), 0);
228 std::string pkgid = "smokewgt31";
229 std::string appid = "smokewgt31.RecoveryModeForMountInstall";
230 bf::path recovery_file = FindRecoveryFile();
231 ASSERT_FALSE(recovery_file.empty());
232 ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
233 ci::AppInstaller::Result::OK);
234 ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
237 TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
239 kSmokePackagesDirectory / "RecoveryMode_ForMountUpdate.wgt";
241 kSmokePackagesDirectory / "RecoveryMode_ForMountUpdate_2.wgt";
242 std::string pkgid = "smokewgt32";
243 std::string appid = "smokewgt32.RecoveryModeForMountUpdate";
244 RemoveAllRecoveryFiles();
245 ASSERT_EQ(MountInstall(path_old, PackageType::WGT),
246 ci::AppInstaller::Result::OK);
247 AddDataFiles(pkgid, kTestUserId);
248 Subprocess backend_crash("/usr/bin/wgt-backend-ut/smoke-test-helper");
249 backend_crash.Run("-w", path_new.string(), "-u", kTestUserIdStr.c_str());
250 ASSERT_NE(backend_crash.Wait(), 0);
252 // Filesystem may be mounted after crash
253 ScopedTzipInterface poweroff_unmount_interface(pkgid);
254 poweroff_unmount_interface.Release();
256 bf::path recovery_file = FindRecoveryFile();
257 ASSERT_FALSE(recovery_file.empty());
258 ASSERT_EQ(Recover(recovery_file, PackageType::WGT),
259 ci::AppInstaller::Result::OK);
261 ScopedTzipInterface interface(pkgid);
262 ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
263 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
264 ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
267 TEST_F(SmokeTest, InstallationMode_GoodSignature) {
269 bf::path path = kSmokePackagesDirectory / "InstallationMode_GoodSignature.wgt"; // NOLINT
270 ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
273 TEST_F(SmokeTest, InstallationMode_WrongSignature) {
275 bf::path path = kSmokePackagesDirectory / "InstallationMode_WrongSignature.wgt"; // NOLINT
276 ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::ERROR);
279 TEST_F(SmokeTest, InstallationMode_Rollback) {
280 bf::path path = kSmokePackagesDirectory / "InstallationMode_Rollback.wgt";
281 std::string pkgid = "smokewgt06";
282 std::string appid = "smokewgt06.InstallationModeRollback";
283 ASSERT_EQ(Install(path, PackageType::WGT, RequestResult::FAIL),
284 ci::AppInstaller::Result::ERROR);
285 ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
288 TEST_F(SmokeTest, UpdateMode_Rollback) {
289 bf::path path_old = kSmokePackagesDirectory / "UpdateMode_Rollback.wgt";
290 bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Rollback_2.wgt";
291 std::string pkgid = "smokewgt07";
292 std::string appid = "smokewgt07.UpdateModeRollback";
293 ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK);
294 AddDataFiles(pkgid, kTestUserId);
295 ASSERT_EQ(Install(path_new, PackageType::WGT, RequestResult::FAIL),
296 ci::AppInstaller::Result::ERROR);
297 ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
299 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
300 ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
303 TEST_F(SmokeTest, DeltaMode_Rollback) {
304 bf::path path = kSmokePackagesDirectory / "DeltaMode_Rollback.wgt";
305 bf::path delta_package = kSmokePackagesDirectory / "DeltaMode_Rollback.delta";
306 std::string pkgid = "smokewgt01";
307 std::string appid = "smokewgt01.DeltaMode";
308 ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
309 AddDataFiles(pkgid, kTestUserId);
310 ASSERT_EQ(Install(delta_package, PackageType::WGT, RequestResult::FAIL),
311 ci::AppInstaller::Result::ERROR);
313 ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
314 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED",
316 ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
317 ASSERT_TRUE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
319 ASSERT_FALSE(bf::exists(GetPackageRoot(pkgid, kTestUserId) /
323 TEST_F(SmokeTest, InstallationMode_Hybrid) {
324 bf::path path = kSmokePackagesDirectory / "InstallationMode_Hybrid.wgt";
325 std::string pkgid = "smokehyb01";
326 // Excutable for native app doesn't create symlink
327 std::string appid1 = "smokehyb01.Web";
328 ASSERT_EQ(Install(path, PackageType::HYBRID), ci::AppInstaller::Result::OK);
329 ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
332 TEST_F(SmokeTest, UpdateMode_Hybrid) {
333 bf::path path_old = kSmokePackagesDirectory / "UpdateMode_Hybrid.wgt";
334 bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Hybrid_2.wgt";
335 std::string pkgid = "smokehyb02";
336 std::string appid1 = "smokehyb02.Web";
337 ASSERT_EQ(Install(path_old, PackageType::HYBRID),
338 ci::AppInstaller::Result::OK);
339 // AddDataFiles(pkgid, kTestUserId);
340 ASSERT_EQ(Install(path_new, PackageType::HYBRID),
341 ci::AppInstaller::Result::OK);
342 ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
344 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
345 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "VERSION", "2\n"));
346 // ValidateDataFiles(pkgid, kTestUserId);
349 TEST_F(SmokeTest, DeinstallationMode_Hybrid) {
350 bf::path path = kSmokePackagesDirectory / "DeinstallationMode_Hybrid.wgt";
351 std::string pkgid = "smokehyb03";
352 std::string appid1 = "smokehyb03.Web";
353 ASSERT_EQ(Install(path, PackageType::HYBRID),
354 ci::AppInstaller::Result::OK);
355 ASSERT_EQ(Uninstall(pkgid, PackageType::HYBRID, false),
356 ci::AppInstaller::Result::OK);
357 ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid1}));
360 TEST_F(SmokeTest, DeltaMode_Hybrid) {
361 bf::path path = kSmokePackagesDirectory / "DeltaMode_Hybrid.wgt";
362 bf::path delta_package = kSmokePackagesDirectory / "DeltaMode_Hybrid.delta";
363 std::string pkgid = "smokehyb04";
364 std::string appid1 = "smokehyb04.Web";
365 ASSERT_EQ(DeltaInstall(path, delta_package, PackageType::HYBRID),
366 ci::AppInstaller::Result::OK);
367 ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
369 // Check delta modifications
370 bf::path root_path = ci::GetRootAppPath(false,
372 ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "DELETED"));
373 ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "ADDED"));
374 ASSERT_FALSE(bf::exists(root_path / pkgid / "lib" / "DELETED"));
375 ASSERT_TRUE(bf::exists(root_path / pkgid / "lib" / "ADDED"));
376 ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "css" / "style.css")); // NOLINT
377 ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "images" / "tizen_32.png")); // NOLINT
378 ASSERT_TRUE(bf::exists(root_path / pkgid / "res" / "wgt" / "js" / "main.js"));
379 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED", "version 2\n")); // NOLINT
380 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/MODIFIED", "version 2\n")); // NOLINT
383 TEST_F(SmokeTest, MountInstallationMode_Hybrid) {
384 bf::path path = kSmokePackagesDirectory / "MountInstallationMode_Hybrid.wgt";
385 std::string pkgid = "smokehyb05";
386 std::string appid1 = "smokehyb05.web";
387 ASSERT_EQ(MountInstall(path, PackageType::HYBRID),
388 ci::AppInstaller::Result::OK);
389 ScopedTzipInterface interface(pkgid);
390 ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
393 TEST_F(SmokeTest, MountUpdateMode_Hybrid) {
394 bf::path path_old = kSmokePackagesDirectory / "MountUpdateMode_Hybrid.wgt";
395 bf::path path_new = kSmokePackagesDirectory / "MountUpdateMode_Hybrid_2.wgt";
396 std::string pkgid = "smokehyb06";
397 std::string appid1 = "smokehyb06.web";
398 ASSERT_EQ(MountInstall(path_old, PackageType::HYBRID),
399 ci::AppInstaller::Result::OK);
400 AddDataFiles(pkgid, kTestUserId);
401 ASSERT_EQ(MountInstall(path_new, PackageType::HYBRID),
402 ci::AppInstaller::Result::OK);
403 ScopedTzipInterface interface(pkgid);
404 ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
406 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
407 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "2\n"));
408 ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
411 TEST_F(SmokeTest, InstallationMode_Rollback_Hybrid) {
412 bf::path path = kSmokePackagesDirectory /
413 "InstallationMode_Rollback_Hybrid.wgt";
414 std::string pkgid = "smokehyb07";
415 std::string appid1 = "smokehyb07.web";
416 ASSERT_EQ(Install(path, PackageType::HYBRID, RequestResult::FAIL),
417 ci::AppInstaller::Result::ERROR);
418 ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid1}));
421 TEST_F(SmokeTest, UpdateMode_Rollback_Hybrid) {
422 bf::path path_old = kSmokePackagesDirectory /
423 "UpdateMode_Rollback_Hybrid.wgt";
424 bf::path path_new = kSmokePackagesDirectory /
425 "UpdateMode_Rollback_Hybrid_2.wgt";
426 std::string pkgid = "smokehyb08";
427 std::string appid1 = "smokehyb08.web";
428 ASSERT_EQ(Install(path_old, PackageType::HYBRID),
429 ci::AppInstaller::Result::OK);
430 AddDataFiles(pkgid, kTestUserId);
431 ASSERT_EQ(Install(path_new, PackageType::HYBRID,
432 RequestResult::FAIL), ci::AppInstaller::Result::ERROR);
433 ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
435 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
436 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "1\n"));
437 ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
440 TEST_F(SmokeTest, DeltaMode_Rollback_Hybrid) {
441 bf::path path = kSmokePackagesDirectory / "DeltaMode_Rollback_Hybrid.wgt";
442 bf::path delta_package = kSmokePackagesDirectory /
443 "DeltaMode_Rollback_Hybrid.delta";
444 std::string pkgid = "smokehyb11";
445 std::string appid1 = "smokehyb11.web";
446 ASSERT_EQ(Install(path, PackageType::HYBRID), ci::AppInstaller::Result::OK);
447 AddDataFiles(pkgid, kTestUserId);
448 ASSERT_EQ(Install(delta_package, PackageType::HYBRID, RequestResult::FAIL),
449 ci::AppInstaller::Result::ERROR);
451 ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
452 // Check delta modifications
453 bf::path root_path = GetPackageRoot(pkgid, kTestUserId);
454 ASSERT_TRUE(bf::exists(root_path / "res" / "wgt" / "DELETED"));
455 ASSERT_FALSE(bf::exists(root_path / "res" / "wgt" / "ADDED"));
456 ASSERT_TRUE(bf::exists(root_path / "lib" / "DELETED"));
457 ASSERT_FALSE(bf::exists(root_path / "lib" / "ADDED"));
458 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/MODIFIED",
460 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/MODIFIED",
462 ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
465 TEST_F(SmokeTest, MountInstallationMode_Rollback_Hybrid) {
466 bf::path path = kSmokePackagesDirectory /
467 "MountInstallationMode_Rollback_Hybrid.wgt";
468 std::string pkgid = "smokehyb09";
469 std::string appid1 = "smokehyb09.web";
470 ASSERT_EQ(MountInstall(path, PackageType::HYBRID, RequestResult::FAIL),
471 ci::AppInstaller::Result::ERROR);
472 ScopedTzipInterface interface(pkgid);
473 ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid1}));
476 TEST_F(SmokeTest, MountUpdateMode_Rollback_Hybrid) {
477 bf::path path_old = kSmokePackagesDirectory /
478 "MountUpdateMode_Rollback_Hybrid.wgt";
479 bf::path path_new = kSmokePackagesDirectory /
480 "MountUpdateMode_Rollback_Hybrid_2.wgt";
481 std::string pkgid = "smokehyb10";
482 std::string appid1 = "smokehyb10.web";
483 ASSERT_EQ(MountInstall(path_old, PackageType::HYBRID),
484 ci::AppInstaller::Result::OK);
485 AddDataFiles(pkgid, kTestUserId);
486 ASSERT_EQ(MountInstall(path_new, PackageType::HYBRID,
487 RequestResult::FAIL), ci::AppInstaller::Result::ERROR);
488 ScopedTzipInterface interface(pkgid);
489 ASSERT_TRUE(ValidatePackage(pkgid, {appid1}));
491 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
492 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "lib/VERSION", "1\n"));
493 ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
496 TEST_F(SmokeTest, MountInstallationMode) {
497 bf::path path = kSmokePackagesDirectory / "MountInstallationMode.wgt";
498 std::string pkgid = "smokewgt28";
499 std::string appid = "smokewgt28.InstallationMode";
500 ASSERT_EQ(MountInstall(path, PackageType::WGT), ci::AppInstaller::Result::OK);
501 ScopedTzipInterface interface(pkgid);
502 ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
505 TEST_F(SmokeTest, MountUpdateMode) {
506 bf::path path_old = kSmokePackagesDirectory / "MountUpdateMode.wgt";
507 bf::path path_new = kSmokePackagesDirectory / "MountUpdateMode_2.wgt";
508 std::string pkgid = "smokewgt29";
509 std::string appid = "smokewgt29.UpdateMode";
510 ASSERT_EQ(MountInstall(path_old, PackageType::WGT),
511 ci::AppInstaller::Result::OK);
512 AddDataFiles(pkgid, kTestUserId);
513 ASSERT_EQ(MountInstall(path_new, PackageType::WGT),
514 ci::AppInstaller::Result::OK);
515 ScopedTzipInterface interface(pkgid);
516 ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
518 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2\n"));
519 ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
522 TEST_F(SmokeTest, MountInstallationMode_Rollback) {
524 kSmokePackagesDirectory / "MountInstallationMode_Rollback.wgt";
525 std::string pkgid = "smokewgt33";
526 std::string appid = "smokewgt33.web";
527 ASSERT_EQ(MountInstall(path, PackageType::WGT, RequestResult::FAIL),
528 ci::AppInstaller::Result::ERROR);
529 ScopedTzipInterface interface(pkgid);
530 ASSERT_TRUE(CheckPackageNonExistance(pkgid, {appid}));
533 TEST_F(SmokeTest, MountUpdateMode_Rollback) {
534 bf::path path_old = kSmokePackagesDirectory / "MountUpdateMode_Rollback.wgt";
536 kSmokePackagesDirectory / "MountUpdateMode_Rollback_2.wgt";
537 std::string pkgid = "smokewgt34";
538 std::string appid = "smokewgt34.web";
539 ASSERT_EQ(MountInstall(path_old, PackageType::WGT),
540 ci::AppInstaller::Result::OK);
541 AddDataFiles(pkgid, kTestUserId);
542 ASSERT_EQ(MountInstall(path_new, PackageType::WGT,
543 RequestResult::FAIL), ci::AppInstaller::Result::ERROR);
544 ScopedTzipInterface interface(pkgid);
545 ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
547 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n"));
548 ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
551 TEST_F(SmokeTest, UserDefinedPlugins) {
552 bf::path path = kSmokePackagesDirectory / "SimpleEchoPrivilege.wgt";
553 std::string pkgid = "smokewgt02";
554 std::string appid = "smokewgt02.SimpleEcho";
555 std::string call_privilege = "http://tizen.org/privilege/call";
556 std::string location_privilege = "http://tizen.org/privilege/location";
557 std::string power_privilege = "http://tizen.org/privilege/power";
559 ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
560 ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
561 std::vector<std::string> res;
562 ASSERT_TRUE(ci::QueryPrivilegesForPkgId(pkgid, kTestUserId, &res));
563 ASSERT_TRUE(std::find(res.begin(), res.end(), call_privilege) != res.end());
564 ASSERT_TRUE(std::find(res.begin(), res.end(), location_privilege)
566 ASSERT_TRUE(std::find(res.begin(), res.end(), power_privilege) != res.end());
569 TEST_F(SmokeTest, InstallExternalMode) {
570 ASSERT_TRUE(CheckAvailableExternalPath());
571 bf::path path = kSmokePackagesDirectory / "InstallExternalMode.wgt";
572 std::string pkgid = "smokewgt35";
573 std::string appid = "smokewgt35.web";
574 ASSERT_EQ(InstallExternal(path, PackageType::WGT),
575 ci::AppInstaller::Result::OK);
576 ValidateExternalPackage(pkgid, {appid});
579 TEST_F(SmokeTest, MigrateLegacyExternalImageMode) {
580 ASSERT_TRUE(CheckAvailableExternalPath());
582 kSmokePackagesDirectory / "MigrateLegacyExternalImageMode.wgt";
583 std::string pkgid = "smokewgt36";
584 std::string appid = "smokewgt36.web";
585 bf::path legacy_path = kSmokePackagesDirectory / kLegacyExtImageDir;
586 if (kTestUserIdStr == kDefaultUserIdStr || kTestUserId == kGlobalUserUid) {
587 ASSERT_EQ(MigrateLegacyExternalImage(pkgid, path, legacy_path,
588 PackageType::WGT), ci::AppInstaller::Result::OK);
589 ValidateExternalPackage(pkgid, {appid});
591 ASSERT_EQ(MigrateLegacyExternalImage(pkgid, path, legacy_path,
592 PackageType::WGT), ci::AppInstaller::Result::ERROR);
596 TEST_F(PreloadSmokeTest, InstallationMode_Preload) {
597 ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
598 bf::path path = kSmokePackagesDirectory / "InstallationMode_Preload.wgt";
599 std::string pkgid = "smokewgt37";
600 std::string appid = "smokewgt37.InstallationModePreload";
601 ASSERT_EQ(InstallPreload(path, PackageType::WGT),
602 ci::AppInstaller::Result::OK);
603 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, true));
606 TEST_F(PreloadSmokeTest, UpdateMode_Preload) {
607 ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
608 bf::path path_old = kSmokePackagesDirectory / "UpdateMode_Preload.wgt";
609 bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Preload2.wgt";
610 std::string pkgid = "smokewgt38";
611 std::string appid = "smokewgt38.UpdateModePreload";
612 ASSERT_EQ(InstallPreload(path_old, PackageType::WGT),
613 ci::AppInstaller::Result::OK);
614 AddDataFiles(pkgid, kTestUserId);
615 ASSERT_EQ(InstallPreload(path_new, PackageType::WGT),
616 ci::AppInstaller::Result::OK);
617 ASSERT_TRUE(ValidatePackage(pkgid, {appid}, true));
619 ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "2",
621 ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId));
624 TEST_F(PreloadSmokeTest, DeinstallationMode_Preload) {
625 ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
626 bf::path path = kSmokePackagesDirectory / "DeinstallationMode_Preload.wgt";
627 std::string pkgid = "smokewgt39";
628 std::string appid = "smokewgt39.DeinstallationModePreload";
629 ASSERT_EQ(InstallPreload(path, PackageType::WGT),
630 ci::AppInstaller::Result::OK);
631 ASSERT_EQ(Uninstall(pkgid, PackageType::WGT, true),
632 ci::AppInstaller::Result::OK);
633 CheckPackageReadonlyNonExistance(pkgid, {appid});
636 TEST_F(SmokeTest, SharedRes24) {
637 bf::path path = kSmokePackagesDirectory / "SharedRes24.wgt";
638 std::string pkgid = "smokeSh2xx";
639 std::string appid = "smokeSh2xx.SharedRes24";
640 ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
641 ValidatePackage(pkgid, {appid});
642 bf::path root_path = ci::GetRootAppPath(false, kTestUserId);
643 ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "NOT-SHARED-WGT")); // NOLINT
644 ASSERT_FALSE(bf::exists(root_path / pkgid / "shared" / "res" / "NOT-SHARED-WGT")); // NOLINT
647 TEST_F(SmokeTest, SharedRes30) {
648 bf::path path = kSmokePackagesDirectory / "SharedRes30.wgt";
649 std::string pkgid = "smokeSh3xx";
650 std::string appid = "smokeSh3xx.SharedRes30";
651 ASSERT_EQ(Install(path, PackageType::WGT), ci::AppInstaller::Result::OK);
652 ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
653 bf::path root_path = ci::GetRootAppPath(false, kTestUserId);
654 ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT")); // NOLINT
655 ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-WGT")); // NOLINT
658 TEST_F(SmokeTest, SharedRes30Delta) {
659 bf::path path = kSmokePackagesDirectory / "SharedRes30Delta.wgt";
660 bf::path delta_package = kSmokePackagesDirectory / "SharedRes30Delta.delta";
661 std::string pkgid = "smokeSh3De";
662 std::string appid = "smokeSh3De.SharedRes30Delta";
663 ASSERT_EQ(DeltaInstall(path, delta_package, PackageType::WGT),
664 ci::AppInstaller::Result::OK);
665 ASSERT_TRUE(ValidatePackage(pkgid, {appid}));
666 // Check delta modifications
667 bf::path root_path = ci::GetRootAppPath(false, kTestUserId);
668 ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT-2")); // NOLINT
669 ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-WGT-2")); // NOLINT
670 ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT-1")); // NOLINT
671 ASSERT_FALSE(bf::exists(root_path / pkgid / "shared" / "res" / "SHARED-WGT-1")); // NOLINT
674 TEST_F(SmokeTest, SharedRes30Hybrid) {
675 bf::path path = kSmokePackagesDirectory / "SharedRes30Hybrid.wgt";
676 std::string pkgid = "smokeSh3Hy";
677 std::string appid1 = "smokeSh3Hy.SharedRes30Hybrid";
678 std::string appid2 = "sharedres30hybridserivce";
679 ASSERT_EQ(Install(path, PackageType::HYBRID), ci::AppInstaller::Result::OK);
680 ASSERT_TRUE(ValidatePackage(pkgid, {appid1, appid2}));
681 bf::path root_path = ci::GetRootAppPath(false, kTestUserId);
682 ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT")); // NOLINT
683 ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-WGT")); // NOLINT
684 ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-TPK")); // NOLINT
687 TEST_F(SmokeTest, SharedRes30HybridDelta) {
688 bf::path path = kSmokePackagesDirectory / "SharedRes30HybridDelta.wgt";
689 bf::path delta_package = kSmokePackagesDirectory /
690 "SharedRes30HybridDelta.delta";
691 std::string pkgid = "smokeSh3HD";
692 std::string appid1 = "smokeSh3HD.SharedRes30HybridDelta";
693 std::string appid2 = "sharedres30hybriddeltaserivce";
694 ASSERT_EQ(DeltaInstall(path, delta_package, PackageType::HYBRID),
695 ci::AppInstaller::Result::OK);
696 ASSERT_TRUE(ValidatePackage(pkgid, {appid1, appid2}));
697 // Check delta modifications
698 bf::path root_path = ci::GetRootAppPath(false, kTestUserId);
699 ASSERT_TRUE(bf::is_symlink(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT-2")); // NOLINT
700 ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-WGT-2")); // NOLINT
701 ASSERT_TRUE(bf::is_regular_file(root_path / pkgid / "shared" / "res" / "SHARED-TPK-2")); // NOLINT
702 ASSERT_FALSE(bf::exists(root_path / pkgid / "res" / "wgt" / "shared" / "res" / "SHARED-WGT-1")); // NOLINT
703 ASSERT_FALSE(bf::exists(root_path / pkgid / "shared" / "res" / "SHARED-WGT-1")); // NOLINT
706 } // namespace common_installer
708 int main(int argc, char** argv) {
709 ci::RequestMode request_mode = ParseRequestMode(argc, argv);
710 if (getuid() != 0 || request_mode != ci::RequestMode::GLOBAL) {
711 std::cout << "Skip tests for preload request" << std::endl;
712 ::testing::GTEST_FLAG(filter) = "SmokeTest.*";
714 testing::InitGoogleTest(&argc, argv);
715 env = testing::AddGlobalTestEnvironment(
716 new common_installer::SmokeEnvironment(request_mode));
717 signal(SIGINT, signalHandler);
718 signal(SIGSEGV, signalHandler);
719 return RUN_ALL_TESTS();