Validate version when running recovery/rollback update tests 37/235337/2
authorSangyoon Jang <jeremy.jang@samsung.com>
Thu, 4 Jun 2020 02:44:35 +0000 (11:44 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Thu, 4 Jun 2020 09:03:30 +0000 (18:03 +0900)
Change-Id: I56a1a49a8e19e6d259168602f50280eb61d3a241
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/unit_tests/smoke_test.cc
src/unit_tests/test_samples/smoke/MountUpdateMode_Rollback.tpk
src/unit_tests/test_samples/smoke/MountUpdateMode_Rollback2.tpk
src/unit_tests/test_samples/smoke/RecoveryMode_ForMountUpdate.tpk
src/unit_tests/test_samples/smoke/RecoveryMode_ForMountUpdate2.tpk
src/unit_tests/test_samples/smoke/RecoveryMode_Tpk_Update.tpk
src/unit_tests/test_samples/smoke/RecoveryMode_Tpk_Update_2.tpk
src/unit_tests/test_samples/smoke/UpdateMode_Rollback.tpk
src/unit_tests/test_samples/smoke/UpdateMode_Rollback2.tpk

index 8d1c0b036db2fd84b76c4bc3b71d227d79964c4f..e6f9bc65619ed0ee68be829e8b0485149b700e06 100644 (file)
@@ -272,21 +272,28 @@ TEST_F(SmokeTest, RecoveryMode_Tpk_Update) {
   bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_Tpk_Update_2.tpk";
   RemoveAllRecoveryFiles("/tpk-recovery", params.test_user.uid);
   ASSERT_EQ(backend.Install(path_old), ci::AppInstaller::Result::OK);
+
+  std::string pkgid = "smokeapp16";
+  std::string appid = "smokeapp16.RecoveryModeTpkUpdate";
+  std::string exec = "native";
+  ci::PkgQueryInterface pkg_query(pkgid, params.test_user.uid);
+  std::string version_old = pkg_query.Version();
+
   ci::Subprocess backend_crash("/usr/bin/tpk-installer-ut/smoke-test-helper");
   std::string test_uid_str = std::to_string(params.test_user.uid);
   backend_crash.Run("-i", path_new.string(), "-u", test_uid_str.c_str());
   ASSERT_NE(backend_crash.Wait(), 0);
 
-  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, {appid, exec}, params));
 
-  ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "VERSION", "1\n", params));
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
+  ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/VERSION", "1", params));
+  ci::PkgQueryInterface pkg_query2(pkgid, params.test_user.uid, true);
+  std::string version_recovered = pkg_query2.Version();
+  ASSERT_TRUE(version_old == version_recovered);
 }
 
 TEST_F(SmokeTest, MountInstallationMode_Tpk) {
@@ -590,11 +597,16 @@ TEST_F(RollbackSmokeTest, UpdateMode) {
   std::string appid = "smoketpk36.UpdateMode_Rollback";
   std::string exec = "smoketpk36";
   ASSERT_EQ(ci::AppInstaller::Result::OK, backend.InstallSuccess(old_path));
+  ci::PkgQueryInterface pkg_query(pkgid, params.test_user.uid);
+  std::string version_old = pkg_query.Version();
   ASSERT_EQ(ci::AppInstaller::Result::ERROR, backend.Install(new_path));
-  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/VERSION", "1",
       params));
+  ci::PkgQueryInterface pkg_query2(pkgid, params.test_user.uid, true);
+  std::string version_rollbacked = pkg_query2.Version();
+  ASSERT_TRUE(version_old == version_rollbacked);
 }
 
 TEST_F(SmokeTest, RecoveryMode_ForMountInstall) {
@@ -620,14 +632,17 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
       kSmokePackagesDirectory / "RecoveryMode_ForMountUpdate2.tpk";
   RemoveAllRecoveryFiles("/tpk-recovery", params.test_user.uid);
   ASSERT_EQ(ci::AppInstaller::Result::OK, backend.MountInstall(path_old));
-  ci::Subprocess backend_crash("/usr/bin/tpk-installer-ut/smoke-test-helper");
-  std::string test_uid_str = std::to_string(params.test_user.uid);
-  backend_crash.Run("-w", path_new.string(), "-u", test_uid_str.c_str());
-  ASSERT_NE(0, backend_crash.Wait());
 
   std::string pkgid = "smoketpk38";
   std::string appid = "smoketpk38.RecoveryMode_ForMountUpdate";
   std::string exec = "smoketpk38";
+  ci::PkgQueryInterface pkg_query(pkgid, params.test_user.uid);
+  std::string version_old = pkg_query.Version();
+
+  ci::Subprocess backend_crash("/usr/bin/tpk-installer-ut/smoke-test-helper");
+  std::string test_uid_str = std::to_string(params.test_user.uid);
+  backend_crash.Run("-w", path_new.string(), "-u", test_uid_str.c_str());
+  ASSERT_NE(0, backend_crash.Wait());
 
   // Filesystem may be mounted after crash
   ScopedTzipInterface poweroff_unmount_interface(pkgid, params.test_user.uid);
@@ -638,9 +653,12 @@ 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, {appid, exec}, params));
 
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/VERSION", "1", params));
+  ci::PkgQueryInterface pkg_query2(pkgid, params.test_user.uid, true);
+  std::string version_recovered = pkg_query2.Version();
+  ASSERT_TRUE(version_old == version_recovered);
 }
 
 TEST_F(RollbackSmokeTest, MountInstallationMode) {
@@ -660,11 +678,16 @@ TEST_F(RollbackSmokeTest, MountUpdateMode) {
   std::string exec = "smoketpk40";
   ASSERT_EQ(ci::AppInstaller::Result::OK,
       backend.MountInstallSuccess(old_path));
+  ci::PkgQueryInterface pkg_query(pkgid, params.test_user.uid);
+  std::string version_old = pkg_query.Version();
   ASSERT_EQ(ci::AppInstaller::Result::ERROR, backend.MountInstall(new_path));
   ScopedTzipInterface package_mount(pkgid, params.test_user.uid);
-  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
 
+  ASSERT_TRUE(ValidatePackage(pkgid, {appid, exec}, params));
   ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/VERSION", "1", params));
+  ci::PkgQueryInterface pkg_query2(pkgid, params.test_user.uid, true);
+  std::string version_rollbacked = pkg_query2.Version();
+  ASSERT_TRUE(version_old == version_rollbacked);
 }
 
 TEST_F(SmokeTest, ManifestDirectInstallMode) {
index ccd5af09eba9e350753aabce33d5b79055330911..9cbf1c0b523905dc0df6cf7ecb2578575f0e731b 100644 (file)
Binary files a/src/unit_tests/test_samples/smoke/MountUpdateMode_Rollback.tpk and b/src/unit_tests/test_samples/smoke/MountUpdateMode_Rollback.tpk differ
index 3ec05965919d0bc72378845783caefad55b24103..2c35dfa7e21faf36344edafdfd3dcd4ec1bae51c 100644 (file)
Binary files a/src/unit_tests/test_samples/smoke/MountUpdateMode_Rollback2.tpk and b/src/unit_tests/test_samples/smoke/MountUpdateMode_Rollback2.tpk differ
index 362a1fc8e3bef03c5e306f7b64962091678603d2..4b88c7209d1730a0e37dbaabf2247bede174dd91 100644 (file)
Binary files a/src/unit_tests/test_samples/smoke/RecoveryMode_ForMountUpdate.tpk and b/src/unit_tests/test_samples/smoke/RecoveryMode_ForMountUpdate.tpk differ
index 86ef6cedc97b3ff26fa5e5f037637bf53f5f67cf..e5e525d95dd4d06624dc474341704bb74c1a17fd 100644 (file)
Binary files a/src/unit_tests/test_samples/smoke/RecoveryMode_ForMountUpdate2.tpk and b/src/unit_tests/test_samples/smoke/RecoveryMode_ForMountUpdate2.tpk differ
index 14820630cb3710f61809e70d38c102d1c1e2a220..3a04033b67479631cb453540035a1b76bff03c38 100644 (file)
Binary files a/src/unit_tests/test_samples/smoke/RecoveryMode_Tpk_Update.tpk and b/src/unit_tests/test_samples/smoke/RecoveryMode_Tpk_Update.tpk differ
index 419e2fd0d3a1d6a096f30715c07bf24d43f52096..48c28395096fed35dbd0b65c3fa8eeda36e822dc 100644 (file)
Binary files a/src/unit_tests/test_samples/smoke/RecoveryMode_Tpk_Update_2.tpk and b/src/unit_tests/test_samples/smoke/RecoveryMode_Tpk_Update_2.tpk differ
index 9ddb075619bd5c77b3acd727845b2817613ee431..e9d6f822ec8860337ae352f828b8bc00fe8b02a3 100644 (file)
Binary files a/src/unit_tests/test_samples/smoke/UpdateMode_Rollback.tpk and b/src/unit_tests/test_samples/smoke/UpdateMode_Rollback.tpk differ
index c9f2cd671da1d301fc6ead5d8c0a8e5dbf4d4482..07c53a3e20f6c540c8dc2dcced38e0358885c7e8 100644 (file)
Binary files a/src/unit_tests/test_samples/smoke/UpdateMode_Rollback2.tpk and b/src/unit_tests/test_samples/smoke/UpdateMode_Rollback2.tpk differ