[SmokeTest] Fix rw filesystem validation 97/119897/5
authorDamian Pietruchowski <d.pietruchow@samsung.com>
Mon, 20 Mar 2017 11:35:03 +0000 (12:35 +0100)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Fri, 26 May 2017 02:29:13 +0000 (02:29 +0000)
Requires:
https://review.tizen.org/gerrit/#/c/119323/

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

index b2cacbb8a707c7f1ebdc330ed57205f08d30fe15..de965c12af4578ce087fb520d063fdba5e702f76 100644 (file)
@@ -63,6 +63,25 @@ const char kPreloadApps[] = "/usr/apps";
 const char kPreloadManifestDir[] = "/usr/share/packages";
 const char kPreloadIcons[] = "/usr/share/icons";
 
+namespace {
+
+enum RWDirectory {
+  DATA,
+  CACHE,
+  SHARED_CACHE,
+  SHARED_DATA,
+  SHARED_TRUSTED
+};
+
+const char* rwDirectories[] = {
+  "data",
+  "cache",
+  "shared/cache",
+  "shared/data",
+  "shared/trusted"
+};
+
+}
 
 
 bool TouchFile(const bf::path& path) {
@@ -133,9 +152,9 @@ bool ValidateFileContentInPackage(const std::string& pkgid,
 void ValidatePackageRWFS(const std::string& pkgid, uid_t uid) {
   bf::path root_path = ci::GetRootAppPath(false, uid);
   bf::path package_path = root_path / pkgid;
-  bf::path data_path = package_path / "data";
-  bf::path cache_path = package_path / "cache";
-  bf::path shared_data_path = package_path / "shared" / "data";
+  bf::path data_path = package_path / rwDirectories[DATA];
+  bf::path cache_path = package_path / rwDirectories[CACHE];
+  bf::path shared_data_path = package_path / rwDirectories[SHARED_DATA];
 
   ASSERT_TRUE(bf::exists(data_path));
   ASSERT_TRUE(bf::exists(cache_path));
@@ -181,9 +200,16 @@ void ValidatePackageFS(const std::string& pkgid, const std::string& appid,
       iter != bf::recursive_directory_iterator(); ++iter) {
     if (bf::is_symlink(symlink_status(iter->path())))
       continue;
-    if (iter->path().filename() == "data" ||
-        iter->path().filename() == ".mmc")
+    bool is_rw_dir = false;
+    for(const auto rw_dir : rwDirectories) {
+      bf::path rw_dir_path = rw_dir;
+      bf::path relative_path = ci::MakeRelativePath(iter->path(), package_path);
+      is_rw_dir |= (relative_path == rw_dir_path);
+    }
+    if (iter->path().filename() == ".mmc" || is_rw_dir) {
+      iter.no_push();
       continue;
+    }
     struct stat stats;
     stat(iter->path().c_str(), &stats);
     ASSERT_EQ(uid, stats.st_uid);