Refactoring ValidatePackage() functions parameter 42/159542/6
authorDamian Pietruchowski <d.pietruchow@samsung.com>
Thu, 9 Nov 2017 12:44:17 +0000 (13:44 +0100)
committerBartlomiej Kunikowski <b.kunikowski@partner.samsung.com>
Fri, 29 Dec 2017 07:28:07 +0000 (08:28 +0100)
Tpk package has different binary name than appid.
So we need to pass appid and exec name to ValidatePackage()
functions.

Submit with:
- https://review.tizen.org/gerrit/#/c/159539/
- https://review.tizen.org/gerrit/#/c/159540/

Change-Id: If103c44bc9ce0127861021edfa1c87d457da0690
Signed-off-by: Damian Pietruchowski <d.pietruchow@samsung.com>
src/unit_tests/extensive_smoke_test.cc
src/unit_tests/smoke_test.cc
src/unit_tests/smoke_utils.cc
src/unit_tests/smoke_utils.h

index e6b72b3aaab8bb9055b0d6c8179a5207cb4d2607..063d9d01115ba1f4e516c5676e69d7639ce3cb2e 100644 (file)
@@ -79,13 +79,14 @@ TEST_F(SmokeTest, DeltaMode_Tpk_Rollback) {
       "DeltaMode_Tpk_Rollback.delta";
   std::string pkgid = "smoketpk28";
   std::string appid = "smoketpk28.DeltaModeTpk_Rollback";
+  std::string exec = "basicdali";
   ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
   std::string test_uid_str = std::to_string(params.test_user.uid);
   const char* argv[] =
       {"", "-i", delta_package.c_str(), "-u", test_uid_str.c_str()};
 
   backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool {
-    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {"basicdali"}, params));
+    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 
     // Check delta modifications
 
@@ -105,7 +106,6 @@ TEST_F(SmokeTest, DeltaMode_Tpk_Rollback) {
 TEST_F(SmokeTest, RecoveryMode_Tpk_Installation) {
   bf::path path = kSmokePackagesDirectory / "RecoveryMode_Tpk_Installation.tpk";
   std::string pkgid = "smokeapp15";
-  std::string appid = "smokeapp15.RecoveryModeTpkInstallation";
   RemoveAllRecoveryFiles("/tpk-recovery", params.test_user.uid);
 
   std::string test_uid_str = std::to_string(params.test_user.uid);
@@ -138,12 +138,13 @@ TEST_F(SmokeTest, RecoveryMode_Tpk_Update) {
     if (step >= 1) {
       std::string pkgid = "smokeapp16";
       std::string appid = "smokeapp16.RecoveryModeTpkUpdate";
+      std::string exec = "native";
       bf::path recovery_file = FindRecoveryFile("/tpk-recovery",
           params.test_user.uid);
       EXTENDED_ASSERT_FALSE(recovery_file.empty());
       EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
           ci::AppInstaller::Result::OK);
-      EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+      EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 
       EXTENDED_ASSERT_TRUE(
           ValidateFileContentInPackage(pkgid, "VERSION", "1\n", params));
@@ -161,6 +162,7 @@ TEST_F(SmokeTest, RecoveryMode_Tpk_Update) {
   std::string number = std::to_string(50 + NUMBER - 1);                        \
   std::string pkgid = std::string("smokeapp") + number;                        \
   std::string appid = pkgid + ".TEP";                                          \
+  std::string exec = "native";                                                 \
 
 
 TEST_F(SmokeTest, TEP_Tpk_TepInstallTepUpdateRollback) {
@@ -170,7 +172,7 @@ TEST_F(SmokeTest, TEP_Tpk_TepInstallTepUpdateRollback) {
   const char* argv[] = {"", "-i", path.c_str(), "-u", test_uid_str.c_str(),
                         "-e", tep1.c_str()};
   backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool {
-    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
     EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
         "tep/tep1.tep", "tep1\n", params));
     return true;
@@ -184,7 +186,7 @@ TEST_F(SmokeTest, TEP_Tpk_NoTepInstallTepUpdateRollback) {
   const char* argv[] = {"", "-i", path.c_str(), "-u", test_uid_str.c_str(),
                         "-e", tep1.c_str()};
   backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool {
-    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
     bf::path root_path = ci::GetRootAppPath(params.is_readonly,
         params.test_user.uid);
     bf::path tep_file = root_path / pkgid / "tep" / "tep2.tep";
@@ -199,7 +201,7 @@ TEST_F(SmokeTest, TEP_Tpk_TepInstallNoTepUpdateRollback) {
   std::string test_uid_str = std::to_string(params.test_user.uid);
   const char* argv[] = {"", "-i", path.c_str(), "-u", test_uid_str.c_str()};
   backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool {
-    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
     EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
         "tep/tep1.tep", "tep1\n", params));
     return true;
@@ -215,7 +217,7 @@ TEST_F(SmokeTest, TEP_Tpk_Mount_TepInstallTepUpdateRollback) {
                         "-e", tep2.c_str()};
   backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool {
     ScopedTzipInterface package_mount(pkgid, params.test_user.uid);
-    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
     EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
         "tep/tep1.tep", "tep1\n", params));
     return true;
@@ -230,7 +232,7 @@ TEST_F(SmokeTest, TEP_Tpk_Mount_NoTepInstallTepUpdateRollback) {
                         "-e", tep1.c_str()};
   backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool {
     ScopedTzipInterface package_mount(pkgid, params.test_user.uid);
-    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
     bf::path root_path = ci::GetRootAppPath(params.is_readonly,
         params.test_user.uid);
     bf::path tep_file = root_path / pkgid / "tep" / "tep2.tep";
@@ -247,7 +249,7 @@ TEST_F(SmokeTest, TEP_Tpk_Mount_TepInstallNoTepUpdateRollback) {
   const char* argv[] = {"", "-i", path.c_str(), "-u", test_uid_str.c_str()};
   backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool {
     ScopedTzipInterface package_mount(pkgid, params.test_user.uid);
-    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
     EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
         "tep/tep1.tep", "tep1\n", params));
     return true;
@@ -257,7 +259,6 @@ TEST_F(SmokeTest, TEP_Tpk_Mount_TepInstallNoTepUpdateRollback) {
 TEST_F(SmokeTest, InstallationMode_Rollback) {
   bf::path path = kSmokePackagesDirectory / "InstallationMode_Rollback.tpk";
   std::string pkgid = "smoketpk34";
-  std::string appid = "smoketpk34.InstallationMode_Rollback";
   std::string test_uid_str = std::to_string(params.test_user.uid);
   const char* argv[] = {"", "-i", path.c_str(), "-u", test_uid_str.c_str()};
 
@@ -280,12 +281,13 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) {
     if (step >= 1) {
       std::string pkgid = "smoketpk35";
       std::string appid = "smoketpk35.RecoveryMode_ForDelta";
+      std::string exec = "smoketpk35";
       bf::path recovery_file = FindRecoveryFile("/tpk-recovery",
           params.test_user.uid);
       EXTENDED_ASSERT_FALSE(recovery_file.empty());
       EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
           ci::AppInstaller::Result::OK);
-      EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {"smoketpk35"}, params));
+      EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 
       EXTENDED_ASSERT_TRUE(
           ValidateFileContentInPackage(pkgid, "res/MODIFIED", "version 1",
@@ -304,13 +306,14 @@ TEST_F(SmokeTest, UpdateMode_Rollback) {
   bf::path new_path = kSmokePackagesDirectory / "UpdateMode_Rollback2.tpk";
   std::string pkgid = "smoketpk36";
   std::string appid = "smoketpk36.UpdateMode_Rollback";
+  std::string exec = "smoketpk36";
   ASSERT_EQ(ci::AppInstaller::Result::OK, backend.Install(old_path));
 
   std::string test_uid_str = std::to_string(params.test_user.uid);
   const char* argv[] =
       {"", "-i", new_path.c_str(), "-u", test_uid_str.c_str()};
   backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool  {
-    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {"smoketpk36"}, params));
+    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
     EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
         "res/VERSION", "1", params));
     return true;
@@ -354,6 +357,7 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
     if (step >= 1) {
       std::string pkgid = "smoketpk38";
       std::string appid = "smoketpk38.RecoveryMode_ForMountUpdate";
+      std::string exec = "smoketpk38";
 
       // Filesystem may be mounted after crash
       ScopedTzipInterface poweroff_unmount_interface(pkgid,
@@ -366,7 +370,7 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
       EXTENDED_ASSERT_EQ(backend.Recover(recovery_file),
           ci::AppInstaller::Result::OK);
       ScopedTzipInterface interface(pkgid, params.test_user.uid);
-      EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {"smoketpk38"}, params));
+      EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 
       EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
         "res/VERSION", "1", params));
@@ -379,7 +383,6 @@ TEST_F(SmokeTest, MountInstallationMode_Rollback) {
   bf::path path =
       kSmokePackagesDirectory / "MountInstallationMode_Rollback.tpk";
   std::string pkgid = "smoketpk39";
-  std::string appid = "smoketpk39.MountInstallationMode_Rollback";
   std::string test_uid_str = std::to_string(params.test_user.uid);
   const char* argv[] = {"", "-w", path.c_str(), "-u", test_uid_str.c_str()};
 
@@ -395,6 +398,7 @@ TEST_F(SmokeTest, MountUpdateMode_Rollback) {
   bf::path new_path = kSmokePackagesDirectory / "MountUpdateMode_Rollback2.tpk";
   std::string pkgid = "smoketpk40";
   std::string appid = "smoketpk40.MountUpdateMode_Rollback";
+  std::string exec = "smoketpk40";
   ASSERT_EQ(ci::AppInstaller::Result::OK, backend.MountInstall(old_path));
   std::string test_uid_str = std::to_string(params.test_user.uid);
   const char* argv[] =
@@ -402,7 +406,7 @@ TEST_F(SmokeTest, MountUpdateMode_Rollback) {
 
   backend.TestRollbackAfterEachStep(SIZEOFARRAY(argv), argv, [&]() -> bool  {
     ScopedTzipInterface package_mount(pkgid, params.test_user.uid);
-    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {"smoketpk40"}, params));
+    EXTENDED_ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
     EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid,
         "res/VERSION", "1", params));
     return true;
index 22f0fbe01da391916709f69349bc64d14e2cbcef..712ca120d63a0de8619ee3e2eb97bbe6439860fd 100644 (file)
@@ -113,9 +113,10 @@ TEST_F(SmokeTest, DeltaMode_Tpk) {
   bf::path delta_package = kSmokePackagesDirectory / "DeltaMode_Tpk.delta";
   std::string pkgid = "smokeapp18";
   std::string appid = "smokeapp18.DeltaModeTpk";
+  std::string exec = "native";
   ASSERT_EQ(backend.InstallSuccess(path), ci::AppInstaller::Result::OK);
   ASSERT_EQ(backend.Install(delta_package), ci::AppInstaller::Result::OK);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 
   // Check delta modifications
   bf::path root_path = ci::GetRootAppPath(params.is_readonly,
@@ -134,9 +135,10 @@ TEST_F(RollbackSmokeTest, DeltaMode) {
       "DeltaMode_Tpk_Rollback.delta";
   std::string pkgid = "smoketpk28";
   std::string appid = "smoketpk28.DeltaModeTpk_Rollback";
+  std::string exec = "basicdali";
   ASSERT_EQ(backend.InstallSuccess(path), ci::AppInstaller::Result::OK);
   ASSERT_EQ(backend.Install(delta_package), ci::AppInstaller::Result::ERROR);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"basicdali"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 
   // Check delta modifications
   bf::path root_path = ci::GetRootAppPath(params.is_readonly,
@@ -157,10 +159,11 @@ TEST_F(SmokeTest, ReinstallMode_Tpk) {
   bf::path rds_directory = kSmokePackagesDirectory / "delta_dir";
   std::string pkgid = "smokeapp25";
   std::string appid = "smokeapp25.ReinstallModeTpk";
+  std::string exec = "native";
   bf::path sdk_expected_directory = kSdkDirectory / "tmp" / pkgid;
   ASSERT_TRUE(ci::CopyDir(rds_directory, sdk_expected_directory));
   ASSERT_EQ(backend.RDSUpdate(path, pkgid), ci::AppInstaller::Result::OK);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 
   // Check rds modifications
   bf::path root_path = ci::GetRootAppPath(false,
@@ -177,8 +180,9 @@ TEST_F(SmokeTest, InstallationMode_Tpk) {
   bf::path path = kSmokePackagesDirectory / "InstallationMode_Tpk.tpk";
   std::string pkgid = "smokeapp12";
   std::string appid = "smokeapp12.InstallationModeTpk";
+  std::string exec = "native";
   ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 }
 
 TEST_F(SmokeTest, UpdateMode_Tpk) {
@@ -186,9 +190,10 @@ TEST_F(SmokeTest, UpdateMode_Tpk) {
   bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Tpk_2.tpk";
   std::string pkgid = "smokeapp13";
   std::string appid = "smokeapp13.UpdateModeTpk";
+  std::string exec = "native";
   ASSERT_EQ(backend.InstallSuccess(path_old), ci::AppInstaller::Result::OK);
   ASSERT_EQ(backend.Install(path_new), ci::AppInstaller::Result::OK);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "VERSION", "2\n", params));
 }
@@ -196,7 +201,6 @@ TEST_F(SmokeTest, UpdateMode_Tpk) {
 TEST_F(SmokeTest, DeinstallationMode_Tpk) {
   bf::path path = kSmokePackagesDirectory / "DeinstallationMode_Tpk.tpk";
   std::string pkgid = "smokeapp14";
-  std::string appid = "smokeapp14.DeinstallationModeTpk";
   ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
   ASSERT_EQ(backend.Uninstall(pkgid), ci::AppInstaller::Result::OK);
   ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
@@ -217,10 +221,11 @@ TEST_F(SmokeTest, DisablePkg) {
   bf::path path = kSmokePackagesDirectory / "DisablePkg.tpk";
   std::string pkgid = "smokeapp23";
   std::string appid = "smokeapp23.DisablePkg";
+  std::string exec = "=disablepkg";
   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, {"=disablepkg"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 }
 
 TEST_F(SmokeTest, RecoveryMode_Tpk_Installation) {
@@ -232,7 +237,6 @@ TEST_F(SmokeTest, RecoveryMode_Tpk_Installation) {
   ASSERT_NE(backend_crash.Wait(), 0);
 
   std::string pkgid = "smokeapp15";
-  std::string appid = "smokeapp15.RecoveryModeTpkInstallation";
   bf::path recovery_file = FindRecoveryFile("/tpk-recovery",
       params.test_user.uid);
   ASSERT_FALSE(recovery_file.empty());
@@ -252,11 +256,12 @@ TEST_F(SmokeTest, RecoveryMode_Tpk_Update) {
 
   std::string pkgid = "smokeapp16";
   std::string appid = "smokeapp16.RecoveryModeTpkUpdate";
+  std::string exec = "native";
   bf::path recovery_file = FindRecoveryFile("/tpk-recovery",
       params.test_user.uid);
   ASSERT_FALSE(recovery_file.empty());
   ASSERT_EQ(backend.Recover(recovery_file), ci::AppInstaller::Result::OK);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "VERSION", "1\n", params));
 }
@@ -265,9 +270,10 @@ TEST_F(SmokeTest, MountInstallationMode_Tpk) {
   bf::path path = kSmokePackagesDirectory / "MountInstallationMode_Tpk.tpk";
   std::string pkgid = "smokeapp26";
   std::string appid = "smokeapp26.MountInstallationModeTpk";
+  std::string exec = "native";
   ASSERT_EQ(backend.MountInstall(path), ci::AppInstaller::Result::OK);
   ScopedTzipInterface package_mount(pkgid, params.test_user.uid);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 }
 
 TEST_F(SmokeTest, MountUpdateMode_Tpk) {
@@ -275,11 +281,12 @@ TEST_F(SmokeTest, MountUpdateMode_Tpk) {
   bf::path path_new = kSmokePackagesDirectory / "MountUpdateMode_Tpk_2.tpk";
   std::string pkgid = "smokeapp27";
   std::string appid = "smokeapp27.MountUpdateModeTpk";
+  std::string exec = "native";
   ASSERT_EQ(backend.MountInstallSuccess(path_old),
       ci::AppInstaller::Result::OK);
   ASSERT_EQ(backend.MountInstall(path_new), ci::AppInstaller::Result::OK);
   ScopedTzipInterface package_mount(pkgid, params.test_user.uid);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/VERSION", "2\n",
       params));
@@ -290,13 +297,14 @@ TEST_F(SmokeTest, MigrateLegacyExternalImage_Tpk) {
   bf::path path = kSmokePackagesDirectory / "InstallExternal_Tpk_2.tpk";
   std::string pkgid = "smokeapp28";
   std::string appid = "smokeapp28.InstallExternalTpk";
+  std::string exec = "smokeapp28";
   bf::path legacy_path = kSmokePackagesDirectory / kLegacyExtImageDir;
   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, {"smokeapp28"}, params);
+    ValidateExternalPackage(pkgid, {appid, exec}, params);
   } else {
     ASSERT_EQ(backend.MigrateLegacyExternalImage(pkgid, path, legacy_path),
         ci::AppInstaller::Result::ERROR);
@@ -308,9 +316,10 @@ TEST_F(SmokeTest, InstallExternal_Tpk) {
   bf::path path = kSmokePackagesDirectory / "InstallExternal_Tpk.tpk";
   std::string pkgid = "smokeapp29";
   std::string appid = "smokeapp29.InstallExternalTpk";
+  std::string exec = "smokeapp29";
   ASSERT_EQ(backend.InstallWithStorage(path, StorageType::EXTERNAL),
       ci::AppInstaller::Result::OK);
-  ASSERT_TRUE(ValidateExternalPackage(pkgid, {"smokeapp29"}, params));
+  ASSERT_TRUE(ValidateExternalPackage(pkgid, {appid, exec}, params));
 }
 
 #define TEP_TEST_STARTING_BLOCK(NUMBER)                                        \
@@ -322,11 +331,12 @@ TEST_F(SmokeTest, InstallExternal_Tpk) {
   std::string number = std::to_string(50 + NUMBER - 1);                        \
   std::string pkgid = std::string("smokeapp") + number;                        \
   std::string appid = pkgid + ".TEP";                                          \
+  std::string exec = "native";                                                 \
 
 TEST_F(SmokeTest, TEP_Tpk_TepInstall) {
   TEP_TEST_STARTING_BLOCK(1)
   ASSERT_EQ(backend.InstallWithTEP(path, tep1), ci::AppInstaller::Result::OK);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "tep/tep1.tep", "tep1\n",
       params));
 }
@@ -335,7 +345,7 @@ TEST_F(SmokeTest, TEP_Tpk_TepInstallTepUpdate) {
   TEP_TEST_STARTING_BLOCK(2)
   ASSERT_EQ(backend.InstallWithTEP(path, tep1), ci::AppInstaller::Result::OK);
   ASSERT_EQ(backend.InstallWithTEP(path, tep2), ci::AppInstaller::Result::OK);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "tep/tep2.tep", "tep2\n",
       params));
 }
@@ -344,7 +354,7 @@ TEST_F(SmokeTest, TEP_Tpk_NoTepInstallTepUpdate) {
   TEP_TEST_STARTING_BLOCK(3)
   ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
   ASSERT_EQ(backend.InstallWithTEP(path, tep2), ci::AppInstaller::Result::OK);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "tep/tep2.tep", "tep2\n",
       params));
 }
@@ -353,7 +363,7 @@ TEST_F(SmokeTest, TEP_Tpk_TepInstallNoTepUpdate) {
   TEP_TEST_STARTING_BLOCK(4)
   ASSERT_EQ(backend.InstallWithTEP(path, tep1), ci::AppInstaller::Result::OK);
   ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "tep/tep1.tep", "tep1\n",
       params));
 }
@@ -364,7 +374,7 @@ TEST_F(RollbackSmokeTest, TEP_Tpk_TepInstallTepUpdateRollback) {
       ci::AppInstaller::Result::OK);
   ASSERT_EQ(backend.InstallWithTEP(path, tep2),
       ci::AppInstaller::Result::ERROR);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "tep/tep1.tep", "tep1\n",
       params));
 }
@@ -374,7 +384,7 @@ TEST_F(RollbackSmokeTest, TEP_Tpk_NoTepInstallTepUpdateRollback) {
   ASSERT_EQ(backend.InstallSuccess(path), ci::AppInstaller::Result::OK);
   ASSERT_EQ(backend.InstallWithTEP(path, tep2),
       ci::AppInstaller::Result::ERROR);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   bf::path root_path = ci::GetRootAppPath(params.is_readonly,
       params.test_user.uid);
   bf::path tep_file = root_path / pkgid / "tep" / "tep2.tep";
@@ -386,7 +396,7 @@ TEST_F(RollbackSmokeTest, TEP_Tpk_TepInstallNoTepUpdateRollback) {
   ASSERT_EQ(backend.InstallSuccessWithTEP(path, tep1),
       ci::AppInstaller::Result::OK);
   ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::ERROR);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "tep/tep1.tep", "tep1\n",
       params));
 }
@@ -396,7 +406,7 @@ TEST_F(SmokeTest, TEP_Tpk_Mount_TepInstall) {
   ASSERT_EQ(backend.MountInstallWithTEP(path, tep1),
       ci::AppInstaller::Result::OK);
   ScopedTzipInterface package_mount(pkgid, params.test_user.uid);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "tep/tep1.tep", "tep1\n",
       params));
 }
@@ -408,7 +418,7 @@ TEST_F(SmokeTest, TEP_Tpk_Mount_TepInstallTepUpdate) {
   ASSERT_EQ(backend.MountInstallWithTEP(path, tep2),
       ci::AppInstaller::Result::OK);
   ScopedTzipInterface package_mount(pkgid, params.test_user.uid);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "tep/tep2.tep", "tep2\n",
       params));
 }
@@ -419,7 +429,7 @@ TEST_F(SmokeTest, TEP_Tpk_Mount_NoTepInstallTepUpdate) {
   ASSERT_EQ(backend.MountInstallWithTEP(path, tep2),
       ci::AppInstaller::Result::OK);
   ScopedTzipInterface package_mount(pkgid, params.test_user.uid);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "tep/tep2.tep", "tep2\n",
       params));
 }
@@ -430,7 +440,7 @@ TEST_F(SmokeTest, TEP_Tpk_Mount_TepInstallNoTepUpdate) {
       ci::AppInstaller::Result::OK);
   ASSERT_EQ(backend.MountInstall(path), ci::AppInstaller::Result::OK);
   ScopedTzipInterface package_mount(pkgid, params.test_user.uid);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "tep/tep1.tep", "tep1\n",
       params));
 }
@@ -442,7 +452,7 @@ TEST_F(RollbackSmokeTest, TEP_Tpk_Mount_TepInstallTepUpdateRollback) {
   ASSERT_EQ(backend.MountInstallWithTEP(path, tep2),
             ci::AppInstaller::Result::ERROR);
   ScopedTzipInterface package_mount(pkgid, params.test_user.uid);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "tep/tep1.tep", "tep1\n",
       params));
 }
@@ -453,7 +463,7 @@ TEST_F(RollbackSmokeTest, TEP_Tpk_Mount_NoTepInstallTepUpdateRollback) {
   ASSERT_EQ(backend.MountInstallWithTEP(path, tep2),
             ci::AppInstaller::Result::ERROR);
   ScopedTzipInterface package_mount(pkgid, params.test_user.uid);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   bf::path root_path = ci::GetRootAppPath(params.is_readonly,
       params.test_user.uid);
   bf::path tep_file = root_path / pkgid / "tep" / "tep2.tep";
@@ -466,7 +476,7 @@ TEST_F(RollbackSmokeTest, TEP_Tpk_Mount_TepInstallNoTepUpdateRollback) {
       ci::AppInstaller::Result::OK);
   ASSERT_EQ(backend.MountInstall(path), ci::AppInstaller::Result::ERROR);
   ScopedTzipInterface package_mount(pkgid, params.test_user.uid);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "tep/tep1.tep", "tep1\n",
       params));
 }
@@ -476,8 +486,9 @@ TEST_F(PreloadSmokeTest, InstallationMode_Preload) {
   bf::path path = kSmokePackagesDirectory / "InstallationMode_Preload.tpk";
   std::string pkgid = "smoketpk29";
   std::string appid = "smoketpk29.InstallationModePreload";
+  std::string exec = "native";
   ASSERT_EQ(backend.InstallPreload(path), ci::AppInstaller::Result::OK);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 }
 
 TEST_F(PreloadSmokeTest, UpdateMode_Preload) {
@@ -486,9 +497,10 @@ TEST_F(PreloadSmokeTest, UpdateMode_Preload) {
   bf::path path_new = kSmokePackagesDirectory / "UpdateMode_Preload2.tpk";
   std::string pkgid = "smoketpk30";
   std::string appid = "smoketpk30.UpdateModePreload";
+  std::string exec = "native";
   ASSERT_EQ(backend.InstallPreload(path_old), ci::AppInstaller::Result::OK);
   ASSERT_EQ(backend.InstallPreload(path_new), ci::AppInstaller::Result::OK);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"native"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/VERSION", "2", params));
 }
@@ -497,7 +509,6 @@ TEST_F(PreloadSmokeTest, DeinstallationMode_Preload) {
   ASSERT_EQ(getuid(), 0) << "Test cannot be run by normal user";
   bf::path path = kSmokePackagesDirectory / "DeinstallationMode_Preload.tpk";
   std::string pkgid = "smoketpk31";
-  std::string appid = "smoketpk31.DeinstallationModePreload";
   ASSERT_EQ(backend.InstallPreload(path), ci::AppInstaller::Result::OK);
   ASSERT_EQ(backend.UninstallPreload(pkgid), ci::AppInstaller::Result::OK);
   CheckPackageNonExistance(pkgid, params);
@@ -518,7 +529,6 @@ TEST_F(SmokeTest, InstallationMode_WrongSignature) {
 TEST_F(RollbackSmokeTest, InstallationMode_Rollback) {
   bf::path path = kSmokePackagesDirectory / "InstallationMode_Rollback.tpk";
   std::string pkgid = "smoketpk34";
-  std::string appid = "smoketpk34.InstallationMode_Rollback";
   ASSERT_EQ(ci::AppInstaller::Result::ERROR, backend.Install(path));
   ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
 }
@@ -535,11 +545,12 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) {
 
   std::string pkgid = "smoketpk35";
   std::string appid = "smoketpk35.RecoveryMode_ForDelta";
+  std::string exec = "smoketpk35";
   bf::path recovery_file = FindRecoveryFile("/tpk-recovery",
       params.test_user.uid);
   ASSERT_FALSE(recovery_file.empty());
   ASSERT_EQ(ci::AppInstaller::Result::OK, backend.Recover(recovery_file));
-  ASSERT_TRUE(ValidatePackage(pkgid, {"smoketpk35"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/MODIFIED", "version 1",
       params));
@@ -554,9 +565,10 @@ TEST_F(RollbackSmokeTest, UpdateMode) {
   bf::path new_path = kSmokePackagesDirectory / "UpdateMode_Rollback2.tpk";
   std::string pkgid = "smoketpk36";
   std::string appid = "smoketpk36.UpdateMode_Rollback";
+  std::string exec = "smoketpk36";
   ASSERT_EQ(ci::AppInstaller::Result::OK, backend.InstallSuccess(old_path));
   ASSERT_EQ(ci::AppInstaller::Result::ERROR, backend.Install(new_path));
-  ASSERT_TRUE(ValidatePackage(pkgid, {"smoketpk36"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/VERSION", "1",
       params));
@@ -571,7 +583,6 @@ TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
   ASSERT_NE(0, backend_crash.Wait());
 
   std::string pkgid = "smoketpk37";
-  std::string appid = "smoketpk37.RecoveryMode_ForMountInstall";
   bf::path recovery_file = FindRecoveryFile("/tpk-recovery",
       params.test_user.uid);
   ASSERT_FALSE(recovery_file.empty());
@@ -593,6 +604,7 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
 
   std::string pkgid = "smoketpk38";
   std::string appid = "smoketpk38.RecoveryMode_ForMountUpdate";
+  std::string exec = "smoketpk38";
 
   // Filesystem may be mounted after crash
   ScopedTzipInterface poweroff_unmount_interface(pkgid, params.test_user.uid);
@@ -603,7 +615,7 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
   ASSERT_FALSE(recovery_file.empty());
   ASSERT_EQ(ci::AppInstaller::Result::OK, backend.Recover(recovery_file));
   ScopedTzipInterface interface(pkgid, params.test_user.uid);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"smoketpk38"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/VERSION", "1", params));
 }
@@ -612,7 +624,6 @@ TEST_F(RollbackSmokeTest, MountInstallationMode) {
   bf::path path =
       kSmokePackagesDirectory / "MountInstallationMode_Rollback.tpk";
   std::string pkgid = "smoketpk39";
-  std::string appid = "smoketpk39.MountInstallationMode_Rollback";
   ASSERT_EQ(ci::AppInstaller::Result::ERROR, backend.MountInstall(path));
   ScopedTzipInterface package_mount(pkgid, params.test_user.uid);
   ASSERT_TRUE(CheckPackageNonExistance(pkgid, params));
@@ -623,11 +634,12 @@ TEST_F(RollbackSmokeTest, MountUpdateMode) {
   bf::path new_path = kSmokePackagesDirectory / "MountUpdateMode_Rollback2.tpk";
   std::string pkgid = "smoketpk40";
   std::string appid = "smoketpk40.MountUpdateMode_Rollback";
+  std::string exec = "smoketpk40";
   ASSERT_EQ(ci::AppInstaller::Result::OK,
       backend.MountInstallSuccess(old_path));
   ASSERT_EQ(ci::AppInstaller::Result::ERROR, backend.MountInstall(new_path));
   ScopedTzipInterface package_mount(pkgid, params.test_user.uid);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"smoketpk40"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/VERSION", "1", params));
 }
@@ -637,6 +649,7 @@ TEST_F(SmokeTest, ManifestDirectInstallMode) {
   bf::path src_path = kSmokePackagesDirectory / "ManifestDirectInstallMode";
   std::string pkgid = "smoketpk41";
   std::string appid = "smoketpk41.ManifestDirectInstallMode";
+  std::string exec = "basicui";
   bf::path pkg_path = ci::GetRootAppPath(params.is_readonly,
       params.test_user.uid);
 
@@ -645,13 +658,14 @@ TEST_F(SmokeTest, ManifestDirectInstallMode) {
   ASSERT_FALSE(pkg_query.IsPackageInstalled(
       ci::GetRequestMode(params.test_user.uid)));
   ASSERT_EQ(backend.ManifestDirectInstall(pkgid), ci::AppInstaller::Result::OK);
-  ASSERT_TRUE(ValidatePackage(pkgid, {"basicui"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 }
 
 TEST_F(SmokeTest, ManifestDirectUpdateMode) {
   bf::path path = kSmokePackagesDirectory / "ManifestDirectUpdateMode.tpk";
   std::string pkgid = "smoketpk42";
   std::string appid = "smoketpk42.ManifestDirectUpdateMode";
+  std::string exec = "basicui";
 
   ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
   int install_time = GetAppInstalledTime(appid.c_str(), params.test_user.uid);
@@ -659,7 +673,7 @@ TEST_F(SmokeTest, ManifestDirectUpdateMode) {
   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, {"basicui"}, params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 }
 
 TEST_F(PreloadSmokeTest, ReadonlyUpdateInstallMode) {
@@ -667,13 +681,14 @@ TEST_F(PreloadSmokeTest, ReadonlyUpdateInstallMode) {
   bf::path path = kSmokePackagesDirectory / "ReadonlyUpdateInstallMode.tpk";
   std::string pkgid = "smoketpk43";
   std::string appid = "smoketpk43.ReadonlyUpdateInstallMode";
+  std::string exec = "basicui";
 
   ASSERT_EQ(backend.InstallPreload(path), ci::AppInstaller::Result::OK);
   ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
-  ValidatePackage(pkgid, {"basicui"}, params);
+  ValidatePackage(pkgid, {appid, exec}, params);
   TestParameters nonreadonly_params(params);
   nonreadonly_params.is_readonly = false;
-  ValidatePackage(pkgid, {"basicui"}, nonreadonly_params);
+  ValidatePackage(pkgid, {appid, exec}, nonreadonly_params);
 }
 
 TEST_F(PreloadSmokeTest, ReadonlyUpdateUninstallMode) {
@@ -685,12 +700,12 @@ TEST_F(PreloadSmokeTest, ReadonlyUpdateUninstallMode) {
 
   ASSERT_EQ(backend.InstallPreload(path), ci::AppInstaller::Result::OK);
   ASSERT_EQ(backend.Install(path), ci::AppInstaller::Result::OK);
-  ValidatePackage(pkgid, {exec}, params);
+  ValidatePackage(pkgid, {appid, exec}, params);
   TestParameters nonreadonly_params(params);
   nonreadonly_params.is_readonly = false;
-  ValidatePackage(pkgid, {exec}, nonreadonly_params);
+  ValidatePackage(pkgid, {appid, exec}, nonreadonly_params);
   ASSERT_EQ(backend.Uninstall(pkgid), ci::AppInstaller::Result::OK);
-  ValidatePackage(pkgid, {exec}, params);
+  ValidatePackage(pkgid, {appid, exec}, params);
 }
 
 TEST_F(SmokeTest, InstallExtended_Tpk) {
@@ -698,9 +713,10 @@ TEST_F(SmokeTest, InstallExtended_Tpk) {
   bf::path path = kSmokePackagesDirectory / "InstallExtended_Tpk.tpk";
   std::string pkgid = "smoketpk45";
   std::string appid = "smoketpk45.InstallExtendedTpk";
+  std::string exec = "smoketpk45.InstallExtendedTpk";
   ASSERT_EQ(backend.InstallWithStorage(path, StorageType::EXTENDED),
       ci::AppInstaller::Result::OK);
-  ASSERT_TRUE(ValidateExtendedPackage(pkgid, {appid}, params));
+  ASSERT_TRUE(ValidateExtendedPackage(pkgid, {appid, exec}, params));
 }
 
 }  // namespace smoke_test
index 4f4673ac323b9200c6c2a59a1081f7a5ade0a415..c7a326d41c397d850280e7cffc4715acb58ca673 100644 (file)
@@ -4,6 +4,9 @@
 
 #include <unit_tests/common/smoke_utils.h>
 
+#include <string>
+#include <utility>
+
 #include "tpk/tpk_installer.h"
 
 #include "unit_tests/smoke_utils.h"
@@ -16,6 +19,24 @@ namespace smoke_test {
 const bf::path kSmokePackagesDirectory =
     "/usr/share/tpk-backend-ut/test_samples/smoke/";
 
+bool ValidatePackage(const std::string& pkgid,
+    const std::pair<std::string, std::string>& app,
+    const TestParameters& params) {
+  return ValidatePackage(pkgid, Apps{ app }, params);
+}
+
+bool ValidateExternalPackage(const std::string& pkgid,
+    const std::pair<std::string, std::string>& app,
+    const TestParameters& params) {
+  return ValidateExternalPackage(pkgid, Apps{ app }, params);
+}
+
+bool ValidateExtendedPackage(const std::string& pkgid,
+    const std::pair<std::string, std::string>& app,
+    const TestParameters& params) {
+  return ValidateExtendedPackage(pkgid, Apps{ app }, params);
+}
+
 TpkBackendInterface::AppQueryInterfacePtr
 TpkBackendInterface::CreateQueryInterface() const {
   return AppQueryInterfacePtr(new tpk::TpkAppQueryInterface());
index 166a350b902f0d9499b194c5ae3673f483250a16..df1e9a4ff3b83b54df7df1ec087742cddea17d11 100644 (file)
@@ -10,6 +10,8 @@
 #include <unit_tests/common/smoke_utils.h>
 
 #include <memory>
+#include <string>
+#include <utility>
 
 #include "tpk/tpk_app_query_interface.h"
 
@@ -17,6 +19,18 @@ namespace smoke_test {
 
 extern const bf::path kSmokePackagesDirectory;
 
+bool ValidatePackage(const std::string& pkgid,
+    const std::pair<std::string, std::string>& app,
+    const TestParameters& params);
+
+bool ValidateExternalPackage(const std::string& pkgid,
+    const std::pair<std::string, std::string>& app,
+    const TestParameters& params);
+
+bool ValidateExtendedPackage(const std::string& pkgid,
+    const std::pair<std::string, std::string>& app,
+    const TestParameters& params);
+
 class TpkBackendInterface: public BackendInterface {
  public:
   using BackendInterface::BackendInterface;