Fix rw filesystem validation 14/116314/4
authorDamian Pietruchowski <d.pietruchow@samsung.com>
Thu, 23 Feb 2017 14:50:02 +0000 (15:50 +0100)
committerjaekuk lee <juku1999@samsung.com>
Fri, 3 Mar 2017 01:14:03 +0000 (17:14 -0800)
Change-Id: I666994cd9fe8f57e9d98b319188e6b86a76eb3db
Signed-off-by: Damian Pietruchowski <d.pietruchow@samsung.com>
src/unit_tests/smoke_test.cc

index 5185bdb..2512a61 100644 (file)
@@ -59,6 +59,22 @@ const char kMigrateTestDBName[] = "app2sd_migrate.db";
 const bf::path kSmokePackagesDirectory =
     "/usr/share/wgt-backend-ut/test_samples/smoke/";
 
+enum RWDirectory {
+    DATA,
+    CACHE,
+    SHARED_CACHE,
+    SHARED_DATA,
+    SHARED_TRUSTED
+};
+
+const char* rwDirectories[] = {
+  "data",
+  "cache",
+  "shared/cache",
+  "shared/data",
+  "shared/trusted",
+};
+
 // common entries
 const std::vector<std::string> kDBEntries = {
   {".pkgmgr_parser.db"},
@@ -228,9 +244,9 @@ void ValidateDataFiles(const std::string& pkgid, uid_t uid) {
 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));
@@ -291,8 +307,12 @@ void ValidatePackageFS(const std::string& pkgid,
       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;
+      is_rw_dir |= ci::MakeRelativePath(iter->path(), package_path) == rw_dir_path;
+    }
+    if (is_rw_dir || iter->path().filename() == ".mmc")
       continue;
     struct stat stats;
     stat(iter->path().c_str(), &stats);