modify smoke-test setup for consideration of user-db change. 99/82999/1 accepted/tizen/common/20160809.184001 accepted/tizen/ivi/20160809.232619 accepted/tizen/mobile/20160809.232357 accepted/tizen/tv/20160809.232508 accepted/tizen/wearable/20160809.232713 submit/tizen/20160809.011327 submit/tizen/20160809.051427
authorjongmyeongko <jongmyeong.ko@samsung.com>
Mon, 8 Aug 2016 13:45:35 +0000 (22:45 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Mon, 8 Aug 2016 13:45:35 +0000 (22:45 +0900)
Change-Id: Ia19906f4561e92f5d20df056cbae64caa8ad2312
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
packaging/wgt-backend.spec
src/unit_tests/smoke_test.cc

index ba0b65b..9d9f89a 100644 (file)
@@ -52,6 +52,9 @@ make %{?_smp_mflags}
 mkdir -p %{buildroot}/etc/package-manager/backend
 ln -s %{_bindir}/wgt-backend %{buildroot}%{_sysconfdir}/package-manager/backend/wgt
 
+%post tests
+/usr/sbin/setcap cap_dac_override=eip %{_bindir}/wgt-backend-ut/smoke-test
+
 %files
 %manifest wgt-backend.manifest
 %license LICENSE
index e8e9a02..97a8d22 100644 (file)
@@ -45,6 +45,7 @@ const char kApplicationDir[] = ".applications";
 const char kApplicationDirBackup[] = ".applications.bck";
 const char KUserAppsDir[] = "apps_rw";
 const char KUserAppsDirBackup[] = "apps_rw.bck";
+const char kUserDataBaseDir[] = "/opt/dbspace/user";
 
 enum class RequestResult {
   NORMAL,
@@ -186,7 +187,7 @@ void ValidatePackageFS(const std::string& pkgid,
 }
 
 void PackageCheckCleanup(const std::string& pkgid,
-                         const std::vector<std::string>& appids) {
+                         const std::vector<std::string>&) {
   bf::path root_path = ci::GetRootAppPath(false);
   bf::path package_path = root_path / pkgid;
   ASSERT_FALSE(bf::exists(package_path));
@@ -374,9 +375,13 @@ class SmokeEnvironment : public testing::Environment {
   explicit SmokeEnvironment(const bf::path& home) : home_(home) {
   }
   void SetUp() override {
+    bf::path UserDBDir = bf::path(kUserDataBaseDir) / std::to_string(getuid());
+    bf::path UserDBDirBackup = UserDBDir.string() + std::string(".bck");
+
     bs::error_code error;
     bf::remove_all(home_ / kApplicationDirBackup, error);
     bf::remove_all(home_ / KUserAppsDirBackup, error);
+    bf::remove_all(UserDBDirBackup, error);
     if (bf::exists(home_ / KUserAppsDir)) {
       bf::rename(home_ / KUserAppsDir, home_ / KUserAppsDirBackup, error);
       if (error)
@@ -393,15 +398,29 @@ class SmokeEnvironment : public testing::Environment {
                    << (home_ / kApplicationDirBackup) << " should not exist.";
       assert(!error);
     }
+    if (bf::exists(UserDBDir)) {
+      bf::rename(UserDBDir, UserDBDirBackup, error);
+      if (error)
+        LOG(ERROR) << "Failed to setup test environment. Does some previous"
+                   << " test crashed? Directory: "
+                   << UserDBDirBackup << " should not exist.";
+      assert(!error);
+    }
   }
   void TearDown() override {
+    bf::path UserDBDir = bf::path(kUserDataBaseDir) / std::to_string(getuid());
+    bf::path UserDBDirBackup = UserDBDir.string() + std::string(".bck");
+
     bs::error_code error;
     bf::remove_all(home_ / kApplicationDir, error);
     bf::remove_all(home_ / KUserAppsDir, error);
+    bf::remove_all(UserDBDir, error);
     if (bf::exists(home_ / KUserAppsDirBackup))
       bf::rename(home_ / KUserAppsDirBackup, home_ / KUserAppsDir, error);
     if (bf::exists(home_ / kApplicationDirBackup))
       bf::rename(home_ / kApplicationDirBackup, home_ / kApplicationDir, error);
+    if (bf::exists(UserDBDirBackup))
+      bf::rename(UserDBDirBackup, UserDBDir, error);
   }
 
  private: